Scippy

SCIP

Solving Constraint Integer Programs

rationalgmp.h
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file rationalgmp.h
26 * @ingroup PUBLICCOREAPI
27 * @brief wrapper for rational number arithmetic that interacts with GMP
28 * @author Leon Eifler
29 * @author Dominik Kamp
30 *
31 * This header file needs to be explicitly included by source that needs to convert between SCIP_Rational and GMP.
32 * It is intentionally not included by other header files that belong to the public SCIP API.
33 */
34
35/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
36
37#ifndef __SCIP_RATIONALGMP_H__
38#define __SCIP_RATIONALGMP_H__
39
40#include <stdlib.h>
41#include "scip/def.h"
42#include "scip/type_rational.h"
43
44#if defined(SCIP_WITH_BOOST) && defined(SCIP_WITH_GMP)
45#include <gmp.h>
46#endif
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/**@addtogroup PublicRationalMethods
53 *
54 * @{
55 */
56
57#if defined(SCIP_WITH_BOOST) && defined(SCIP_WITH_GMP)
58/** gets the underlying gmp rational pointer */
59SCIP_EXPORT
60mpq_t* SCIPrationalGetGMP(
61 SCIP_RATIONAL* rational /**< rational to access */
62 );
63
64/** sets rational to gmp rational */
65SCIP_EXPORT
66void SCIPrationalSetGMP(
67 SCIP_RATIONAL* rational, /**< rational to define */
68 const mpq_t numb /**< gmp rational to set */
69 );
70
71/** creates rational from gmp rational */
72SCIP_EXPORT
73SCIP_RETCODE SCIPrationalCreateBlockGMP(
74 BMS_BLKMEM* mem, /**< block memory */
75 SCIP_RATIONAL** rational, /**< pointer to the rational to create */
76 mpq_t numb /**< gmp rational to set */
77 );
78
79/** sets gmp rational array to values of rational array */
80SCIP_EXPORT
81void SCIPrationalSetGMPArray(
82 mpq_t* mpqaaray, /**< gmp rational array */
83 SCIP_RATIONAL** ratarrray, /**< rational array */
84 int len /**< array length */
85 );
86
87/** sets rational array to values of gmp rational array */
88SCIP_EXPORT
89void SCIPrationalSetArrayGMP(
90 SCIP_RATIONAL** ratarray, /**< rational array */
91 mpq_t* mpqarray, /**< gmp rational array */
92 int len /**< array length */
93 );
94
95/** clears gmp rational array */
96SCIP_EXPORT
97void SCIPrationalClearArrayGMP(
98 mpq_t* mpqarray, /**< gmp rational array */
99 int len /**< array length */
100 );
101#endif
102
103/** @} */
104
105#ifdef __cplusplus
106}
107#endif
108
109#endif
common defines and data types used in all packages of SCIP
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
type definitions for rational numbers
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63