Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions check/fixes.frm
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,91 @@ P F;
assert succeeded?
assert result("F") =~ expr("0")
*--#] Issue525 :
*--#[ Issue544 :
#-
Off Statistics;

Symbol x;
Vector D,p,q;
CFunction tag;
CFunction f,g,h,i,j,k,l,m;
CFunction F,G,H,I,J,K,L,M;

#define N "3"

Local test =
#do i = -`N',`N'
+ f(p,`i')
+ f(-q,`i')
+ f(p,q,`i')
+ f(-p,q,`i')
+ f(p,-q,`i')
+ f(-p,-q,`i')
#enddo
;

* Use tags to make sure the cancellation is unique
Identify f(?a) =
+ (f(?a) - F(?a)) * tag(f,?a)
+ (g(?a) - G(?a)) * tag(g,?a)
+ (h(?a) - H(?a)) * tag(h,?a)
+ (i(?a) - I(?a)) * tag(i,?a)
+ (j(?a) - J(?a)) * tag(j,?a)
+ (k(?a) - K(?a)) * tag(k,?a)
+ (l(?a) - L(?a)) * tag(l,?a)
+ (m(?a) - M(?a)) * tag(m,?a)
;
.sort

Identify f(p?,x?) = D.p^x;
Identify f(p?,q?,x?) = p.q^x;
Identify g(p?,x?) = D.p^-x;
Identify g(p?,q?,x?) = p.q^-x;

Identify h(p?,x?) = (D.p)^x;
Identify h(p?,q?,x?) = (p.q)^x;
Identify i(p?,x?) = D.p^(x);
Identify i(p?,q?,x?) = p.q^(x);

* And with - signs on the pattern vector:
Identify j(-p?,x?) = D.p^x;
Identify j(-p?,-q?,x?) = p.q^x;
Identify k(-p?,x?) = D.p^-x;
Identify k(-p?,-q?,x?) = p.q^-x;

Identify l(-p?,x?) = (D.p)^x;
Identify l(-p?,-q?,x?) = (p.q)^x;
Identify m(-p?,x?) = D.p^(x);
Identify m(-p?,-q?,x?) = p.q^(x);

* Cancel all terms, with no pattern for the power
#do i = -`N',`N'
Identify F(p?,`i') = D.p^`i';
Identify F(p?,q?,`i') = p.q^`i';
Identify G(p?,`i') = D.p^-`i';
Identify G(p?,q?,`i') = p.q^-`i';

Identify H(p?,`i') = (D.p)^`i';
Identify H(p?,q?,`i') = (p.q)^`i';
Identify I(p?,`i') = D.p^(`i');
Identify I(p?,q?,`i') = p.q^(`i');

Identify J(-p?,`i') = D.p^`i';
Identify J(-p?,-q?,`i') = p.q^`i';
Identify K(-p?,`i') = D.p^-`i';
Identify K(-p?,-q?,`i') = p.q^-`i';

Identify L(-p?,`i') = (D.p)^`i';
Identify L(-p?,-q?,`i') = (p.q)^`i';
Identify M(-p?,`i') = D.p^(`i');
Identify M(-p?,-q?,`i') = p.q^(`i');
#enddo

Print +s;
.end
assert succeeded?
assert result("test") =~ expr("0")
*--#] Issue544 :
*--#[ Issue563 :
#: SubTermsInSmall 50

Expand Down
32 changes: 30 additions & 2 deletions sources/wildcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ Seven:;
while ( t < u ) {
*m = *t;
subcount = 0;
/* Process the first vector of the DOTPRODUCT */
for ( si = 0; si < setflag; si += 2 ) {
if ( t == temp + setlist[si] ) goto ss2;
}
Expand All @@ -316,7 +317,17 @@ Seven:;
*m = s[3]; dirty = 1; break;
}
if ( *s == VECTOMIN ) {
*m = s[3]; dirty = 1; sgn += t[2]; break;
*m = s[3];
dirty = 1;
if ( ( ABS(t[2]) - 2*MAXPOWER ) < 0 ) {
/* The power is a number */
sgn += t[2];
}
else {
/* The power is a wildcard. Put a -, resolve later. */
sgn++;
}
break;
}
if ( *s == VECTOSUB ) {
*m = s[3]; dirty = 1; subcount = 1; break;
Expand All @@ -327,6 +338,7 @@ Seven:;
ss2:
*++m = *++t;
s = subs;
/* Process the second vector of the DOTPRODUCT */
for ( si = 0; si < setflag; si += 2 ) {
if ( t == temp + setlist[si] ) goto ss3;
}
Expand All @@ -336,7 +348,17 @@ Seven:;
*m = s[3]; dirty = 1; break;
}
if ( *s == VECTOMIN ) {
*m = s[3]; dirty = 1; sgn += t[1]; break;
*m = s[3];
dirty = 1;
if ( ( ABS(t[1]) - 2*MAXPOWER ) < 0 ) {
/* The power is a number */
sgn += t[1];
}
else {
/* The power is a wildcard. Put a -, resolve later. */
sgn++;
}
break;
}
if ( *s == VECTOSUB ) {
*m = s[3]; dirty = 1; subcount += 2; break;
Expand All @@ -345,12 +367,18 @@ Seven:;
s += s[1];
}
ss3: *++m = *++t;
/* Process the power */
if ( ( ABS(*t) - 2*MAXPOWER ) < 0 ) goto RegPow;
s = subs;
for ( j = 0; j < i; j++ ) {
if ( ( ABS(*t) - 2*MAXPOWER ) == s[2] ) {
if ( *s == SYMTONUM ) {
*m = s[3];
/* Since the power is a wildcard, sgn is 0,1,2 depending whether
there were 0,1,2 VECTOMIN in the DOTPRODUCT. Multiply by the
power, which is positive currently. */
sgn *= *m;
/* Now flip the sign of the power, if the wildcard came with a - */
if ( *t < 0 ) *m = -*m;
dirty = 1;
break;
Expand Down
Loading