version 1.83, 2005/10/26 10:44:50 |
version 1.86, 2005/10/26 23:43:23 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.82 2005/10/26 08:39:58 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.85 2005/10/26 11:07:50 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 127 struct ftab str_tab[] = { |
|
Line 127 struct ftab str_tab[] = { |
|
{"quote_is_dependent",Pquote_is_dependent,2}, |
{"quote_is_dependent",Pquote_is_dependent,2}, |
|
|
{"quote_normalize",Pquote_normalize,-2}, |
{"quote_normalize",Pquote_normalize,-2}, |
{"quote_normalize_comp",Pquote_normalize_comp,2,0x3}, |
{"quote_normalize_comp",Pquote_normalize_comp,2}, |
|
|
{"quote_to_nary",Pquote_to_nary,1}, |
{"quote_to_nary",Pquote_to_nary,1}, |
{"quote_to_bin",Pquote_to_bin,2}, |
{"quote_to_bin",Pquote_to_bin,2}, |
Line 2488 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2488 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
FNODE b1,b2,e1,e2,g; |
FNODE b1,b2,e1,e2,g; |
Num ee,ee1,c1,c2; |
Num ee,ee1,c1,c2; |
|
|
if ( IS_ZERO(f1) ) |
|
if ( IS_ZERO(f2) ) return 0; |
|
else return -1; |
|
else if ( IS_ZERO(f2) ) return 1; |
|
|
|
if ( IS_NARYADD(f1) || IS_NARYADD(f2) ) { |
if ( IS_NARYADD(f1) || IS_NARYADD(f2) ) { |
f1 = to_naryadd(f1); f2 = to_naryadd(f2); |
f1 = to_naryadd(f1); f2 = to_naryadd(f2); |
n1 = (NODE)FA1(f1); n2 = (NODE)FA1(f2); |
n1 = (NODE)FA1(f1); n2 = (NODE)FA1(f2); |
Line 2501 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2496 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
else { |
else { |
n1 = NEXT(n1); n2 = NEXT(n2); |
n1 = NEXT(n1); n2 = NEXT(n2); |
} |
} |
if ( n1 ) return 1; |
return n1?1:(n2?-1:0); |
else if ( n2 ) return -1; |
|
else return 0; |
|
} |
} |
if ( IS_NARYMUL(f1) || IS_NARYMUL(f2) ) { |
if ( IS_NARYMUL(f1) || IS_NARYMUL(f2) ) { |
fnode_coef_body(f1,&c1,&b1); |
fnode_coef_body(f1,&c1,&b1); |
Line 2516 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2509 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
n1 = NEXT(n1); n2 = NEXT(n2); |
n1 = NEXT(n1); n2 = NEXT(n2); |
} |
} |
if ( !n1 || !n2 ) { |
if ( !n1 || !n2 ) { |
if ( n1 ) return 1; |
return n1?1:(n2?-1:0); |
else if ( n2 ) return -1; |
|
else return 0; |
|
} |
} |
fnode_base_exp(BDY(n1),&b1,&e1); |
fnode_base_exp(BDY(n1),&b1,&e1); |
fnode_base_exp(BDY(n2),&b2,&e2); |
fnode_base_exp(BDY(n2),&b2,&e2); |
Line 2535 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2526 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
subnum(0,eval(e1),eval(e2),&ee); |
subnum(0,eval(e1),eval(e2),&ee); |
r = compnum(0,ee,0); |
r = compnum(0,ee,0); |
if ( r > 0 ) { |
if ( r > 0 ) { |
/* e1>e2 */ |
|
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
MKNODE(n1,g,n1); |
MKNODE(n1,g,n1); |
} else if ( r < 0 ) { |
} else if ( r < 0 ) { |
/* e1<e2 */ |
chsgnnum(ee,&ee1); |
chsgnnum(ee,&ee1); ee = ee1; |
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee1)); |
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
MKNODE(n2,g,n2); |
MKNODE(n2,g,n2); |
|
} |
} |
} else { |
} else { |
r = fnode_normalize_comp(e1,e2); |
r = fnode_normalize_comp(e1,e2); |
Line 2584 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2573 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
else { |
else { |
n1 = NEXT(n1); n2 = NEXT(n2); |
n1 = NEXT(n1); n2 = NEXT(n2); |
} |
} |
if ( n1 ) return 1; |
return n1?1:(n2?-1:0); |
else if ( n2 ) return -1; |
|
else return 0; |
|
} |
} |
break; |
break; |
case I_PVAR: |
case I_PVAR: |