Scippy

SCIP

Solving Constraint Integer Programs

rational.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 rational.h
26 * @ingroup PUBLICCOREAPI
27 * @brief wrapper for rational number arithmetic
28 * @author Leon Eifler
29 * @author Dominik Kamp
30 */
31
32/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
33
34#ifndef __SCIP_RATIONAL_H__
35#define __SCIP_RATIONAL_H__
36
37#include <stdbool.h>
38#include <stdlib.h>
39#include "scip/def.h"
40#include "scip/type_message.h"
41#include "scip/type_rational.h"
42#include "scip/type_set.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/**@addtogroup PublicRationalMethods
50 *
51 * @{
52 */
53
54/*
55 * Creation methods
56 */
57
58/** creates a rational using standard memory allocation */
59SCIP_EXPORT
61 SCIP_RATIONAL** rational /**< pointer to the rational to create */
62 );
63
64/** creates a rational using buffer memory */
65SCIP_EXPORT
67 BMS_BUFMEM* bufmem, /**< buffer memory */
68 SCIP_RATIONAL** rational /**< pointer to the rational to create */
69 );
70
71/** creates a rational using block memory */
72SCIP_EXPORT
74 BMS_BLKMEM* blkmem, /**< block memory */
75 SCIP_RATIONAL** rational /**< pointer to the rational to create */
76 );
77
78/** creates a copy of a rational using ordinary memory */
79SCIP_EXPORT
81 SCIP_RATIONAL** result, /**< pointer to the rational to create */
82 SCIP_RATIONAL* src /**< rational to copy */
83 );
84
85/** creates a copy of a rational using block memory */
86SCIP_EXPORT
88 BMS_BLKMEM* mem, /**< block memory */
89 SCIP_RATIONAL** result, /**< pointer to the rational to create */
90 SCIP_RATIONAL* src /**< rational to copy */
91 );
92
93/** creates a copy of a rational */
94SCIP_EXPORT
96 BMS_BUFMEM* bufmem, /**< buffer memory */
97 SCIP_RATIONAL** result, /**< pointer to the rational to create */
98 SCIP_RATIONAL* src /**< rational to copy */
99 );
100
101/** creates an array of rationals using ordinary memory */
102SCIP_EXPORT
104 SCIP_RATIONAL*** rational, /**< pointer to the array to create */
105 int size /**< the size of the array */
106 );
107
108/** creates an array of rationals using block memory */
109SCIP_EXPORT
111 BMS_BLKMEM* mem, /**< block memory */
112 SCIP_RATIONAL*** rational, /**< pointer to the array to create */
113 int size /**< the size of the array */
114 );
115
116/** creates an array of rationals using buffer memory */
117SCIP_EXPORT
119 BMS_BUFMEM* mem, /**< buffer memory */
120 SCIP_RATIONAL*** rational, /**< pointer to the array to create */
121 int size /**< the size of the array */
122 );
123
124/** copies an array of rationals using ordinary memory */
125SCIP_EXPORT
127 SCIP_RATIONAL*** target, /**< address to copy to */
128 SCIP_RATIONAL** src, /**< src array */
129 int len /**< size of src array */
130 );
131
132/** copies an array of rationals using block memory */
133SCIP_EXPORT
135 BMS_BLKMEM* mem, /**< block memory */
136 SCIP_RATIONAL*** target, /**< address to copy to */
137 SCIP_RATIONAL** src, /**< src array */
138 int len /**< size of src array */
139 );
140
141/** copy an array of rationals using buffer memory */
142SCIP_EXPORT
144 BMS_BUFMEM* mem, /**< buffer memory */
145 SCIP_RATIONAL*** result, /**< address to copy to */
146 SCIP_RATIONAL** src, /**< src array */
147 int len /**< size of src array */
148 );
149
150/** realloc a rational ordinary array */
151SCIP_EXPORT
153 SCIP_RATIONAL*** result, /**< address to copy to */
154 int oldlen, /**< size of src array */
155 int newlen /**< size of src array */
156 );
157
158/** realloc a rational buffer arrray */
159SCIP_EXPORT
161 BMS_BUFMEM* mem, /**< buffer memory */
162 SCIP_RATIONAL*** result, /**< address to copy to */
163 int oldlen, /**< size of src array */
164 int newlen /**< size of src array */
165 );
166
167/** realloc a rational block arrray */
168SCIP_EXPORT
170 BMS_BLKMEM* mem, /**< block memory */
171 SCIP_RATIONAL*** result, /**< address to copy to */
172 int oldlen, /**< size of src array */
173 int newlen /**< size of src array */
174 );
175
176/** deletes a rational and frees the allocated ordinary memory */
177SCIP_EXPORT
179 SCIP_RATIONAL** rational /**< address of the rational */
180 );
181
182/** deletes a rational and frees the allocated block memory */
183SCIP_EXPORT
185 BMS_BLKMEM* mem, /**< block memory */
186 SCIP_RATIONAL** rational /**< address of the rational */
187 );
188
189/** deletes a rational and frees the allocated buffer memory */
190SCIP_EXPORT
192 BMS_BUFMEM* bufmem, /**< buffer memory */
193 SCIP_RATIONAL** rational /**< address of the rational */
194 );
195
196/** deletes an array of rationals and frees the allocated ordinary memory */
197SCIP_EXPORT
199 SCIP_RATIONAL*** ratarray, /**< address of rational array */
200 int size /**< size of the array */
201 );
202
203/** deletes an array of rationals and frees the allocated block memory */
204SCIP_EXPORT
206 BMS_BLKMEM* mem, /**< block memory */
207 SCIP_RATIONAL*** ratblockarray, /**< address of rational array */
208 int size /**< size of the array */
209 );
210
211/** deletes an array of rationals and frees the allocated buffer memory */
212SCIP_EXPORT
214 BMS_BUFMEM* mem, /**< buffer memory */
215 SCIP_RATIONAL*** ratbufarray, /**< pointer to the array */
216 int size /**< size of the array */
217 );
218
219/** sets a rational to the value of another rational */
220SCIP_EXPORT
222 SCIP_RATIONAL* res, /**< the result */
223 SCIP_RATIONAL* src /**< the src */
224 );
225
226/** sets a rational to a nom/denom value */
227SCIP_EXPORT
229 SCIP_RATIONAL* res, /**< the result */
230 SCIP_Longint nom, /**< the nominator */
231 SCIP_Longint denom /**< the denominator */
232 );
233
234/** sets a rational to the value of another a real */
235SCIP_EXPORT
237 SCIP_RATIONAL* res, /**< the result */
238 SCIP_Real real /**< the value to set to */
239 );
240
241/** sets a rational to positive infinity */
242SCIP_EXPORT
244 SCIP_RATIONAL* res /**< the result */
245 );
246
247/** sets a rational to negative infinity */
248SCIP_EXPORT
250 SCIP_RATIONAL* res /**< the result */
251 );
252
253/** checks if a string describes a rational number */
254SCIP_EXPORT
256 const char* desc /**< string to check */
257 );
258
259/** sets a rational to the value described by a string */
260SCIP_EXPORT
262 SCIP_RATIONAL* res, /**< the result */
263 const char* desc /**< the string describing the rational */
264 );
265
266/** allocates and creates a rational from a string if known, otherwise assigns a null pointer */
267SCIP_EXPORT
269 BMS_BLKMEM* mem, /**< block memory */
270 SCIP_RATIONAL** rational, /**< pointer to the rational to create */
271 const char* desc /**< the string describing the rational */
272 );
273
274/** extract the next token as a rational value if it is one; in case no value is parsed the endptr is set to @p desc
275 *
276 * @return Returns TRUE if a value could be extracted, otherwise FALSE
277 */
278SCIP_EXPORT
280 char* desc, /**< string to search */
281 SCIP_RATIONAL* value, /**< pointer to store the parsed value */
282 char** endptr /**< pointer to store the final string position if successfully parsed, otherwise @p desc */
283 );
284
285/** resets the flag isfprepresentable to SCIP_ISFPREPRESENTABLE_UNKNOWN */
286SCIP_EXPORT
288 SCIP_RATIONAL* rat /**< the number to set flag for */
289 );
290
291/*
292 * Computing methods
293 */
294
295/* transforms rational into canonical form */
296SCIP_EXPORT
298 SCIP_RATIONAL* rational /**< rational to put in canonical form */
299 );
300
301/* checks if the underlying Rational has a value >= infinity;
302 * needed after underlying value was directly set, e.g. by exact lp solver
303 */
304SCIP_EXPORT
306 SCIP_RATIONAL* rational /**< rational number */
307 );
308
309/** adds two rationals and saves the result in res */
310SCIP_EXPORT
311void SCIPrationalAdd(
312 SCIP_RATIONAL* res, /**< the result */
313 SCIP_RATIONAL* op1, /**< first operand */
314 SCIP_RATIONAL* op2 /**< second operand */
315 );
316
317/** adds a rational and a real and saves the result in res */
318SCIP_EXPORT
320 SCIP_RATIONAL* res, /**< the result */
321 SCIP_RATIONAL* rat, /**< rational number */
322 SCIP_Real real /**< real number */
323 );
324
325/** subtracts two rationals and saves the result in res */
326SCIP_EXPORT
328 SCIP_RATIONAL* res, /**< the result */
329 SCIP_RATIONAL* op1, /**< first operand */
330 SCIP_RATIONAL* op2 /**< second operand */
331 );
332
333/** subtracts a rational and a real and saves the result in res */
334SCIP_EXPORT
336 SCIP_RATIONAL* res, /**< the result */
337 SCIP_RATIONAL* rat, /**< rational number */
338 SCIP_Real real /**< real number */
339 );
340
341/** returns the relative difference: (val1-val2)/max(|val1|,|val2|,1.0) of two rationals
342 *
343 * @note this method handles infinity like finite numbers
344 */
345SCIP_EXPORT
347 SCIP_RATIONAL* res, /**< the result */
348 SCIP_RATIONAL* val1, /**< first value to be compared */
349 SCIP_RATIONAL* val2 /**< second value to be compared */
350 );
351
352/** multiplies two rationals and saves the result in res */
353SCIP_EXPORT
355 SCIP_RATIONAL* res, /**< the result */
356 SCIP_RATIONAL* op1, /**< first operand */
357 SCIP_RATIONAL* op2 /**< second operand */
358 );
359
360/** multiply a rational and a real and save the result in res */
361SCIP_EXPORT
363 SCIP_RATIONAL* res, /**< the result */
364 SCIP_RATIONAL* op1, /**< first operand */
365 SCIP_Real op2 /**< second operand */
366 );
367
368/** divide two rationals and save the result in res */
369SCIP_EXPORT
370void SCIPrationalDiv(
371 SCIP_RATIONAL* res, /**< the result */
372 SCIP_RATIONAL* op1, /**< first operand */
373 SCIP_RATIONAL* op2 /**< second operand */
374 );
375
376/** divide a rational by a real and save the result in res */
377SCIP_EXPORT
379 SCIP_RATIONAL* res, /**< the result */
380 SCIP_RATIONAL* op1, /**< first operand */
381 SCIP_Real op2 /**< second operand */
382 );
383
384/* Computes res += op1 * op2 and saves the result in res */
385SCIP_EXPORT
387 SCIP_RATIONAL* res, /**< the result */
388 SCIP_RATIONAL* op1, /**< first operand */
389 SCIP_RATIONAL* op2 /**< second operand */
390 );
391
392/* Computes res += op1 * op2 and saves the result in res */
393SCIP_EXPORT
395 SCIP_RATIONAL* res, /**< the result */
396 SCIP_RATIONAL* op1, /**< first operand */
397 SCIP_Real op2 /**< second operand */
398 );
399
400/* Computes res -= op1 * op2 and saves the result in res */
401SCIP_EXPORT
403 SCIP_RATIONAL* res, /**< the result */
404 SCIP_RATIONAL* op1, /**< first operand */
405 SCIP_RATIONAL* op2 /**< second operand */
406 );
407
408/* Computes res -= op1 * op2 and saves the result in res */
409SCIP_EXPORT
411 SCIP_RATIONAL* res, /**< the result */
412 SCIP_RATIONAL* op1, /**< first operand */
413 SCIP_Real op2 /**< second operand */
414 );
415
416/** set res to -op */
417SCIP_EXPORT
419 SCIP_RATIONAL* res, /**< the result */
420 SCIP_RATIONAL* op /**< operand */
421 );
422
423/** set res to Abs(op) */
424SCIP_EXPORT
425void SCIPrationalAbs(
426 SCIP_RATIONAL* res, /**< the result */
427 SCIP_RATIONAL* op /**< operand */
428 );
429
430/** set res to 1/op */
431SCIP_EXPORT
433 SCIP_RATIONAL* res, /**< the result */
434 SCIP_RATIONAL* op /**< operand */
435 );
436
437/** compute the minimum of two rationals */
438SCIP_EXPORT
439void SCIPrationalMin(
440 SCIP_RATIONAL* res, /**< the result */
441 SCIP_RATIONAL* op1, /**< the first rational */
442 SCIP_RATIONAL* op2 /**< the second rational */
443 );
444
445/** compute the maximum of two rationals */
446SCIP_EXPORT
447void SCIPrationalMax(
448 SCIP_RATIONAL* res, /**< the result */
449 SCIP_RATIONAL* op1, /**< the first rational */
450 SCIP_RATIONAL* op2 /**< the second rational */
451 );
452
453/*
454 * Comparison methods
455 */
456
457/** checks if two rationals are equal */
458SCIP_EXPORT
460 SCIP_RATIONAL* rat1, /**< the first rational */
461 SCIP_RATIONAL* rat2 /**< the second rational */
462 );
463
464/** checks if two rationals are equal */
465SCIP_EXPORT
467 SCIP_RATIONAL* rat1, /**< the first rational */
468 SCIP_RATIONAL* rat2 /**< the second rational */
469 );
470
471/** checks if rational and real are equal */
472SCIP_EXPORT
474 SCIP_RATIONAL* rat, /**< the rational */
475 SCIP_Real real /**< the real */
476 );
477
478/** checks if real approx of rational and real are equal */
479SCIP_EXPORT
481 SCIP_SET* set, /**< SCIP set pointer */
482 SCIP_RATIONAL* rat, /**< the rational */
483 SCIP_Real real, /**< the real */
484 SCIP_ROUNDMODE_RAT roundmode /**< the rounding mode to use */
485 );
486
487/** checks if first rational is greater than second rational */
488SCIP_EXPORT
490 SCIP_RATIONAL* rat1, /**< the first rational */
491 SCIP_RATIONAL* rat2 /**< the second rational */
492 );
493
494/** checks if first rational is smaller than second rational */
495SCIP_EXPORT
497 SCIP_RATIONAL* rat1, /**< the first rational */
498 SCIP_RATIONAL* rat2 /**< the second rational */
499 );
500
501/** checks if first rational is greater or equal than second rational */
502SCIP_EXPORT
504 SCIP_RATIONAL* rat1, /**< the first rational */
505 SCIP_RATIONAL* rat2 /**< the second rational */
506 );
507
508/** checks if first rational is less or equal than second rational */
509SCIP_EXPORT
511 SCIP_RATIONAL* rat1, /**< the first rational */
512 SCIP_RATIONAL* rat2 /**< the second rational */
513 );
514
515/** checks if first rational is greater than second rational */
516SCIP_EXPORT
518 SCIP_RATIONAL* rat1, /**< the first rational */
519 SCIP_RATIONAL* rat2 /**< the second rational */
520 );
521
522/** checks if rational is greater than real */
523SCIP_EXPORT
525 SCIP_RATIONAL* rat, /**< the rational */
526 SCIP_Real real /**< the real */
527 );
528
529/** checks if rational is less than real */
530SCIP_EXPORT
532 SCIP_RATIONAL* rat, /**< the rational */
533 SCIP_Real real /**< the real */
534 );
535
536/** checks if rational is greater or equal than real */
537SCIP_EXPORT
539 SCIP_RATIONAL* rat, /**< the rational */
540 SCIP_Real real /**< the real */
541 );
542
543/** checks if rational is less or equal than real */
544SCIP_EXPORT
546 SCIP_RATIONAL* rat, /**< the rational */
547 SCIP_Real real /**< the real */
548 );
549
550/** checks if rational is zero */
551SCIP_EXPORT
553 SCIP_RATIONAL* rational /**< the rational to check */
554 );
555
556/** checks if rational is positive */
557SCIP_EXPORT
559 SCIP_RATIONAL* rational /**< the rational to check */
560 );
561
562/** checks if rational is negative */
563SCIP_EXPORT
565 SCIP_RATIONAL* rational /**< the rational to check */
566 );
567
568/** checks if rational is positive infinity */
569SCIP_EXPORT
571 SCIP_RATIONAL* rational /**< the rational to check */
572 );
573
574/** checks if rational is negative infinity */
575SCIP_EXPORT
577 SCIP_RATIONAL* rational /**< the rational to check */
578 );
579
580/** checks if rational is negative infinity */
581SCIP_EXPORT
583 SCIP_RATIONAL* rational /**< the rational to check */
584 );
585
586/** checks if rational is integral */
587SCIP_EXPORT
589 SCIP_RATIONAL* rational /**< the rational to check */
590 );
591
592/** checks if rational is exactly representable as real */
593SCIP_EXPORT
595 SCIP_RATIONAL* rational /**< the rational to check */
596 );
597
598/*
599 * Printing/Conversion methods
600 */
601
602/** converts a rational to a string for printing, returns the number of copied characters.
603 *
604 * @return number of characters printed into string, see also SCIPstrncpy()
605 *
606 * @note If return value is equal to strlen, it means the string was truncated.
607 */
608SCIP_EXPORT
610 SCIP_RATIONAL* rational, /**< the rational to print */
611 char* str, /**< the string to save the rational in */
612 int strlen /**< maximal length that can be copied to str */
613 );
614
615/** returns the strlen of a rational number */
616SCIP_EXPORT
618 SCIP_RATIONAL* rational /** rational to consider */
619 );
620
621/* if we have a C99 compiler */
622#ifdef SCIP_HAVE_VARIADIC_MACROS
623
624/** rational extension for the SCIPdebugMsg */
625/*lint -emacro(681,SCIPrationalDebugMessage) */
626/*lint -emacro(506,SCIPrationalDebugMessage) */
627/*lint -emacro(774,SCIPrationalDebugMessage) */
628#ifdef SCIP_DEBUG
629#define SCIPrationalDebugMessage(...) SCIPrationalPrintDebugMessage(__FILE__, __LINE__, __VA_ARGS__)
630#else
631#define SCIPrationalDebugMessage(...) while ( FALSE ) SCIPrationalPrintDebugMessage(__FILE__, __LINE__, __VA_ARGS__)
632#endif
633
634#else
635/* if we do not have a C99 compiler, use a workaround that prints a message, but not the file and linenumber */
636
637/** rational extension for the SCIPdebugMsg */
638#ifdef SCIP_DEBUG
639#define SCIPrationalDebugMessage printf("debug: "), SCIPrationalPrintf
640#else
641#define SCIPrationalDebugMessage while ( FALSE ) SCIPrationalPrintf
642#endif
643
644#endif
645
646/** prints rational into a file using message handler */
647SCIP_EXPORT
649 SCIP_MESSAGEHDLR* msg, /**< message handler */
650 FILE* file, /**< file pointer */
651 SCIP_RATIONAL* rational /**< the rational to print */
652 );
653
654/** prints rational depending on the verbosity level */
655SCIP_EXPORT
657 SCIP_MESSAGEHDLR* msg, /**< message handler */
658 SCIP_VERBLEVEL verblevel, /**< current verbosity level */
659 SCIP_VERBLEVEL msgverblevel, /**< verbosity level of this message */
660 SCIP_RATIONAL* rational /**< the rational to print */
661 );
662
663/** prints a rational to command line (for debugging) */
664SCIP_EXPORT
666 SCIP_RATIONAL* rational /**< the rational to print */
667 );
668
669/** printf extension for rationals (does not support all format options yet) */
670SCIP_EXPORT
672 const char* formatstr, /**< format string like in printf() function */
673 ... /**< format arguments line in printf() function */
674 );
675
676/** prints a debug message */
678 const char* sourcefile, /**< name of the source file that called the function */
679 int sourceline, /**< line in the source file where the function was called */
680 const char* formatstr, /**< format string like in printf() function */
681 ... /**< format arguments line in printf() function */
682 );
683
684/** returns the numerator of a rational as a long */
685SCIP_EXPORT
687 SCIP_RATIONAL* rational /**< the rational */
688 );
689
690/** returns the denominator of a rational as a long */
691SCIP_EXPORT
693 SCIP_RATIONAL* rational /**< the rational */
694 );
695
696/** compares denominator of a rational to a long */
697SCIP_EXPORT
699 SCIP_RATIONAL* rational, /**< the rational */
700 SCIP_Longint val /**< long value to compare to */
701 );
702
703/** returns the sign of the rational (1 if positive, -1 if negative, 0 if zero) */
704SCIP_EXPORT
706 const SCIP_RATIONAL* rational /**< the rational */
707 );
708
709/** computes fractional part of a rational number */
710SCIP_EXPORT
712 SCIP_RATIONAL* res, /**< rational to save the frac */
713 SCIP_RATIONAL* src /**< src rational */
714 );
715
716/** returns approximation of rational as SCIP_Real */
717SCIP_EXPORT
719 SCIP_RATIONAL* rational /**< the rational to convert */
720 );
721
722/** gets the relaxation of a rational as a real
723 *
724 * @note Requires MPFR if rational is not fp-representable and roundmode is different from SCIP_R_ROUND_NEAREST.
725 */
726SCIP_EXPORT
728 SCIP_RATIONAL* rational, /**< the rational to convert */
729 SCIP_ROUNDMODE_RAT roundmode /**< the rounding direction */
730 );
731
732/** rounds a rational to an integer and saves it as a rational */
733SCIP_EXPORT
735 SCIP_RATIONAL* res, /**< the resulting rounded integer */
736 SCIP_RATIONAL* src, /**< the rational to round */
737 SCIP_ROUNDMODE_RAT roundmode /**< the rounding direction */
738 );
739
740/** rounds rational to next integer in direction of roundmode
741 *
742 * @return FALSE if rational outside of long-range
743 */
744SCIP_EXPORT
746 SCIP_Longint* res, /**< the resulting rounded long int */
747 SCIP_RATIONAL* src, /**< the rational to round */
748 SCIP_ROUNDMODE_RAT roundmode /**< the rounding direction */
749 );
750
751/** compute an approximate number with denominator <= maxdenom, closest to src and save it in res using continued fractions */
752SCIP_EXPORT
754 SCIP_RATIONAL* res,
755 SCIP_RATIONAL* src,
756 SCIP_Longint maxdenom,
757 int forcegreater /**< 1 if res >= src should be enforced, -1 if res <= src should be enforced, 0 else */
758 );
759
760/*
761 * Dynamic Arrays
762 */
763
764/** creates a dynamic array of real values */
765SCIP_EXPORT
767 SCIP_RATIONALARRAY** rationalarray, /**< pointer to store the real array */
768 BMS_BLKMEM* blkmem /**< block memory */
769 );
770
771/** resizes a dynamic array of real values */
772SCIP_EXPORT
774 SCIP_RATIONALARRAY* rationalarray, /**< pointer to store the real array */
775 int newsize /**< new size */
776 );
777
778/** creates a copy of a dynamic array of real values */
779SCIP_EXPORT
781 SCIP_RATIONALARRAY** rationalarray, /**< pointer to store the copied real array */
782 BMS_BLKMEM* blkmem, /**< block memory */
783 SCIP_RATIONALARRAY* sourcerationalarray /**< dynamic real array to copy */
784 );
785
786/** frees a dynamic array of real values */
787SCIP_EXPORT
789 SCIP_RATIONALARRAY** rationalarray, /**< pointer to the real array */
790 BMS_BLKMEM* blkmem /**< block memory */
791 );
792
793/** gets value of entry in dynamic array */
794SCIP_EXPORT
796 SCIP_RATIONALARRAY* rationalarray, /**< dynamic real array */
797 int idx, /**< array index to get value for */
798 SCIP_RATIONAL* result /**< store the result */
799 );
800
801/** sets value of entry in dynamic array */
802SCIP_EXPORT
804 SCIP_RATIONALARRAY* rationalarray, /**< dynamic real array */
805 int idx, /**< array index to set value for */
806 SCIP_RATIONAL* val /**< value to set array index to */
807 );
808
809/** increases value of entry in dynamic array */
810SCIP_EXPORT
812 SCIP_RATIONALARRAY* rationalarray, /**< dynamic real array */
813 int idx, /**< array index to increase value for */
814 SCIP_RATIONAL* incval /**< value to increase array index */
815 );
816
817/** prints a rationalarray to std out */
818SCIP_EXPORT
820 SCIP_RATIONALARRAY* rationalarray /**< dynamic rational array */
821 );
822
823/** returns the minimal index of all stored non-zero elements */
824SCIP_EXPORT
826 SCIP_RATIONALARRAY* rationalarray /**< dynamic rational array */
827 );
828
829/** returns the maximal index of all stored non-zero elements */
830SCIP_EXPORT
832 SCIP_RATIONALARRAY* rationalarray /**< dynamic rational array */
833 );
834
835/** changes the infinity threshold to new value */
836SCIP_EXPORT
838 SCIP_Real inf /**< new infinity value */
839 );
840
841/** return the infinity threshold for rationals */
842SCIP_EXPORT
844 void
845 );
846
847/** @} */
848
849#ifdef __cplusplus
850}
851#endif
852
853#endif
common defines and data types used in all packages of SCIP
#define SCIP_Longint
Definition: def.h:141
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:156
SCIP_Bool SCIPrationalIsLTReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1576
SCIP_Bool SCIPrationalIsFpRepresentable(SCIP_RATIONAL *rational)
Definition: rational.cpp:1710
void SCIPrationalMin(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1342
SCIP_Bool SCIPrationalRoundLong(SCIP_Longint *res, SCIP_RATIONAL *src, SCIP_ROUNDMODE_RAT roundmode)
Definition: rational.cpp:2204
SCIP_RETCODE SCIPrationalCreateBlock(BMS_BLKMEM *blkmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:108
SCIP_RETCODE SCIPrationalCreate(SCIP_RATIONAL **rational)
Definition: rational.cpp:94
void SCIPrationalMult(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1066
void SCIPrationalInvert(SCIP_RATIONAL *res, SCIP_RATIONAL *op)
Definition: rational.cpp:1323
SCIP_Bool SCIPrationalIsAbsEQ(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1421
SCIP_RETCODE SCIPrationalarrayIncVal(SCIP_RATIONALARRAY *rationalarray, int idx, SCIP_RATIONAL *incval)
Definition: rational.cpp:2785
void SCIPrationalPrint(SCIP_RATIONAL *rational)
Definition: rational.cpp:1831
void SCIPrationalSetInfinity(SCIP_RATIONAL *res)
Definition: rational.cpp:618
void SCIPrationalAdd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:935
SCIP_Real SCIPrationalGetReal(SCIP_RATIONAL *rational)
Definition: rational.cpp:2085
void SCIPrationalGetFrac(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:2057
SCIP_RETCODE SCIPrationalCreateString(BMS_BLKMEM *mem, SCIP_RATIONAL **rational, const char *desc)
Definition: rational.cpp:796
SCIP_RETCODE SCIPrationalCopy(SCIP_RATIONAL **result, SCIP_RATIONAL *src)
Definition: rational.cpp:138
SCIP_Bool SCIPrationalIsString(const char *desc)
Definition: rational.cpp:652
void SCIPrationalResetFloatingPointRepresentable(SCIP_RATIONAL *rat)
Definition: rational.cpp:642
SCIP_Bool SCIPrationalIsApproxEQReal(SCIP_SET *set, SCIP_RATIONAL *rat, SCIP_Real real, SCIP_ROUNDMODE_RAT roundmode)
Definition: rational.cpp:1451
void SCIPrationalFreeBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **rational)
Definition: rational.cpp:461
int SCIPrationalToString(SCIP_RATIONAL *rational, char *str, int strlen)
Definition: rational.cpp:1743
void SCIPrationalarrayGetVal(SCIP_RATIONALARRAY *rationalarray, int idx, SCIP_RATIONAL *result)
Definition: rational.cpp:2729
SCIP_RETCODE SCIPrationalCreateBlockArray(BMS_BLKMEM *mem, SCIP_RATIONAL ***rational, int size)
Definition: rational.cpp:196
void SCIPrationalPrintVerbInfo(SCIP_MESSAGEHDLR *msg, SCIP_VERBLEVEL verblevel, SCIP_VERBLEVEL msgverblevel, SCIP_RATIONAL *rational)
Definition: rational.cpp:1813
void SCIPrationalAbs(SCIP_RATIONAL *res, SCIP_RATIONAL *op)
Definition: rational.cpp:1310
void SCIPrationalRoundInteger(SCIP_RATIONAL *res, SCIP_RATIONAL *src, SCIP_ROUNDMODE_RAT roundmode)
Definition: rational.cpp:2158
void SCIPrationalDiv(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1132
SCIP_Bool SCIPrationalIsAbsInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1680
SCIP_RETCODE SCIPrationalarrayResize(SCIP_RATIONALARRAY *rationalarray, int newsize)
Definition: rational.cpp:2684
SCIP_Bool SCIPrationalIsLT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1503
void SCIPrationalSetReal(SCIP_RATIONAL *res, SCIP_Real real)
Definition: rational.cpp:603
SCIP_Bool SCIPrationalIsGT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1474
SCIP_RETCODE SCIPrationalCopyBlock(BMS_BLKMEM *mem, SCIP_RATIONAL **result, SCIP_RATIONAL *src)
Definition: rational.cpp:151
void SCIPrationalCheckInfByValue(SCIP_RATIONAL *rational)
Definition: rational.cpp:552
void SCIPrationalFreeBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:473
SCIP_RETCODE SCIPrationalCopyBlockArray(BMS_BLKMEM *mem, SCIP_RATIONAL ***target, SCIP_RATIONAL **src, int len)
Definition: rational.cpp:249
void SCIPrationalDiff(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:983
SCIP_Bool SCIPrationalIsLEReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1615
SCIP_RETCODE SCIPrationalCopyBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***result, SCIP_RATIONAL **src, int len)
Definition: rational.cpp:267
SCIP_Bool SCIPrationalIsPositive(SCIP_RATIONAL *rational)
Definition: rational.cpp:1640
SCIP_Longint SCIPrationalDenominator(SCIP_RATIONAL *rational)
Definition: rational.cpp:2027
int SCIPrationalGetSign(const SCIP_RATIONAL *rational)
Definition: rational.cpp:2048
SCIP_Real SCIPrationalGetInfinity(void)
Definition: rational.cpp:2863
SCIP_RETCODE SCIPrationalCreateBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **rational)
Definition: rational.cpp:123
void SCIPrationalAddProd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1173
SCIP_Bool SCIPrationalIsZero(SCIP_RATIONAL *rational)
Definition: rational.cpp:1624
void SCIPrationalSetRational(SCIP_RATIONAL *res, SCIP_RATIONAL *src)
Definition: rational.cpp:569
int SCIPrationalarrayGetMinIdx(SCIP_RATIONALARRAY *rationalarray)
Definition: rational.cpp:2824
void SCIPrationalSetString(SCIP_RATIONAL *res, const char *desc)
Definition: rational.cpp:716
SCIP_Bool SCIPrationalIsGEReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1606
void SCIPrationalFreeArray(SCIP_RATIONAL ***ratarray, int size)
Definition: rational.cpp:485
SCIP_RETCODE SCIPrationalReallocArray(SCIP_RATIONAL ***result, int oldlen, int newlen)
Definition: rational.cpp:285
SCIP_Bool SCIPrationalIsIntegral(SCIP_RATIONAL *rational)
Definition: rational.cpp:1691
SCIP_Bool SCIPrationalDenominatorIsLE(SCIP_RATIONAL *rational, SCIP_Longint val)
Definition: rational.cpp:2036
void SCIPrationalMax(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1373
void SCIPrationalRelDiff(SCIP_RATIONAL *res, SCIP_RATIONAL *val1, SCIP_RATIONAL *val2)
Definition: rational.cpp:1024
SCIP_Bool SCIPrationalIsGE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1512
SCIP_RETCODE SCIPrationalarraySetVal(SCIP_RATIONALARRAY *rationalarray, int idx, SCIP_RATIONAL *val)
Definition: rational.cpp:2746
SCIP_Bool SCIPstrToRationalValue(char *desc, SCIP_RATIONAL *value, char **endptr)
Definition: rational.cpp:822
void SCIPrationalPrintDebugMessage(const char *sourcefile, int sourceline, const char *formatstr,...)
Definition: rational.cpp:1936
void SCIPrationalCanonicalize(SCIP_RATIONAL *rational)
Definition: rational.cpp:538
void SCIPrationalMessage(SCIP_MESSAGEHDLR *msg, FILE *file, SCIP_RATIONAL *rational)
Definition: rational.cpp:1790
void SCIPrationalSetNegInfinity(SCIP_RATIONAL *res)
Definition: rational.cpp:630
void SCIPrationalSetFraction(SCIP_RATIONAL *res, SCIP_Longint nom, SCIP_Longint denom)
Definition: rational.cpp:582
void SCIPrationalNegate(SCIP_RATIONAL *res, SCIP_RATIONAL *op)
Definition: rational.cpp:1297
SCIP_RETCODE SCIPrationalarrayCreate(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem)
Definition: rational.cpp:2668
SCIP_Bool SCIPrationalIsNegative(SCIP_RATIONAL *rational)
Definition: rational.cpp:1650
void SCIPrationalDiffReal(SCIP_RATIONAL *res, SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1009
int SCIPrationalarrayGetMaxIdx(SCIP_RATIONALARRAY *rationalarray)
Definition: rational.cpp:2834
SCIP_Bool SCIPrationalIsInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1660
void SCIPrationalFreeBlockArray(BMS_BLKMEM *mem, SCIP_RATIONAL ***ratblockarray, int size)
Definition: rational.cpp:501
SCIP_Real SCIPrationalRoundReal(SCIP_RATIONAL *rational, SCIP_ROUNDMODE_RAT roundmode)
Definition: rational.cpp:2110
SCIP_Longint SCIPrationalNumerator(SCIP_RATIONAL *rational)
Definition: rational.cpp:2018
SCIP_Bool SCIPrationalIsEQReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1437
SCIP_RETCODE SCIPrationalCreateArray(SCIP_RATIONAL ***rational, int size)
Definition: rational.cpp:179
SCIP_RETCODE SCIPrationalCreateBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***rational, int size)
Definition: rational.cpp:214
SCIP_RETCODE SCIPrationalarrayCopy(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem, SCIP_RATIONALARRAY *sourcerationalarray)
Definition: rational.cpp:2697
SCIP_Bool SCIPrationalIsNegInfinity(SCIP_RATIONAL *rational)
Definition: rational.cpp:1670
void SCIPrationalFree(SCIP_RATIONAL **rational)
Definition: rational.cpp:450
void SCIPrationalDiffProdReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1268
SCIP_RETCODE SCIPrationalarrayFree(SCIP_RATIONALARRAY **rationalarray, BMS_BLKMEM *blkmem)
Definition: rational.cpp:2714
void SCIPrationalDivReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1147
SCIP_Bool SCIPrationalIsGTReal(SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:1546
SCIP_RETCODE SCIPrationalReallocBlockArray(BMS_BLKMEM *mem, SCIP_RATIONAL ***result, int oldlen, int newlen)
Definition: rational.cpp:344
SCIP_Bool SCIPrationalIsEQ(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1404
void SCIPrationalChgInfinity(SCIP_Real inf)
Definition: rational.cpp:2844
void SCIPrationalDiffProd(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_RATIONAL *op2)
Definition: rational.cpp:1239
void SCIPrationalPrintf(const char *formatstr,...)
Definition: rational.cpp:1923
SCIP_RETCODE SCIPrationalReallocBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***result, int oldlen, int newlen)
Definition: rational.cpp:314
void SCIPrationalMultReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1097
void SCIPrationalComputeApproximation(SCIP_RATIONAL *res, SCIP_RATIONAL *src, SCIP_Longint maxdenom, int forcegreater)
Definition: rational.cpp:2464
void SCIPrationalFreeBufferArray(BMS_BUFMEM *mem, SCIP_RATIONAL ***ratbufarray, int size)
Definition: rational.cpp:518
SCIP_RETCODE SCIPrationalCopyBuffer(BMS_BUFMEM *bufmem, SCIP_RATIONAL **result, SCIP_RATIONAL *src)
Definition: rational.cpp:165
SCIP_Bool SCIPrationalIsAbsGT(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1530
SCIP_Bool SCIPrationalIsLE(SCIP_RATIONAL *rat1, SCIP_RATIONAL *rat2)
Definition: rational.cpp:1521
void SCIPrationalAddReal(SCIP_RATIONAL *res, SCIP_RATIONAL *rat, SCIP_Real real)
Definition: rational.cpp:961
SCIP_RETCODE SCIPrationalCopyArray(SCIP_RATIONAL ***target, SCIP_RATIONAL **src, int len)
Definition: rational.cpp:232
SCIP_RETCODE SCIPrationalarrayPrint(SCIP_RATIONALARRAY *rationalarray)
Definition: rational.cpp:2809
int SCIPrationalStrLen(SCIP_RATIONAL *rational)
Definition: rational.cpp:1774
void SCIPrationalAddProdReal(SCIP_RATIONAL *res, SCIP_RATIONAL *op1, SCIP_Real op2)
Definition: rational.cpp:1210
memory allocation routines
struct BMS_BlkMem BMS_BLKMEM
Definition: memory.h:437
double real
Definition: heur_padm.c:135
type definitions for message output methods
enum SCIP_VerbLevel SCIP_VERBLEVEL
Definition: type_message.h:64
type definitions for rational numbers
enum SCIP_RoundModeRational SCIP_ROUNDMODE_RAT
Definition: type_rational.h:61
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63
type definitions for global SCIP settings