63 number lo = fun(
lower,
R->cf, r->cf),
64 up = fun(
upper,
R->cf, r->cf);
85 if (intervals !=
NULL)
87 for (i = 0; i < n; i++)
100 if (intervals !=
NULL)
102 for (i = 0; i < n; i++)
113 for (i = 0; i < n; i++)
117 omFree((
void**) intervals);
124 if (0 <= i && i < R->
N)
210 n1 = (number) args->
CopyD();
214 WerrorS(
"Input not supported: first argument not int or number");
239 WerrorS(
"Input not supported: second argument not int or number");
260 result->
data = (
void*) RES;
278 WerrorS(
"syntax: length(<interval>)");
314 int i, imax = 0, imin = 0;
315 for (i = 1; i < 4; i++)
327 lo =
n_Copy(nums[imin], I->
R->cf);
328 up =
n_Copy(nums[imax], I->
R->cf);
331 for (i = 0; i < 4; i++)
452 WerrorS(
"syntax: <interval> + <interval>");
460 WerrorS(
"adding intervals defined in different rings not supported");
471 WerrorS(
"syntax: <interval> - <interval>");
479 WerrorS(
"subtracting intervals defined in different rings not supported");
488 if (i1->
Typ() == i2->
Typ())
496 WerrorS(
"multiplying intervals defined in different rings not supported");
506 leftv iscalar, iinterv;
521 switch (iscalar->
Typ())
524 { n =
nInit((
int)(
long) iscalar->
Data());
break; }
526 { n = (number) iscalar->
CopyD();
break; }
528 {
WerrorS(
"first argument not int/number/interval");
return TRUE; }
550 WerrorS(
"second interval contains zero");
566 WerrorS(
"dividing intervals from different rings not supported");
590 WerrorS(
"first argument not int/number/interval");
610 { n =
nInit((
int)(
long) i2->
Data());
break; }
612 { n =
nCopy((number) i2->
Data());
break; }
615 WerrorS(
"second argument not int/number/interval");
622 WerrorS(
"<interval>/0 not supported");
640 WerrorS(
"syntax: <interval> ^ <int>");
643 int p = (int)(
long) i2->
Data();
646 WerrorS(
"<interval> ^ n not implemented for n < 0");
658 WerrorS(
"syntax: <interval> == <interval>");
675 WerrorS(
"syntax: <interval>[<int>]");
680 int n = (int)(
long) i2->
Data();
693 WerrorS(
"Allowed indices are 1 and 2");
700 number r = (number) result->
Data();
705 result->
data = (
void*) out;
724 result->
data = (
void*) RES;
738 memset(&l, 0,
sizeof(l));
739 memset(&lo, 0,
sizeof(lo));
740 memset(&up, 0,
sizeof(up));
743 l.
data = (
void*)
"interval";
755 f->m->SetRing(f, R,
TRUE);
771 l->
next = f->m->Read(f);
773 number lo = (number) l->
CopyD(),
788 return (
void*)
new box();
793 return (
void*)
new box((
box*) d);
815 for (i = 1; i < n; i++)
850 int M = m > (n-1) ? (n-1) :
m;
852 for (i = 0; i <=
M; i++)
856 WerrorS(
"list contains non-intervals");
870 WerrorS(
"Input not supported: first argument not box, list, or interval");
887 result->
data = (
void*) RES;
898 Werror(
"first argument is not box but type(%d), second is type(%d)",
913 WerrorS(
"second argument not int");
921 int i = (int)(
long) b2->
Data();
925 WerrorS(
"index out of bounds");
945 WerrorS(
"second argument not box");
954 WerrorS(
"subtracting boxes from different rings not supported");
959 for (i = 0; i < n; i++)
970 result->
data = (
void*) RES;
979 WerrorS(
"second argument not box");
984 for (i = 0; i < n; i++)
994 result->
data = (
void*) res;
1013 WerrorS(
"can only intersect boxes");
1018 number lowerb[n], upperb[n];
1021 for (i = 0; i < n; i++)
1032 WerrorS(
"can only intersect boxes");
1037 for (i = 0; i < n; i++)
1048 if (
nGreater(lowerb[i], upperb[i]))
1051 result->
data = (
void*) (-1);
1061 for (i = 0; i < n; i++)
1067 result->
data = (
void*) RES;
1084 memset(&l, 0,
sizeof(l));
1085 memset(&iv, 0,
sizeof(iv));
1088 l.
data = (
void*)
"box";
1091 f->m->SetRing(f, B->
R,
TRUE);
1094 for (
i = 0;
i <
N;
i++)
1097 f->m->Write(f, &iv);
1120 for (i = 1; i <
N; i++)
1146 WerrorS(
"boxSet: index out of range");
1157 result->
data = (
void*) RES;
1174 poly
p = (poly) args->
Data();
1176 int i, pot, n = B->
R->N;
1184 for (i = 1; i <= n; i++)
1216 result->
data = (
void*) RES;
1227 blackbox *b_iv = (blackbox*)
omAlloc0(
sizeof(blackbox)),
1228 *b_bx = (blackbox*)
omAlloc0(
sizeof(blackbox));
1254 psModulFunctions->iiAddCproc(
"rootisolation.lib",
"length",
FALSE,
length);
1255 psModulFunctions->iiAddCproc(
"rootisolation.lib",
"boxSet",
FALSE,
boxSet);
1256 psModulFunctions->iiAddCproc(
"rootisolation.lib",
"evalPolyAtBox",
FALSE,
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
box & setInterval(int, interval *)
static bool intervalContainsZero(interval *I)
static FORCE_INLINE BOOLEAN n_Greater(number a, number b, const coeffs r)
ordered fields: TRUE iff 'a' is larger than 'b'; in Z/pZ: TRUE iff la > lb, where la and lb are the l...
static BOOLEAN interval_serialize(blackbox *, void *d, si_link f)
Class used for (list of) interpreter objects.
static BOOLEAN evalPolyAtBox(leftv result, leftv args)
interval(const ring r=currRing)
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
static void interval_Destroy(blackbox *, void *d)
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
void WerrorS(const char *s)
BOOLEAN blackboxDefaultOp2(int, leftv, leftv, leftv)
default procedure blackboxDefaultOp2, to be called as "default:" branch
static interval * intervalScalarMultiply(number a, interval *I)
static BOOLEAN box_Op2(int op, leftv result, leftv b1, leftv b2)
static char * interval_String(blackbox *, void *d)
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
#define pGetExp(p, i)
Exponent.
const CanonicalForm CFMap CFMap & N
static interval * intervalSubtract(interval *I, interval *J)
static BOOLEAN box_deserialize(blackbox **, void **d, si_link f)
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
void StringSetS(const char *st)
static BOOLEAN boxSet(leftv result, leftv args)
void StringAppendS(const char *st)
static BOOLEAN box_Assign(leftv result, leftv args)
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
static char * box_String(blackbox *, void *d)
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of 'a'; raise an error if 'a' is not invertible ...
static void * interval_Copy(blackbox *, void *d)
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
static void * interval_Init(blackbox *)
static void * box_Init(blackbox *)
static FORCE_INLINE void n_Power(number a, int b, number *res, const coeffs r)
fill res with the power a^b
static BOOLEAN box_OpM(int op, leftv result, leftv args)
static bool intervalEqual(interval *I, interval *J)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
static interval * intervalPower(interval *I, int p)
BOOLEAN iiCheckTypes(leftv args, const short *type_list, int report)
check a list of arguemys against a given field of types return TRUE if the types match return FALSE (...
static void box_Destroy(blackbox *, void *d)
static interval * intervalMultiply(interval *I, interval *J)
static BOOLEAN length(leftv result, leftv arg)
BOOLEAN blackboxDefaultOpM(int op, leftv res, leftv args)
default procedure blackboxDefaultOpM, to be called as "default:" branch
static BOOLEAN box_serialize(blackbox *, void *d, si_link f)
void CleanUp(ring r=currRing)
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
static BOOLEAN interval_Assign(leftv result, leftv args)
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
static FORCE_INLINE BOOLEAN n_GreaterZero(number n, const coeffs r)
ordered fields: TRUE iff 'n' is positive; in Z/pZ: TRUE iff 0 < m <= roundedBelow(p/2), where m is the long representing n in C: TRUE iff (Im(n) != 0 and Im(n) >= 0) or (Im(n) == 0 and Re(n) >= 0) in K(a)/<p(a)>: TRUE iff (n != 0 and (LC(n) > 0 or deg(n) > 0)) in K(t_1, ..., t_n): TRUE iff (LC(numerator(n) is a constant and > 0) or (LC(numerator(n) is not a constant) in Z/2^kZ: TRUE iff 0 < n <= 2^(k-1) in Z/mZ: TRUE iff the internal mpz is greater than zero in Z: TRUE iff n > 0
static BOOLEAN interval_Op2(int op, leftv result, leftv i1, leftv i2)
int setBlackboxStuff(blackbox *bb, const char *n)
define a new type
static void * box_Copy(blackbox *, void *d)
void Werror(const char *fmt,...)
blackbox * getBlackboxStuff(const int t)
return the structure to the type given by t
static BOOLEAN interval_deserialize(blackbox **, void **d, si_link f)
static interval * intervalAdd(interval *I, interval *J)