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
114 changes: 114 additions & 0 deletions check/features.frm
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,120 @@ assert result("F3") =~ expr("1/1000000*x^5")
assert result("F4") =~ expr("4.7e+00*x - 5.0e-05*x^4 + 1/1000000*x^5")
assert result("F5") =~ expr("1/1000000*x^5")
*--#] chop :
*--#[ pattern_float :
#-
Off Statistics;
#StartFloat 10d
#message StartFloat
Symbol a,x1,...,x4;
CFunction f,g;
Vector p;
Local F = 1.0-2.0*a+3.0*f-4.0*p.p+5.0*p;
id 1.0 = 5;
id f?(?a) = g(?a);
id float_(?a) = g(?a);
id float_(x1?,x2?,x3?,x4?) = g(x1,x2,x3,x4);
Print;
.sort

#endfloat
#message endfloat
id float_(2,3,1,340282366920938463463374607431768211456) = 5;
id f?(?a) = g(?a);
id float_(?a) = g(?a);
id float_(x1?,x2?,x3?,x4?) = g(x1,x2,x3,x4);
Print +s;
.end
#pend_if wordsize == 2
assert succeeded?
assert stdout =~ exact_pattern(<<'EOF')
~~~StartFloat

F =
- 2.0e+00*a - 4.0e+00*p.p + 5.0e+00*p + 1.0e+00 + 3.0e+00*g;

~~~endfloat

F =
- a*float_(2,3,1,680564733841876926926749214863536422912)
- p.p*float_(2,3,1,1361129467683753853853498429727072845824)
+ p*float_(2,3,1,1701411834604692317316873037158841057280)
+ float_(2,3,1,340282366920938463463374607431768211456)
+ g*float_(2,3,1,1020847100762815390390123822295304634368)
;
EOF
*--#] pattern_float :
*--#[ transform_float :
#-
CFunction f;
Off Statistics;
#StartFloat 10d
#message StartFloat
Local F = 1.0*f(1,2,3);
Transform replace(1,last)=(xarg_,2*xarg_+1);
Print;
.sort

#endfloat
#message endfloat
Transform mulargs(1,last);
Print;
.end
#pend_if wordsize == 2
assert succeeded?
assert stdout =~ exact_pattern(<<'EOF')
~~~StartFloat

F =
1.0e+00*f(3,5,7);

~~~endfloat

F =
f(105)*float_(2,3,1,340282366920938463463374607431768211456);
EOF
*--#] transform_float :
*--#[ transform_float_error :
#-
CFunction f,g;
Off Statistics;
#StartFloat 10d
Local F = 1.0*f(1,2,3)*g(3,2,1);
Transform float_, reverse(1,last);
Transform {float_,f}, addargs(1,last);
Print;
.sort

#endfloat
Transform float_, dropargs(1,last);
Transform {float_,f}, selectargs(1,2);
Print;
.end
#pend_if wordsize == 2
runtime_error?("Illegal use of a transform statement and float_")
runtime_error?("Illegal use of a transform statement and float_")
runtime_error?("Illegal use of a transform statement and float_")
runtime_error?("Illegal use of a transform statement and float_")
*--#] transform_float_error :
*--#[ argument_float :
#StartFloat 24d
CFunction f;
Symbol a,b,c,d;
#StartFloat 24d
Local F = 1.0 -2.0*f(a+5*b-3*c)+f(3.14*a*b);
Normalize;
MakeInteger;
Argument;
Multiply 10*d;
EndArgument;
SplitArg;
FactArg;
Print;
.end
#pend_if wordsize == 2
assert succeeded?
assert result("F") =~ expr("1.0e+00 + f(a,b,d,3.14e+01) + 2.0e+00*f(30,c,d,-50,b,d,-10,a,d)")
*--#] argument_float :
*--#[ float_error :
Evaluate;
ToFloat;
Expand Down
7 changes: 6 additions & 1 deletion sources/argument.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,18 @@ int execarg(PHEAD WORD *term, WORD level)
RightNum:
if ( m[1] == 2 ) {
#ifdef WITHFLOAT
if ( *t != FLOATFUN || AT.aux_ == 0 || TestFloat(t) == 0 )
if ( *t != FLOATFUN || TestFloat(t) == 0 )
#endif
{
m += 2;
m += *m;
goto HaveTodo;
}
#ifdef WITHFLOAT
else {
m += 2;
}
#endif
}
else {
r = m + m[1];
Expand Down
17 changes: 17 additions & 0 deletions sources/compcomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2054,9 +2054,26 @@ int DoArgument(UBYTE *s, int par)
c = *s; *s = 0;
if ( ( type = GetName(AC.varnames,name,&number,WITHAUTO) ) == CSET ) {
doset: if ( Sets[number].type != CFUNCTION ) goto nofun;
#ifdef WITHFLOAT
WORD *r1, *r2;
r1 = SetElements + Sets[number].first;
r2 = SetElements + Sets[number].last;
while ( r1 < r2 ) {
if ( *r1++ == FLOATFUN ) {
MesPrint("&Illegal use of argument environment and float_.");
error = 1;
}
}
#endif
*w++ = CSET; *w++ = number;
}
else if ( type == CFUNCTION ) {
#ifdef WITHFLOAT
if ( (number + FUNCTION) == FLOATFUN ) {
MesPrint("&Illegal use of argument environment and float_.");
error = 1;
}
#endif
*w++ = CFUNCTION; *w++ = number + FUNCTION;
}
else {
Expand Down
10 changes: 6 additions & 4 deletions sources/function.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,12 @@ int MatchFunction(PHEAD WORD *pattern, WORD *interm, WORD *wilds)
CBUF *C = cbuf+AT.ebufnum;
int ntwa = AN.NumTotWildArgs;
LONG oldcpointer = C->Pointer - C->Buffer;
#ifdef WITHFLOAT
// Pattern matching against float_ functions is currently disabled.
// To relax this in the future, move this early return down to where gamma
// functions and tensors are handled specially.
if ( *interm == FLOATFUN ) return(0);
#endif
/*
Test first for a straight match
*/
Expand All @@ -860,10 +866,6 @@ int MatchFunction(PHEAD WORD *pattern, WORD *interm, WORD *wilds)
i = *pattern - WILDOFFSET;
if ( i >= FUNCTION ) {
if ( *interm != GAMMA
#ifdef WITHFLOAT
&& ( *interm != FLOATFUN )
#endif

&& !CheckWild(BHEAD i,FUNTOFUN,*interm,&newvalue) ) {
AddWild(BHEAD i,FUNTOFUN,newvalue);
return(1);
Expand Down
26 changes: 25 additions & 1 deletion sources/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ int CoTransform(UBYTE *in)
if ( *in != ',' ) break;
c = *in; *in = 0;
type = GetName(AC.varnames,s,&number,NOAUTO);
if ( type == CFUNCTION ) { number += MAXVARIABLES + FUNCTION; }
if ( type == CFUNCTION ) {
#ifdef WITHFLOAT
if ( (number+FUNCTION) == FLOATFUN ) {
MesPrint("&Illegal use of a transform statement and float_");
if ( error == 0 ) error = 1;
}
#endif
number += MAXVARIABLES + FUNCTION; }
else if ( type != CSET ) {
MesPrint("& %s: A transform statement starts with sets of functions",s);
if ( error == 0 ) error = 1;
Expand All @@ -139,6 +146,17 @@ int CoTransform(UBYTE *in)
MesPrint("&A set in a transform statement should be a set of functions");
if ( error == 0 ) error = 1;
}
#ifdef WITHFLOAT
WORD *r1, *r2;
r1 = SetElements + Sets[number].first;
r2 = SetElements + Sets[number].last;
while ( r1 < r2 ) {
if ( *r1++ == FLOATFUN ) {
MesPrint("&Illegal use of a transform statement and float_");
if ( error == 0 ) error = 1;
}
}
#endif
}
}
else if ( error == 0 ) error = 1;
Expand Down Expand Up @@ -745,6 +763,9 @@ int RunTransform(PHEAD WORD *term, WORD *params)
if ( *t < FUNCTION ) {}
else if ( funs == endfun ) { /* we do all functions */
hit:;
#ifdef WITHFLOAT
if ( *t == FLOATFUN ) goto next;
#endif
while ( in < t ) *out++ = *in++;
tt = t + t[1]; fun = out;
while ( in < tt ) *out++ = *in++;
Expand Down Expand Up @@ -950,6 +971,9 @@ abortlyndon:;
funs++;
}
}
#ifdef WITHFLOAT
next:
#endif
t += t[1];
}
tt = term + *term; while ( in < tt ) *out++ = *in++;
Expand Down
Loading