version 1.80, 2005/10/26 02:58:25 |
version 1.82, 2005/10/26 08:39:58 |
|
|
* 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.79 2005/10/19 10:31:18 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/strobj.c,v 1.81 2005/10/26 07:33:03 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}, |
{"quote_normalize_comp",Pquote_normalize_comp,2,0x3}, |
|
|
{"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 2364 FNODE fnode_normalize_pwr(FNODE f1,FNODE f2,int expand |
|
Line 2364 FNODE fnode_normalize_pwr(FNODE f1,FNODE f2,int expand |
|
return b; |
return b; |
else |
else |
return fnode_node_to_narymul(mknode(2,cc,b)); |
return fnode_node_to_narymul(mknode(2,cc,b)); |
} else if ( expand && fnode_is_nonnegative_integer(f2) ) { |
} else if ( expand && fnode_is_integer(f2) |
|
&& fnode_is_nonnegative_integer(f2) ) { |
q = (Q)eval(f2); |
q = (Q)eval(f2); |
if ( PL(NM(q)) > 1 ) error("fnode_normalize_pwr : exponent too large"); |
if ( PL(NM(q)) > 1 ) error("fnode_normalize_pwr : exponent too large"); |
return fnode_expand_pwr(f1,QTOS(q)); |
return fnode_expand_pwr(f1,QTOS(q)); |
Line 2483 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2484 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
{ |
{ |
NODE n1,n2; |
NODE n1,n2; |
int r,i1,i2; |
int r,i1,i2; |
FUNC fp1,fp2; |
char *nm1,*nm2; |
FNODE b1,b2,e1,e2,g; |
FNODE b1,b2,e1,e2,g; |
Num ee,ee1; |
Num ee,ee1; |
|
|
Line 2562 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
Line 2563 int fnode_normalize_comp(FNODE f1,FNODE f2) |
|
case I_FORMULA: |
case I_FORMULA: |
return 1; |
return 1; |
case I_FUNC: |
case I_FUNC: |
fp1 = (FUNC)FA0(f1); fp2 = (FUNC)FA0(f2); |
nm1 = ((FUNC)FA0(f1))->name; nm2 = ((FUNC)FA0(f2))->name; |
if ( fp1 > fp2 ) return 1; |
r = strcmp(nm1,nm2); |
else if ( fp1 < fp2 ) return -1; |
if ( r > 0 ) return 1; |
|
else if ( r < 0 ) return -1; |
else { |
else { |
/* compare args */ |
/* compare args */ |
n1 = FA0((FNODE)FA1(f1)); n2 = FA0((FNODE)FA1(f2)); |
n1 = FA0((FNODE)FA1(f1)); n2 = FA0((FNODE)FA1(f2)); |
while ( n1 && n2 ) |
while ( n1 && n2 ) |
if ( r = fnode_normalize_comp(BDY(n1),BDY(n2)) ) |
if ( r = fnode_normalize_comp(BDY(n1),BDY(n2)) ) return r; |
return r; |
else { |
|
n1 = NEXT(n1); n2 = NEXT(n2); |
|
} |
if ( n1 ) return 1; |
if ( n1 ) return 1; |
else if ( n2 ) return -1; |
else if ( n2 ) return -1; |
else return 0; |
else return 0; |