version 1.82, 2005/10/26 08:39:58 |
version 1.83, 2005/10/26 10:44:50 |
|
|
* 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.81 2005/10/26 07:33:03 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.82 2005/10/26 08:39:58 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 2486 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2486 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
int r,i1,i2; |
int r,i1,i2; |
char *nm1,*nm2; |
char *nm1,*nm2; |
FNODE b1,b2,e1,e2,g; |
FNODE b1,b2,e1,e2,g; |
Num ee,ee1; |
Num ee,ee1,c1,c2; |
|
|
if ( IS_ZERO(f1) ) |
if ( IS_ZERO(f1) ) |
if ( IS_ZERO(f2) ) return 0; |
if ( IS_ZERO(f2) ) return 0; |
Line 2506 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2506 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
else return 0; |
else return 0; |
} |
} |
if ( IS_NARYMUL(f1) || IS_NARYMUL(f2) ) { |
if ( IS_NARYMUL(f1) || IS_NARYMUL(f2) ) { |
f1 = to_narymul(f1); f2 = to_narymul(f2); |
fnode_coef_body(f1,&c1,&b1); |
n1 = (NODE)FA1(f1); n2 = (NODE)FA1(f2); |
fnode_coef_body(f2,&c2,&b2); |
|
if ( !compfnode(b1,b2) ) return compnum(0,c1,c2); |
|
b1 = to_narymul(b1); b2 = to_narymul(b2); |
|
n1 = (NODE)FA1(b1); n2 = (NODE)FA1(b2); |
while ( 1 ) { |
while ( 1 ) { |
while ( n1 && n2 && !compfnode(BDY(n1),BDY(n2)) ) { |
while ( n1 && n2 && !compfnode(BDY(n1),BDY(n2)) ) { |
n1 = NEXT(n1); n2 = NEXT(n2); |
n1 = NEXT(n1); n2 = NEXT(n2); |
Line 2519 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2522 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
} |
} |
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); |
n1 = NEXT(n1); n2 = NEXT(n2); |
|
|
|
if ( r = fnode_normalize_comp(b1,b2) ) return r; |
if ( r = fnode_normalize_comp(b1,b2) ) { |
else if ( fnode_is_number(e1) && fnode_is_number(e2) ) { |
if ( r > 0 ) |
/* f1 = t b^e1 ... , f2 = t b^e2 ... */ |
return fnode_normalize_comp(e1,mkfnode(1,I_FORMULA,0)); |
subnum(0,eval(e1),eval(e2),&ee); |
else if ( r < 0 ) |
r = compnum(0,ee,0); |
return fnode_normalize_comp(mkfnode(1,I_FORMULA,0),e2); |
if ( r > 0 ) { |
} else { |
/* e1>e2 */ |
n1 = NEXT(n1); n2 = NEXT(n2); |
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
if ( fnode_is_number(e1) && fnode_is_number(e2) ) { |
MKNODE(n1,g,n1); |
/* f1 = t b^e1 ... , f2 = t b^e2 ... */ |
} else if ( r < 0 ) { |
subnum(0,eval(e1),eval(e2),&ee); |
/* e1<e2 */ |
r = compnum(0,ee,0); |
chsgnnum(ee,&ee1); ee1 = ee; |
if ( r > 0 ) { |
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
/* e1>e2 */ |
|
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
|
MKNODE(n1,g,n1); |
|
} else if ( r < 0 ) { |
|
/* e1<e2 */ |
|
chsgnnum(ee,&ee1); ee = ee1; |
|
g = mkfnode(3,I_BOP,pwrfs,b1,mkfnode(1,I_FORMULA,ee)); |
MKNODE(n2,g,n2); |
MKNODE(n2,g,n2); |
|
} |
|
} else { |
|
r = fnode_normalize_comp(e1,e2); |
|
if ( r > 0 ) return 1; |
|
else if ( r < 0 ) return -1; |
} |
} |
} else { |
|
r = fnode_normalize_comp(e1,e2); |
|
if ( r > 0 ) return 1; |
|
else if ( r < 0 ) return -1; |
|
} |
} |
} |
} |
} |
} |
Line 2610 int fnode_normalize_comp_pwr(FNODE f1,FNODE f2) |
|
Line 2619 int fnode_normalize_comp_pwr(FNODE f1,FNODE f2) |
|
|
|
fnode_base_exp(f1,&b1,&e1); |
fnode_base_exp(f1,&b1,&e1); |
fnode_base_exp(f2,&b2,&e2); |
fnode_base_exp(f2,&b2,&e2); |
if ( r = fnode_normalize_comp(b1,b2) ) return r; |
if ( r = fnode_normalize_comp(b1,b2) ) { |
else return fnode_normalize_comp(e1,e2); |
if ( r > 0 ) |
|
return fnode_normalize_comp(e1,mkfnode(1,I_FORMULA,0)); |
|
else if ( r < 0 ) |
|
return fnode_normalize_comp(mkfnode(1,I_FORMULA,0),e2); |
|
} else return fnode_normalize_comp(e1,e2); |
} |
} |