|
Go to the documentation of this file.
42 #define SCIP_ROUND_DOWNWARDS FE_DOWNWARD
43 #define SCIP_ROUND_UPWARDS FE_UPWARD
44 #define SCIP_ROUND_NEAREST FE_TONEAREST
45 #define SCIP_ROUND_ZERO FE_TOWARDZERO
60 if( fesetround(roundmode) != 0 )
88 #define SCIP_ROUND_DOWNWARDS FP_RND_RM
89 #define SCIP_ROUND_UPWARDS FP_RND_RP
90 #define SCIP_ROUND_NEAREST FP_RND_RN
91 #define SCIP_ROUND_ZERO FP_RND_RZ
106 if( write_rnd(roundmode) != 0 )
134 #define SCIP_ROUND_DOWNWARDS RC_DOWN
135 #define SCIP_ROUND_UPWARDS RC_UP
136 #define SCIP_ROUND_NEAREST RC_NEAR
137 #define SCIP_ROUND_ZERO RC_CHOP
152 if( (_controlfp(roundmode, _MCW_RC) & _MCW_RC) != roundmode )
164 return _controlfp(0, 0) & _MCW_RC;
174 #define SCIP_ROUND_DOWNWARDS 0
175 #define SCIP_ROUND_UPWARDS 1
176 #define SCIP_ROUND_NEAREST 2
177 #define SCIP_ROUND_ZERO 3
192 SCIPerrorMessage( "setting rounding mode not available - interval arithmetic is invalid!\n");
207 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
220 asm volatile ( "fldl %1; fchs; fstpl %0" : "=m" (x) : "m" (x));
227 #elif defined(_MSC_VER) && (defined(__INTEL_COMPILER) || !defined(_M_X64))
249 #define nextafter(x,y) _nextafter(x,y)
255 #if defined(_MSC_VER) && defined(_M_X64) && !defined(NO_NEXTAFTER)
256 #define nextafter(x,y) _nextafter(x,y)
289 #define __HI(x) *(1+(int*)&x)
290 #define __LO(x) *(int*)&x
291 #define __HIp(x) *(1+(int*)x)
292 #define __LOp(x) *(int*)x
295 double nextafter( double x, double y)
311 if( ((ix>=0x7ff00000) && ((ix-0x7ff00000)|lx) != 0 ) ||
312 ( (iy>=0x7ff00000) && ((iy-0x7ff00000)|ly) != 0 ))
323 __HI(x) = hy&0x80000000;
335 if( hx > hy || ((hx == hy) && (lx > ly)) )
352 if( hy >= 0 || hx > hy || ((hx == hy) && (lx > ly)) )
369 if( hy >= 0x7ff00000 )
371 if( hy < 0x00100000 )
439 #undef SCIPintervalGetInf
440 #undef SCIPintervalGetSup
441 #undef SCIPintervalSet
442 #undef SCIPintervalSetBounds
443 #undef SCIPintervalSetEmpty
444 #undef SCIPintervalIsEmpty
445 #undef SCIPintervalSetEntire
446 #undef SCIPintervalIsEntire
447 #undef SCIPintervalIsPositiveInfinity
448 #undef SCIPintervalIsNegativeInfinity
472 assert(resultant != NULL);
474 resultant-> inf = value;
475 resultant-> sup = value;
485 assert(resultant != NULL);
488 resultant-> inf = inf;
489 resultant-> sup = sup;
497 assert(resultant != NULL);
499 resultant-> inf = 1.0;
500 resultant-> sup = -1.0;
508 return operand. sup < operand. inf;
517 assert(resultant != NULL);
519 resultant-> inf = -infinity;
520 resultant-> sup = infinity;
529 return operand. inf <= -infinity && operand. sup >= infinity;
538 return operand. inf >= infinity && operand. sup >= operand. inf;
547 return operand. sup <= -infinity && operand. inf <= operand. sup;
558 if( operand1. inf > operand1. sup )
562 if( operand2. inf > operand2. sup )
565 return ( MAX(-infinity, operand1. inf) >= operand2. inf) &&
566 ( MIN( infinity, operand1. sup) <= operand2. sup);
575 return (operand1. sup < operand2. inf) || (operand2. sup < operand1. inf);
585 assert(resultant != NULL);
598 assert(resultant != NULL);
600 if( operand1. inf > operand1. sup )
603 *resultant = operand2;
607 if( operand2. inf > operand2. sup )
610 *resultant = operand1;
627 assert(resultant != NULL);
630 if( operand1. inf <= -infinity || operand2. inf <= -infinity )
632 resultant-> inf = -infinity;
635 else if( operand1. inf >= infinity || operand2. inf >= infinity )
637 resultant-> inf = infinity;
641 resultant-> inf = operand1. inf + operand2. inf;
654 assert(resultant != NULL);
657 if( operand1. sup >= infinity || operand2. sup >= infinity )
659 resultant-> sup = infinity;
662 else if( operand1. sup <= -infinity || operand2. sup <= -infinity )
664 resultant-> sup = -infinity;
668 resultant-> sup = operand1. sup + operand2. sup;
682 assert(resultant != NULL);
683 assert(operand1. inf <= operand1. sup);
684 assert(operand2. inf <= operand2. sup);
709 assert(resultant != NULL);
710 assert(operand1. inf <= operand1. sup);
715 if( operand1. inf <= -infinity || operand2 <= -infinity )
717 resultant-> inf = -infinity;
719 else if( operand1. inf >= infinity || operand2 >= infinity )
722 resultant-> inf = infinity;
727 resultant-> inf = operand1. inf + operand2;
731 if( operand1. sup >= infinity || operand2 >= infinity )
733 resultant-> sup = infinity;
735 else if( operand1. sup <= -infinity || operand2 <= -infinity )
738 resultant-> sup = -infinity;
743 resultant-> sup = operand1. sup + operand2;
765 for( i = 0; i < length; ++i )
771 for( i = 0; i < length; ++i )
789 assert(resultant != NULL);
790 assert(operand1. inf <= operand1. sup);
791 assert(operand2. inf <= operand2. sup);
795 if( operand1. inf <= -infinity || operand2. sup >= infinity )
796 resultant-> inf = -infinity;
798 else if( operand1. inf >= infinity || operand2. sup <= -infinity )
800 resultant-> inf = infinity;
801 resultant-> sup = infinity;
807 resultant-> inf = operand1. inf - operand2. sup;
810 if( operand1. sup >= infinity || operand2. inf <= -infinity )
811 resultant-> sup = infinity;
813 else if( operand1. sup <= -infinity || operand2. inf >= infinity )
815 assert(resultant-> inf == -infinity);
816 resultant-> sup = -infinity;
821 resultant-> sup = operand1. sup - operand2. inf;
846 assert(resultant != NULL);
847 assert(operand1. inf <= operand1. sup);
848 assert(operand2. inf <= operand2. sup);
851 if( operand1. inf >= infinity )
854 assert(operand1. sup >= infinity);
857 else if( operand2. inf >= infinity )
860 assert(operand2. sup >= infinity);
863 else if( operand1. sup <= -infinity )
866 assert(operand1. inf <= -infinity);
869 else if( operand2. sup <= -infinity )
872 assert(operand2. inf <= -infinity);
875 else if( ( operand1. inf <= -infinity && operand2. sup > 0.0 )
876 || ( operand1. sup > 0.0 && operand2. inf <= -infinity )
877 || ( operand1. inf < 0.0 && operand2. sup >= infinity )
878 || ( operand1. sup >= infinity && operand2. inf < 0.0 ) )
880 resultant-> inf = -infinity;
889 cand1 = operand1. inf * operand2. inf;
890 cand2 = operand1. inf * operand2. sup;
891 cand3 = operand1. sup * operand2. inf;
892 cand4 = operand1. sup * operand2. sup;
893 resultant-> inf = MIN( MIN(cand1, cand2), MIN(cand3, cand4));
905 assert(resultant != NULL);
906 assert(operand1. inf <= operand1. sup);
907 assert(operand2. inf <= operand2. sup);
910 if( operand1. inf >= infinity )
913 assert(operand1. sup >= infinity);
916 else if( operand2. inf >= infinity )
919 assert(operand2. sup >= infinity);
922 else if( operand1. sup <= -infinity )
925 assert(operand1. inf <= -infinity);
928 else if( operand2. sup <= -infinity )
931 assert(operand2. inf <= -infinity);
934 else if( ( operand1. inf <= -infinity && operand2. inf < 0.0 )
935 || ( operand1. inf < 0.0 && operand2. inf <= -infinity )
936 || ( operand1. sup > 0.0 && operand2. sup >= infinity )
937 || ( operand1. sup >= infinity && operand2. sup > 0.0 ) )
939 resultant-> sup = infinity;
948 cand1 = operand1. inf * operand2. inf;
949 cand2 = operand1. inf * operand2. sup;
950 cand3 = operand1. sup * operand2. inf;
951 cand4 = operand1. sup * operand2. sup;
952 resultant-> sup = MAX( MAX(cand1, cand2), MAX(cand3, cand4));
966 assert(resultant != NULL);
967 assert(operand1. inf <= operand1. sup);
968 assert(operand2. inf <= operand2. sup);
992 assert(resultant != NULL);
993 assert(operand1. inf <= operand1. sup);
995 if( operand2 >= infinity )
998 if( operand1. inf > 0 )
999 resultant-> inf = infinity;
1000 else if( operand1. inf < 0 )
1001 resultant-> inf = -infinity;
1003 resultant-> inf = 0.0;
1005 else if( operand2 <= -infinity )
1008 if( operand1. sup > 0 )
1009 resultant-> inf = -infinity;
1010 else if( operand1. sup < 0 )
1011 resultant-> inf = infinity;
1013 resultant-> inf = 0.0;
1015 else if( operand2 == 0.0 )
1017 resultant-> inf = 0.0;
1019 else if( operand2 > 0.0 )
1021 if( operand1. inf <= -infinity )
1022 resultant-> inf = -infinity;
1023 else if( operand1. inf >= infinity )
1024 resultant-> inf = infinity;
1026 resultant-> inf = operand1. inf * operand2;
1030 if( operand1. sup >= infinity )
1031 resultant-> inf = -infinity;
1032 else if( operand1. sup <= -infinity )
1033 resultant-> inf = infinity;
1035 resultant-> inf = operand1. sup * operand2;
1048 assert(resultant != NULL);
1049 assert(operand1. inf <= operand1. sup);
1051 if( operand2 >= infinity )
1054 if( operand1. sup > 0 )
1055 resultant-> sup = infinity;
1056 else if( operand1. sup < 0 )
1057 resultant-> sup = -infinity;
1059 resultant-> sup = 0.0;
1061 else if( operand2 <= -infinity )
1064 if( operand1. inf > 0 )
1065 resultant-> sup = -infinity;
1066 else if( operand1. inf < 0 )
1067 resultant-> sup = infinity;
1069 resultant-> sup = 0.0;
1071 else if( operand2 == 0.0 )
1073 resultant-> sup = 0.0;
1075 else if( operand2 > 0.0 )
1077 if( operand1. sup >= infinity )
1078 resultant-> sup = infinity;
1079 else if( operand1. sup <= -infinity )
1080 resultant-> sup = -infinity;
1082 resultant-> sup = operand1. sup * operand2;
1086 if( operand1. inf <= -infinity )
1087 resultant-> sup = infinity;
1088 else if( operand1. inf >= infinity )
1089 resultant-> sup = -infinity;
1091 resultant-> sup = operand1. inf * operand2;
1105 assert(resultant != NULL);
1106 assert(operand1. inf <= operand1. sup);
1132 assert(resultant != NULL);
1133 assert(operand1. inf <= operand1. sup);
1134 assert(operand2. inf <= operand2. sup);
1136 if( operand2. inf <= 0.0 && operand2. sup >= 0.0 )
1138 resultant-> inf = -infinity;
1139 resultant-> sup = infinity;
1143 if( operand1. inf == 0.0 && operand1. sup == 0.0 )
1152 if( operand2. sup >= infinity || operand2. sup <= -infinity )
1159 intmed. inf = 1.0 / operand2. sup;
1161 if( operand2. inf <= -infinity || operand2. inf >= infinity )
1168 intmed. sup = 1.0 / operand2. inf;
1185 assert(resultant != NULL);
1186 assert(operand1. inf <= operand1. sup);
1190 if( operand2 >= infinity || operand2 <= -infinity )
1193 resultant-> inf = 0.0;
1194 resultant-> sup = 0.0;
1196 else if( operand2 > 0.0 )
1198 if( operand1. inf <= -infinity )
1199 resultant-> inf = -infinity;
1200 else if( operand1. inf >= infinity )
1203 resultant-> inf = infinity;
1208 resultant-> inf = operand1. inf / operand2;
1211 if( operand1. sup >= infinity )
1212 resultant-> sup = infinity;
1213 else if( operand1. sup <= -infinity )
1216 resultant-> sup = -infinity;
1221 resultant-> sup = operand1. sup / operand2;
1224 else if( operand2 < 0.0 )
1226 if( operand1. sup >= infinity )
1227 resultant-> inf = -infinity;
1228 else if( operand1. sup <= -infinity )
1231 resultant-> inf = infinity;
1236 resultant-> inf = operand1. sup / operand2;
1239 if( operand1. inf <= -infinity )
1240 resultant-> sup = infinity;
1241 else if( operand1. inf >= infinity )
1244 resultant-> sup = -infinity;
1249 resultant-> sup = operand1. inf / operand2;
1254 if( operand1. inf >= 0 )
1257 resultant-> inf = infinity;
1258 resultant-> sup = infinity;
1260 else if( operand1. sup <= 0 )
1263 resultant-> inf = -infinity;
1264 resultant-> sup = -infinity;
1269 resultant-> inf = -infinity;
1270 resultant-> sup = infinity;
1293 resultant-> inf = 0.0;
1294 resultant-> sup = 0.0;
1298 for( i = 0; i < length && resultant-> inf > -infinity; ++i )
1304 assert(resultant-> sup == 0.0);
1308 for( i = 0; i < length && resultant-> sup < infinity ; ++i )
1334 resultant-> inf = 0.0;
1338 for( i = 0; i < length && resultant-> inf > -infinity; ++i )
1341 assert(prod. sup >= infinity);
1362 resultant-> sup = 0.0;
1366 for( i = 0; i < length && resultant-> sup < infinity; ++i )
1369 assert(prod. inf <= -infinity);
1387 resultant-> inf = 0.0;
1388 resultant-> sup = 0.0;
1393 assert(resultant-> sup == 0.0);
1411 assert(resultant != NULL);
1412 assert(operand. inf <= operand. sup);
1416 if( operand. sup <= 0.0 )
1418 if( operand. sup <= -infinity )
1419 resultant-> inf = infinity;
1423 resultant-> inf = operand. sup * operand. sup;
1426 if( operand. inf <= -infinity )
1427 resultant-> sup = infinity;
1431 resultant-> sup = operand. inf * operand. inf;
1434 else if( operand. inf >= 0.0 )
1436 if( operand. inf >= infinity )
1437 resultant-> inf = infinity;
1441 resultant-> inf = operand. inf * operand. inf;
1444 if( operand. sup >= infinity )
1445 resultant-> sup = infinity;
1449 resultant-> sup = operand. sup * operand. sup;
1454 resultant-> inf = 0.0;
1455 if( operand. inf <= -infinity || operand. sup >= infinity )
1456 resultant-> sup = infinity;
1463 x = operand. inf * operand. inf;
1464 y = operand. sup * operand. sup;
1465 resultant-> sup = MAX(x, y);
1481 assert(resultant != NULL);
1482 assert(operand. inf <= operand. sup);
1484 if( operand. sup < 0.0 )
1490 if( operand. inf == operand. sup )
1492 if( operand. inf >= infinity )
1494 resultant-> inf = infinity;
1495 resultant-> sup = infinity;
1510 if( operand. inf <= 0.0 )
1511 resultant-> inf = 0.0;
1512 else if( operand. inf >= infinity )
1514 resultant-> inf = infinity;
1515 resultant-> sup = infinity;
1523 if( operand. sup >= infinity )
1524 resultant-> sup = infinity;
1543 assert(resultant != NULL);
1544 assert(operand1. inf <= operand1. sup);
1545 assert(operand2. inf <= operand2. sup);
1547 if( operand2. inf == operand2. sup )
1577 assert(operand1 >= 0.0);
1579 if( operand1 == 0.0 )
1581 assert(operand2 >= 0);
1589 if( operand1 == 1.0 || operand2 == 0 )
1596 assert(result != 0.0);
1600 result = 1.0 / result;
1611 n = ( unsigned int)operand2;
1630 result = result * z;
1659 assert(operand1 >= 0.0);
1661 if( operand1 == 0.0 )
1663 assert(operand2 >= 0);
1671 if( operand1 == 1.0 || operand2 == 0 )
1678 assert(result != 0.0);
1682 result = 1.0 / result;
1693 n = ( unsigned int)operand2;
1704 result = result * z;
1733 assert(operand1 >= 0.0);
1735 if( operand1 == 0.0 )
1737 assert(operand2 >= 0);
1751 if( operand1 == 1.0 || operand2 == 0 )
1761 assert(resultant-> inf > 0.0 || resultant-> sup < 0.0);
1778 n = ( unsigned int)operand2;
1791 result_sup = result_sup * z_sup;
1799 z_sup = z_sup * z_sup;
1805 resultant-> inf = result_inf;
1806 resultant-> sup = result_sup;
1807 assert(resultant-> inf <= resultant-> sup);
1824 assert(resultant != NULL);
1826 if( operand1 == 0.0 )
1828 assert(operand2 >= 0);
1842 if( operand1 == 1.0 || operand2 == 0 )
1849 result = pow(operand1, operand2);
1868 assert(resultant != NULL);
1869 assert(operand1. inf <= operand1. sup);
1871 if( operand2 == infinity )
1877 if( operand1. inf < 0.0 )
1878 resultant-> inf = -infinity;
1880 resultant-> inf = 0.0;
1881 if( operand1. sup > 0.0 )
1882 resultant-> sup = infinity;
1884 resultant-> sup = 0.0;
1888 if( operand2 == 0.0 )
1890 if( operand1. inf == 0.0 && operand1. sup == 0.0 )
1892 resultant-> inf = 0.0;
1893 resultant-> sup = 0.0;
1895 else if( operand1. inf <= 0.0 || operand1. sup >= 0.0 )
1897 resultant-> inf = 0.0;
1898 resultant-> sup = 1.0;
1902 resultant-> inf = 1.0;
1903 resultant-> sup = 1.0;
1908 if( operand2 == 1.0 )
1911 *resultant = operand1;
1915 op2isint = (ceil(operand2) == operand2);
1917 if( !op2isint && operand1. inf < 0.0 )
1920 if( operand1. sup < operand1. inf )
1927 if( operand1. inf >= 0.0 )
1929 if( operand2 >= 0.0 )
1932 if( operand1. inf >= infinity )
1933 resultant-> inf = infinity;
1934 else if( operand1. inf > 0.0 )
1940 resultant-> inf = 0.0;
1942 if( operand1. sup >= infinity )
1943 resultant-> sup = infinity;
1944 else if( operand1. sup > 0.0 )
1950 resultant-> sup = 0.0;
1954 if( operand1. sup >= infinity )
1955 resultant-> inf = 0.0;
1956 else if( operand1. sup == 0.0 )
1960 if( ceil(operand2/2) == operand2/2 )
1961 resultant-> inf = infinity;
1963 resultant-> inf = -infinity;
1972 if( operand1. inf == 0.0 )
1973 resultant-> sup = infinity;
1981 else if( operand1. sup <= 0.0 )
1984 if( operand2 >= 0.0 && ceil(operand2/2) == operand2/2 )
1987 if( operand1. sup == -infinity )
1989 resultant-> inf = infinity;
1993 if( operand1. inf <= -infinity )
1994 resultant-> sup = infinity;
1998 else if( operand2 <= 0.0 && ceil(operand2/2) != operand2/2 )
2001 if( operand1. sup == -infinity )
2003 resultant-> inf = 0.0;
2004 else if( operand1. sup == 0.0 )
2006 resultant-> inf = -infinity;
2010 if( operand1. inf <= -infinity )
2012 resultant-> sup = 0.0;
2013 else if( operand1. inf == 0.0 )
2015 resultant-> sup = infinity;
2019 else if( operand2 >= 0.0 )
2022 if( operand1. inf <= -infinity )
2023 resultant-> inf = -infinity;
2027 if( operand1. sup <= -infinity )
2028 resultant-> sup = -infinity;
2035 if( operand1. inf <= -infinity )
2036 resultant-> inf = 0.0;
2037 else if( operand1. inf == 0.0 )
2039 resultant-> inf = infinity;
2043 if( operand1. sup <= -infinity )
2044 resultant-> sup = 0.0;
2045 else if( operand1. sup == 0.0 )
2047 resultant-> sup = infinity;
2051 assert(resultant-> inf <= resultant-> sup || resultant-> inf >= infinity || resultant-> sup <= -infinity);
2056 if( operand2 >= 0.0 && operand2/2 == ceil(operand2/2) )
2059 resultant-> inf = 0.0;
2060 if( operand1. inf == -infinity || operand1. sup == infinity )
2061 resultant-> sup = infinity;
2065 else if( operand2 <= 0.0 && ceil(operand2/2) != operand2/2 )
2068 resultant-> sup = infinity;
2069 if( operand1. inf == -infinity || operand1. sup == infinity )
2070 resultant-> inf = 0.0;
2074 else if( operand2 >= 0.0 )
2077 if( operand1. inf == -infinity )
2078 resultant-> inf = -infinity;
2081 if( operand1. sup == infinity )
2082 resultant-> sup = infinity;
2091 resultant-> inf = -infinity;
2092 resultant-> sup = infinity;
2097 if( resultant-> inf > infinity )
2098 resultant-> inf = infinity;
2099 if( resultant-> sup < -infinity )
2100 resultant-> sup = -infinity;
2118 assert(resultant != NULL);
2119 assert(image. inf <= image. sup);
2120 assert(basedomain. inf <= basedomain. sup);
2122 if( exponent == 0.0 )
2125 if( image. inf <= 1.0 && image. sup >= 1.0 )
2128 *resultant = basedomain;
2130 else if( image. inf <= 0.0 && image. sup >= 0.0 )
2154 if( image. sup >= 0.0 )
2158 if( basedomain. inf <= -resultant-> inf && EPSISINT(exponent, 0.0) && ( int)exponent % 2 == 0 )
2160 if( basedomain. sup < resultant-> inf )
2172 if( image. inf < 0.0 && basedomain. inf < 0.0 && EPSISINT(exponent, 0.0) && (( int)exponent % 2 != 0) )
2196 assert(resultant != NULL);
2198 assert(operand1. inf <= operand1. sup);
2199 assert(operand2 >= 0.0);
2201 if( operand2 == infinity )
2207 if( operand1. inf < 0.0 )
2208 resultant-> inf = -infinity;
2210 resultant-> inf = 0.0;
2211 if( operand1. sup > 0.0 )
2212 resultant-> sup = infinity;
2214 resultant-> sup = 0.0;
2218 if( operand2 == 0.0 )
2221 if( operand1. inf < 0.0 )
2222 resultant-> inf = -1.0;
2223 else if( operand1. inf == 0.0 )
2224 resultant-> inf = 0.0;
2226 resultant-> inf = 1.0;
2228 if( operand1. sup < 0.0 )
2229 resultant-> sup = -1.0;
2230 else if( operand1. sup == 0.0 )
2231 resultant-> sup = 0.0;
2233 resultant-> sup = 1.0;
2238 if( operand2 == 1.0 )
2240 *resultant = operand1;
2246 if( operand2 == 2.0 )
2248 if( operand1. inf <= -infinity )
2250 resultant-> inf = -infinity;
2252 else if( operand1. inf >= infinity )
2254 resultant-> inf = infinity;
2256 else if( operand1. inf > 0.0 )
2259 resultant-> inf = operand1. inf * operand1. inf;
2268 if( operand1. sup >= infinity )
2270 resultant-> sup = infinity;
2272 else if( operand1. sup <= -infinity )
2274 resultant-> sup = -infinity;
2276 else if( operand1. sup > 0.0 )
2279 resultant-> sup = operand1. sup * operand1. sup;
2287 assert(resultant-> inf <= resultant-> sup);
2289 else if( operand2 == 0.5 )
2291 if( operand1. inf <= -infinity )
2292 resultant-> inf = -infinity;
2293 else if( operand1. inf >= infinity )
2294 resultant-> inf = infinity;
2295 else if( operand1. inf >= 0.0 )
2306 if( operand1. sup >= infinity )
2307 resultant-> sup = infinity;
2308 else if( operand1. sup <= -infinity )
2309 resultant-> sup = -infinity;
2310 else if( operand1. sup > 0.0 )
2320 assert(resultant-> inf <= resultant-> sup);
2324 if( operand1. inf <= -infinity )
2325 resultant-> inf = -infinity;
2326 else if( operand1. inf >= infinity )
2327 resultant-> inf = infinity;
2328 else if( operand1. inf > 0.0 )
2339 if( operand1. sup >= infinity )
2340 resultant-> sup = infinity;
2341 else if( operand1. sup <= -infinity )
2342 resultant-> sup = -infinity;
2343 else if( operand1. sup > 0.0 )
2368 assert(resultant != NULL);
2369 assert(operand. inf <= operand. sup);
2371 if( operand. inf == 0.0 && operand. sup == 0.0 )
2373 resultant-> inf = infinity;
2374 resultant-> sup = -infinity;
2380 if( operand. inf >= 0.0 )
2382 if( operand. sup >= infinity )
2383 resultant-> inf = 0.0;
2387 resultant-> inf = 1.0 / operand. sup;
2390 if( operand. inf >= infinity )
2391 resultant-> sup = 0.0;
2392 else if( operand. inf == 0.0 )
2393 resultant-> sup = infinity;
2397 resultant-> sup = 1.0 / operand. inf;
2402 else if( operand. sup <= 0.0 )
2404 if( operand. sup <= -infinity )
2405 resultant-> inf = 0.0;
2406 else if( operand. sup == 0.0 )
2407 resultant-> inf = -infinity;
2411 resultant-> inf = 1.0 / operand. sup;
2414 if( operand. inf <= -infinity )
2415 resultant-> sup = infinity;
2419 resultant-> sup = 1.0 / operand. inf;
2425 resultant-> inf = -infinity;
2426 resultant-> sup = infinity;
2439 assert(resultant != NULL);
2440 assert(operand. inf <= operand. sup);
2442 if( operand. sup <= -infinity )
2444 resultant-> inf = 0.0;
2445 resultant-> sup = 0.0;
2449 if( operand. inf >= infinity )
2451 resultant-> inf = infinity;
2452 resultant-> sup = infinity;
2456 if( operand. inf == operand. sup )
2458 if( operand. inf == 0.0 )
2460 resultant-> inf = 1.0;
2461 resultant-> sup = 1.0;
2476 if( operand. inf <= -infinity )
2478 resultant-> inf = 0.0;
2480 else if( operand. inf == 0.0 )
2482 resultant-> inf = 1.0;
2489 if( resultant-> inf >= infinity )
2490 resultant-> inf = infinity;
2493 if( operand. sup >= infinity )
2495 resultant-> sup = infinity;
2497 else if( operand. sup == 0.0 )
2499 resultant-> sup = 1.0;
2505 if( resultant-> sup < -infinity )
2506 resultant-> sup = -infinity;
2519 assert(resultant != NULL);
2520 assert(operand. inf <= operand. sup);
2522 if( operand. sup < 0.0 )
2528 if( operand. inf == operand. sup )
2530 if( operand. sup <= 0.0 )
2532 resultant-> inf = -infinity;
2533 resultant-> sup = -infinity;
2535 else if( operand. sup == 1.0 )
2537 resultant-> inf = 0.0;
2538 resultant-> sup = 0.0;
2553 if( operand. inf <= 0.0 )
2555 resultant-> inf = -infinity;
2557 else if( operand. inf == 1.0 )
2559 resultant-> inf = 0.0;
2567 if( operand. sup >= infinity )
2569 resultant-> sup = infinity;
2571 else if( operand. sup == 1.0 )
2573 resultant-> sup = 0.0;
2575 else if( operand. sup == 0.0 )
2577 resultant-> sup = -infinity;
2593 assert(resultant != NULL);
2594 assert(operand1. inf <= operand1. sup);
2595 assert(operand2. inf <= operand2. sup);
2608 assert(resultant != NULL);
2609 assert(operand1. inf <= operand1. sup);
2610 assert(operand2. inf <= operand2. sup);
2622 assert(resultant != NULL);
2623 assert(operand. inf <= operand. sup);
2625 if( operand. inf <= 0.0 && operand. sup >= 0.0)
2627 resultant-> inf = 0.0;
2630 else if( operand. inf > 0.0 )
2632 *resultant = operand;
2636 resultant-> inf = -operand. sup;
2637 resultant-> sup = -operand. inf;
2647 assert(resultant != NULL);
2648 assert(operand. inf <= operand. sup);
2650 if( operand. sup < 0.0 )
2652 resultant-> inf = -1.0;
2653 resultant-> sup = -1.0;
2655 else if( operand. inf >= 0.0 )
2657 resultant-> inf = 1.0;
2658 resultant-> sup = 1.0;
2662 resultant-> inf = -1.0;
2663 resultant-> sup = 1.0;
2681 assert(b_. inf < infinity);
2682 assert(b_. sup > -infinity);
2683 assert( x. inf < infinity);
2684 assert( x. sup > -infinity);
2689 if( (b_. inf <= -infinity && x. inf < 0.0 ) ||
2690 ( b_. inf < 0.0 && x. inf <= -infinity) ||
2691 ( b_. sup > 0.0 && x. sup >= infinity) ||
2692 ( b_. sup >= infinity && x. sup > 0.0 ) )
2707 u = MAX( MAX(cand1, cand2), MAX(cand3, cand4));
2752 assert(x. inf < 0.0 && x. sup > 0);
2758 return MAX(cand1, cand2);
2780 if( sqrcoeff == 0.0 )
2789 lincoeff. inf = -lincoeff. sup;
2790 lincoeff. sup = -tmp;
2793 assert(resultant-> sup >= resultant-> inf);
2808 assert(resultant != NULL);
2811 if( lincoeff. inf <= -infinity || rhs. sup >= infinity || sqrcoeff. inf <= -infinity )
2813 resultant-> inf = 0.0;
2814 resultant-> sup = infinity;
2823 if( lincoeff. sup < infinity && rhs. inf > -infinity && sqrcoeff. sup < infinity )
2835 if( resultant-> inf >= infinity || resultant-> sup <= -infinity )
2859 assert(resultant != NULL);
2860 assert(sqrcoeff < infinity);
2861 assert(sqrcoeff > -infinity);
2863 resultant-> inf = 0.0;
2864 resultant-> sup = infinity;
2871 if( lincoeff >= 0.0 )
2876 delta = b*b + sqrcoeff*rhs;
2877 if( delta < 0.0 || (sqrcoeff == 0.0 && lincoeff == 0.0) )
2888 if( sqrcoeff < 0.0 )
2894 if( sqrcoeff < 0.0 )
2896 delta = b*b + sqrcoeff*rhs;
2909 if( sqrcoeff > 0.0 )
2912 delta = b*b + sqrcoeff*rhs;
2917 resultant-> inf = z / sqrcoeff;
2927 delta = b*b + sqrcoeff * rhs;
2928 if( delta >= 0.0 && sqrcoeff <= 0.0 )
2959 assert(resultant != NULL);
2961 if( sqrcoeff. inf == 0.0 && sqrcoeff. sup == 0.0 )
2963 if( lincoeff. inf == 0.0 && lincoeff. sup == 0.0 )
2965 if( rhs. inf <= 0.0 && rhs. sup >= 0.0 )
2976 if( lincoeff. inf == 0.0 && lincoeff. sup == 0.0 )
2980 resultant-> inf = -resultant-> sup;
2986 SCIPdebugMessage( " positive solutions of [%g,%g]*x^2 + [%g,%g]*x in [%g,%g] are [%g,%g]\n",
2990 lincoeff. inf = -lincoeff. sup;
2991 lincoeff. sup = -tmp;
2998 SCIPdebugMessage( " negative solutions of [%g,%g]*x^2 + [%g,%g]*x in [%g,%g] are [%g,%g]\n",
3029 assert(resultant != NULL);
3030 assert(xbnds. inf <= xbnds. sup);
3031 assert(ybnds. inf <= ybnds. sup);
3055 denom = 4.0 * ax * ay - axy * axy;
3058 x = (axy * by - 2.0 * ay * bx) / denom;
3059 y = (axy * bx - 2.0 * ax * by) / denom;
3060 if( xbnds. inf <= x && x <= xbnds. sup && ybnds. inf <= y && y <= ybnds. sup )
3062 val = (axy * bx * by - ay * bx * bx - ax * by * by) / denom;
3063 minval = MIN(val, minval);
3064 maxval = MAX(val, maxval);
3067 else if( REALABS(2.0 * ay * bx - axy * by) <= 1e-9 )
3073 if( xbnds. inf <= -infinity && xbnds. sup >= infinity )
3075 val = -ay * bx * bx / (axy * axy);
3076 minval = MIN(val, minval);
3077 maxval = MAX(val, maxval);
3083 if( xbnds. inf <= -infinity )
3090 else if( ax == 0.0 )
3094 if( ybnds. inf <= -infinity )
3095 val = (axy < 0.0 ? -infinity : infinity);
3096 else if( bx + axy * ybnds. inf < 0.0 )
3100 minval = MIN(val, minval);
3101 maxval = MAX(val, maxval);
3103 if( ybnds. sup >= infinity )
3104 val = (axy < 0.0 ? infinity : -infinity);
3105 else if( bx + axy * ybnds. sup < 0.0 )
3109 minval = MIN(val, minval);
3110 maxval = MAX(val, maxval);
3122 minval = MIN(tmp. inf, minval);
3123 maxval = MAX(tmp. sup, maxval);
3126 if( xbnds. sup >= infinity )
3133 else if( ax == 0.0 )
3137 if( ybnds. inf <= -infinity )
3138 val = (axy > 0.0 ? -infinity : infinity);
3139 else if( bx + axy * ybnds. inf > 0.0 )
3143 minval = MIN(val, minval);
3144 maxval = MAX(val, maxval);
3146 if( ybnds. sup >= infinity )
3147 val = (axy > 0.0 ? infinity : -infinity);
3148 else if( bx + axy * ybnds. sup > 0.0 )
3152 minval = MIN(val, minval);
3153 maxval = MAX(val, maxval);
3165 minval = MIN(tmp. inf, minval);
3166 maxval = MAX(tmp. sup, maxval);
3169 if( ybnds. inf <= -infinity )
3176 else if( ay == 0.0 )
3180 if( xbnds. inf <= -infinity )
3181 val = (axy < 0.0 ? -infinity : infinity);
3182 else if( by + axy * xbnds. inf < 0.0 )
3186 minval = MIN(val, minval);
3187 maxval = MAX(val, maxval);
3189 if( xbnds. sup >= infinity )
3190 val = (axy < 0.0 ? infinity : -infinity);
3191 else if( by + axy * xbnds. sup < 0.0 )
3195 minval = MIN(val, minval);
3196 maxval = MAX(val, maxval);
3208 minval = MIN(tmp. inf, minval);
3209 maxval = MAX(tmp. sup, maxval);
3212 if( ybnds. sup >= infinity )
3219 else if( ay == 0.0 )
3223 if( xbnds. inf <= -infinity )
3224 val = (axy > 0.0 ? -infinity : infinity);
3225 else if( by + axy * xbnds. inf > 0.0 )
3229 minval = MIN(val, minval);
3230 maxval = MAX(val, maxval);
3232 if( xbnds. sup >= infinity )
3233 val = (axy > 0.0 ? infinity : -infinity);
3234 else if( by + axy * xbnds. sup > 0.0 )
3238 minval = MIN(val, minval);
3239 maxval = MAX(val, maxval);
3251 minval = MIN(tmp. inf, minval);
3252 maxval = MAX(tmp. sup, maxval);
3255 minval -= 1e-10 * REALABS(minval);
3256 maxval += 1e-10 * REALABS(maxval);
3259 SCIPdebugMessage( "range for %gx^2 + %gy^2 + %gxy + %gx + %gy = [%g, %g] for x = [%g, %g], y=[%g, %g]\n",
3260 ax, ay, axy, bx, by, minval, maxval, xbnds. inf, xbnds. sup, ybnds. inf, ybnds. sup);
3284 assert(resultant != NULL);
3302 if( xbnds. sup >= 0.0 )
3312 if( xbnds. inf < 0.0 )
3363 rcoef_y = axy * bx / (2.0*ax) - by;
3364 rcoef_yy = axy * axy / (4.0*ax) - ay;
3365 rcoef_const = bx * bx / (4.0*ax);
3367 #define CALCB(y) ((bx + axy * (y)) / (2.0 * sqrtax))
3368 #define CALCR(c,y) (rcoef_const + (c) + (rcoef_y + rcoef_yy * (y)) * (y))
3371 if( rhs. sup < infinity )
3379 if( EPSN(ub, 1e-9) )
3393 minvalleft = infinity;
3394 maxvalleft = -infinity;
3395 minvalright = infinity;
3396 maxvalright = -infinity;
3398 if( rhs. sup >= infinity )
3402 minvalleft = -infinity;
3403 maxvalright = infinity;
3407 if( ybnds. inf <= -infinity )
3410 if( ! EPSZ(ay, 1e-9) && axy * axy >= 4.0 * ax * ay )
3412 if( axy < 0.0 || ay < 0.0 )
3413 minvalleft = -infinity;
3415 if( axy < 0.0 && ay > 0.0 )
3416 maxvalleft = infinity;
3418 if( axy > 0.0 && ay > 0.0 )
3419 minvalleft = -infinity;
3421 if( axy > 0.0 || ay < 0.0 )
3422 maxvalright = infinity;
3424 else if( ! EPSZ(ay, 1e-9) )
3431 minvalleft = -by / 2.0;
3432 maxvalleft = -by / 2.0;
3434 maxvalright = infinity;
3444 if( rhs. sup < infinity )
3453 minvalleft = MIN(-sqrtc - b, minvalleft);
3454 maxvalright = MAX( sqrtc - b, maxvalright);
3458 if( rhs. inf > -infinity )
3467 maxvalleft = MAX(-sqrtc - b, maxvalleft);
3468 minvalright = MIN( sqrtc - b, minvalright);
3474 if( ybnds. sup >= infinity )
3477 if( ! EPSZ(ay, 1e-9) && axy * axy >= 4.0 * ax * ay )
3479 if( axy > 0.0 || ay < 0.0 )
3480 minvalleft = -infinity;
3482 if( axy < 0.0 && ay > 0.0 )
3483 maxvalleft = infinity;
3485 if( axy > 0.0 && ay > 0.0 )
3486 minvalright = -infinity;
3488 if( axy < 0.0 || ay < 0.0 )
3489 maxvalright = infinity;
3491 else if( ! EPSZ(ay, 1e-9) )
3498 minvalleft = -infinity;
3500 minvalright = MIN(minvalright, -by / 2.0);
3501 maxvalright = MAX(maxvalright, -by / 2.0);
3511 if( rhs. sup < infinity )
3520 minvalleft = MIN(-sqrtc - b, minvalleft);
3521 maxvalright = MAX( sqrtc - b, maxvalright);
3525 if( rhs. inf > -infinity )
3534 maxvalleft = MAX(-sqrtc - b, maxvalleft);
3535 minvalright = MIN( sqrtc - b, minvalright);
3542 if( ! EPSZ(ay, 1e-9) )
3544 if( REALABS(axy*axy - 4.0*ax*ay) > 1e-9 )
3548 if( rhs. sup < infinity )
3550 sqrtterm = axy * axy * ay * (ay * bx * bx - axy * bx * by + ax * by * by - axy * axy * rhs. sup + 4.0 * ax * ay * rhs. sup);
3551 if( ! EPSN(sqrtterm, 1e-9) )
3553 sqrtterm = sqrt( MAX(sqrtterm, 0.0));
3555 ymin = axy * ay * bx - 2.0 * ax * ay * by - sqrtterm;
3557 ymin /= 4.0 * ax * ay - axy * axy;
3559 if( ymin > ybnds. inf && ymin < ybnds. sup )
3572 minvalleft = MIN(-sqrtc - b, minvalleft);
3573 maxvalright = MAX( sqrtc - b, maxvalright);
3578 ymin = axy * ay * bx - 2.0 * ax * ay * by + sqrtterm;
3580 ymin /= 4.0 * ax * ay - axy * axy;
3582 if( ymin > ybnds. inf && ymin < ybnds. sup )
3595 minvalleft = MIN(-sqrtc - b, minvalleft);
3596 maxvalright = MAX( sqrtc - b, maxvalright);
3602 if( rhs. inf > -infinity )
3604 sqrtterm = axy * axy * ay * (ay * bx * bx - axy * bx * by + ax * by * by - axy * axy * rhs. inf + 4.0 * ax * ay * rhs. inf);
3605 if( ! EPSN(sqrtterm, 1e-9) )
3607 sqrtterm = sqrt( MAX(sqrtterm, 0.0));
3609 ymin = axy * ay * bx - 2.0 * ax * ay * by - sqrtterm;
3611 ymin /= 4.0 * ax * ay - axy * axy;
3613 if( ymin > ybnds. inf && ymin < ybnds. sup )
3626 maxvalleft = MAX(-sqrtc - b, maxvalleft);
3627 minvalright = MIN( sqrtc - b, minvalright);
3632 ymin = axy * ay * bx - 2.0 * ax * ay * by + sqrtterm;
3634 ymin /= 4.0 * ax * ay - axy * axy;
3636 if( ymin > ybnds. inf && ymin < ybnds. sup )
3649 maxvalleft = MAX(-sqrtc - b, maxvalleft);
3650 minvalright = MIN( sqrtc - b, minvalright);
3657 else if( REALABS(2.0 * ay * bx - axy * by) > 1e-9 )
3659 if( rhs. sup < infinity )
3661 ymin = - (4.0 * ay * bx * by - axy * by * by + 4.0 * axy * ay * rhs. sup);
3663 ymin /= 2.0 * ay * bx - axy * by;
3665 if( ymin > ybnds. inf && ymin < ybnds. sup )
3678 minvalleft = MIN(-sqrtc - b, minvalleft);
3679 maxvalright = MAX( sqrtc - b, maxvalright);
3684 if( rhs. inf > -infinity )
3686 ymin = - (4.0 * ay * bx * by - axy * by * by + 4.0 * axy * ay * rhs. inf);
3688 ymin /= 2.0 * ay * bx - axy * by;
3690 if( ymin > ybnds. inf && ymin < ybnds. sup )
3703 maxvalleft = MAX(-sqrtc - b, maxvalleft);
3704 minvalright = MIN( sqrtc - b, minvalright);
3734 if( ybnds. sup > 0.0 )
3742 assert(ypos. inf >= 0.0);
3744 minvalleft = MIN(minvalleft, -b);
3745 maxvalleft = MAX(maxvalleft, -b);
3746 minvalright = MIN(minvalright, -b);
3747 maxvalright = MAX(maxvalright, -b);
3749 if( ypos. sup < infinity )
3752 minvalleft = MIN(minvalleft, -b);
3753 maxvalleft = MAX(maxvalleft, -b);
3754 minvalright = MIN(minvalright, -b);
3755 maxvalright = MAX(maxvalright, -b);
3762 minvalleft = -infinity;
3763 minvalright = -infinity;
3767 maxvalleft = infinity;
3768 maxvalright = infinity;
3776 if( ybnds. inf < 0.0 )
3790 if( yneg. inf > -infinity )
3793 minvalleft = MIN(minvalleft, -b);
3794 maxvalleft = MAX(maxvalleft, -b);
3795 minvalright = MIN(minvalright, -b);
3796 maxvalright = MAX(maxvalright, -b);
3803 maxvalleft = infinity;
3804 maxvalright = infinity;
3808 minvalleft = -infinity;
3809 minvalright = -infinity;
3813 assert(yneg. sup <= 0.0);
3815 minvalleft = MIN(minvalleft, -b);
3816 maxvalleft = MAX(maxvalleft, -b);
3817 minvalright = MIN(minvalright, -b);
3818 maxvalright = MAX(maxvalright, -b);
3823 if( rhs. inf > -infinity && xbnds. inf > -infinity && EPSGT(xbnds. inf, maxvalleft / sqrtax, 1e-9) )
3827 assert( EPSGE(minvalright, minvalleft, 1e-9));
3828 if( minvalright > -infinity )
3834 if( minvalleft > -infinity )
3838 if( rhs. inf > -infinity && xbnds. sup < infinity && EPSLT(xbnds. sup, minvalright / sqrtax, 1e-9) )
3842 assert( EPSLE(maxvalleft, maxvalright, 1e-9));
3843 if( maxvalleft < infinity )
3849 if( maxvalright < infinity )
3870 if( EPSGE(-bx / axy, ybnds. inf, 1e-9) && EPSLE(-bx / axy, ybnds. sup, 1e-9) )
3880 if( xbnds. inf < 0.0 && xbnds. sup > 0.0 )
3898 if( lincoef. inf == 0.0 && lincoef. sup == 0.0 )
3901 if( myrhs. inf <= 0.0 && myrhs. sup >= 0.0 )
3906 else if( xbnds. inf >= 0.0 )
3918 assert(xbnds. sup <= 0.0);
3937 if( bx + axy * (axy > 0.0 ? ybnds. inf : ybnds. sup) > 0.0 )
3942 if( c > -infinity && c < infinity )
3944 if( ybnds. inf <= -infinity )
3947 if( EPSZ(ay, 1e-9) )
3949 else if( ay * axy < 0.0 )
3954 val = (c - ay * ybnds. inf * ybnds. inf - by * ybnds. inf) / (bx + axy * ybnds. inf);
3955 minval = MIN(val, minval);
3958 if( ybnds. sup >= infinity )
3961 if( EPSZ(ay, 1e-9) )
3962 minval = MIN(minval, -by / axy);
3963 else if( ay * axy > 0.0 )
3968 val = (c - ay * ybnds. sup * ybnds. sup - by * ybnds. sup) / (bx + axy * ybnds. sup);
3969 minval = MIN(val, minval);
3972 if( ! EPSZ(ay, 1e-9) )
3974 d = ay * (ay * bx * bx - axy * (bx * by + axy * c));
3975 if( ! EPSN(d, 1e-9) )
3977 ymin = -ay * bx + sqrt( MAX(d, 0.0));
3980 val = (c - ay * ymin * ymin - by * ymin) / (bx + axy * ymin);
3981 minval = MIN(val, minval);
3983 ymin = -ay * bx - sqrt( MAX(d, 0.0));
3986 val = (c - ay * ymin * ymin - by * ymin) / (bx + axy * ymin);
3987 minval = MIN(val, minval);
3997 if( bx + axy * (axy > 0.0 ? ybnds. inf : ybnds. sup) > 0.0 )
4002 if( c > -infinity && c < infinity )
4004 if( ybnds. inf <= -infinity )
4007 if( EPSZ(ay, 1e-9) )
4009 else if( ay * axy > 0.0 )
4014 val = (c - ay * ybnds. inf * ybnds. inf - by * ybnds. inf) / (bx + axy * ybnds. inf);
4015 maxval = MAX(val, maxval);
4018 if( ybnds. sup >= infinity )
4021 if( EPSZ(ay, 1e-9) )
4022 maxval = MAX(maxval, -by / axy);
4023 else if( ay * axy < 0.0 )
4028 val = (c - ay * ybnds. sup * ybnds. sup - by * ybnds. sup) / (bx + axy * ybnds. sup);
4029 maxval = MAX(val, maxval);
4032 if( ! EPSZ(ay, 1e-9) )
4034 d = ay * (ay * bx * bx - axy * (bx * by + axy * c));
4035 if( ! EPSN(d, 1e-9) )
4037 ymin = ay * bx + sqrt( MAX(d, 0.0));
4040 val = (c - ay * ymin * ymin - by * ymin) / (bx + axy * ymin);
4041 maxval = MAX(val, maxval);
4043 ymin = ay * bx - sqrt( MAX(d, 0.0));
4046 val = (c - ay * ymin * ymin - by * ymin) / (bx + axy * ymin);
4047 maxval = MAX(val, maxval);
4056 if( minval > -infinity )
4057 resultant-> inf = minval - 1e-10 * REALABS(minval);
4059 resultant-> inf = -infinity;
4060 if( maxval < infinity )
4061 resultant-> sup = maxval + 1e-10 * REALABS(maxval);
4063 resultant-> sup = infinity;
|