18 for (i
= 0; i
< p
->u
.tensor
->nelem
; i
++)
19 if (!iszero(p
->u
.tensor
->elem
[i
]))
29 isnegativenumber(U
*p
)
33 if (MSIGN(p
->u
.q
.a
) == -1)
51 if (MEQUAL(p
->u
.q
.a
, 1) && MEQUAL(p
->u
.q
.b
, 1))
69 if (MEQUAL(p
->u
.q
.a
, -1) && MEQUAL(p
->u
.q
.b
, 1))
85 if (p
->k
== NUM
&& MEQUAL(p
->u
.q
.b
, 1))
92 isnonnegativeinteger(U
*p
)
94 if (isrational(p
) && MEQUAL(p
->u
.q
.b
, 1) && MSIGN(p
->u
.q
.a
) == 1)
103 if (isinteger(p
) && MSIGN(p
->u
.q
.a
) == 1)
113 return ispoly_expr(p
, x
);
119 ispoly_expr(U
*p
, U
*x
)
121 if (car(p
) == symbol(ADD
)) {
124 if (!ispoly_term(car(p
), x
))
130 return ispoly_term(p
, x
);
134 ispoly_term(U
*p
, U
*x
)
136 if (car(p
) == symbol(MULTIPLY
)) {
139 if (!ispoly_factor(car(p
), x
))
145 return ispoly_factor(p
, x
);
149 ispoly_factor(U
*p
, U
*x
)
153 if (car(p
) == symbol(POWER
) && equal(cadr(p
), x
)) {
154 if (isposint(caddr(p
)))
168 if (isnegativenumber(p
))
170 else if (car(p
) == symbol(MULTIPLY
) && isnegativenumber(cadr(p
)))
177 isimaginarynumber(U
*p
)
179 if ((car(p
) == symbol(MULTIPLY
)
182 && equal(caddr(p
), imaginaryunit
))
183 || equal(p
, imaginaryunit
))
191 iscomplexnumber(U
*p
)
193 if ((car(p
) == symbol(ADD
)
196 && isimaginarynumber(caddr(p
)))
197 || isimaginarynumber(p
))
206 if (isinteger(p
) && (p
->u
.q
.a
[0] & 1) == 0)
215 if (car(p
) == symbol(ADD
) && isnegativeterm(cadr(p
)))
217 else if (isnegativeterm(p
))
223 // returns 1 if there's a symbol somewhere
232 if (issymbolic(car(p
)))
243 isintegerfactor(U
*p
)
245 if (isinteger(p
) || car(p
) == symbol(POWER
)
246 && isinteger(cadr(p
))
247 && isinteger(caddr(p
)))
256 if (car(p
) == symbol(POWER
)
257 && isminusone(caddr(p
)))
266 if (p
->k
== NUM
&& !MEQUAL(p
->u
.q
.b
, 1))
277 if (MEQUAL(p
->u
.q
.a
, n
) && MEQUAL(p
->u
.q
.b
, 1))
281 if (p
->u
.d
== (double) n
)
291 equalq(U
*p
, int a
, int b
)
295 if (MEQUAL(p
->u
.q
.a
, a
) && MEQUAL(p
->u
.q
.b
, b
))
299 if (p
->u
.d
== (double) a
/ b
)
311 isoneoversqrttwo(U
*p
)
313 if (car(p
) == symbol(POWER
)
314 && equaln(cadr(p
), 2)
315 && equalq(caddr(p
), -1, 2))
324 isminusoneoversqrttwo(U
*p
)
326 if (car(p
) == symbol(MULTIPLY
)
327 && equaln(cadr(p
), -1)
328 && isoneoversqrttwo(caddr(p
))
341 if (isfloating(car(p
)))
349 isimaginaryunit(U
*p
)
351 if (equal(p
, imaginaryunit
))
374 int n
, minussign
= 0;
376 if (car(p
) != symbol(MULTIPLY
))
379 if (equal(cadr(p
), imaginaryunit
)) {
381 if (caddr(p
) != symbol(PI
))
393 if (!equal(caddr(p
), imaginaryunit
))
396 if (cadddr(p
) != symbol(PI
))
408 if (n
== (int) 0x80000000)
440 // special multiple of pi?
442 // returns for the following multiples of pi...
444 // -4/2 -3/2 -2/2 -1/2 1/2 2/2 3/2 4/2
454 if (car(p
) == symbol(MULTIPLY
)
456 && caddr(p
) == symbol(PI
)
465 if (n
== (int) 0x80000000)