-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A question about addargs #277
Comments
Hi,
That was indeed not as it should have been.
Has been repaired…..
It gives now f(0).
Jos
… On 11 Apr 2018, at 07:55, Vladyslav Shtabovenko ***@***.***> wrote:
Could someone please explain me how to deal with cases where the application of addargs creates a function with zero arguments?
Consider for example
CFunction f,g,h;
S x,y;
Local test = f(-1,1)*g(2);
Transform f addargs(1,last);
Print +s;
.sort
id f(x?{>=0,<=0}) = 0;
id f(x?neg0_) = 0;
id f(0) = 0;
id f() = 0;
id f = 0;
Print +s;
.end
Actually I would expect to see f(0) instead of f(), but perhaps it is some FORM convention. Now none of the obvious id statements I tried allows me to pick up this f() and transform it into something else (e.g. set it to zero). On the other hand, this
id f(x?) = g(10,x);
and this
id f(x?)*g(y?) = h(x,y);
rule obviously work and return a correct result, while this
id f(?x)*g(y?) = h(y,?x);
creates a weird h(2,).
I wonder whether I'm missing something here or if this behavior is a consequence of a bug.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#277>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFLxEjXsfLL1pDyRzjePIIPtAnwld2iwks5tnZrvgaJpZM4TPacP>.
|
Hi Jos, thanks a lot, now it works as expected! Just a small related question: Why is it actually not to possible to do
while the funny workaround with
works nonetheless? A similar code with a symbolic set element works as well
Cheers, |
Hi Vladislav,
This one is actually in the manual (although a bit hidden in this context).
The combination {0} gets stolen by the preprocessor calculator.
Hence you should use something like {0,} giving it a dummy second argument
that is empty and hence will never be considered. The comma makes that the
contents of the {} cannot be evaluated as a numerical expression.
Cheers
Jos
… On 12 Apr 2018, at 03:12, Vladyslav Shtabovenko ***@***.***> wrote:
Hi Jos,
thanks a lot, now it works as expected!
Just a small related question: Why is it actually not to possible to do
CFunction f;
S x;
Local test = f(-1,1);
Transform f addargs(1,last);
id f(x?{0}) = 0;
Print +s;
.end
while the funny workaround with
id f(x?{<=0,>=0}) = 0;
works nonetheless. A similar code with a symbolic set element works as well
CFunction f;
S x,y;
Local test = f(y);
id f(x?{y}) = 0;
Print +s;
.end
Cheers,
Vladyslav
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#277 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFLxEln1SHtR3FcrflHGxjOAyULc1zw8ks5tnqn6gaJpZM4TPacP>.
|
Hi Jos, my bad, I should have studied the chapter about the preprocessor calculator more carefully. Actually, my original motivation to use The naive approach
is painfully slow and hence not good. With
Probably it can be made even faster without using Cheers, |
Hi Vladislav,
At first when I looked at your program, I did not see a way to do it better, but
then, we usually tend to think in fixed patterns.
Suddenly it struck me that it can be done even faster:
Autodeclare symbol x,y;
Autodeclare cfunction f;
#define NP "8"
Local test = (f(1,0,2,3,7,1,5,2)+f(1,1,0,3,4,1,2,2))^10*
(f(1,-1,0,-3,2,1,-5,0)+f(1,2,0,3,4,1,-2,-2))^12*
(f(-1,0,0,-2,3,0,0,0)+f(0,0,0,0,0,0,-1,-1))^23;
id f(y1?,...,y`NP'?) = <x1^y1>*...*<x`NP'^y`NP'>;
id <x1^y1?>*...*<x`NP'^y`NP'?> = ff(y1,...,y`NP');
Print;
.end
The manipulation of symbols is faster because adding the powers is kind of
automatic. But the transform was very nice too.
Cheers
Jos
… On 12 Apr 2018, at 05:45, Vladyslav Shtabovenko ***@***.***> wrote:
Hi Jos,
my bad, I should have studied the chapter about the preprocessor calculator more carefully.
Actually, my original motivation to use addargs was to find a fast way to add arguments of function products like f(a,b,c)*f(d,e,f) -> f(a+d,b+e,c+f).
The naive approach
cfunction f;
Autodeclare symbol xx,yy;
Autodeclare cfunction ff;
#define NP "8"
Local test = (f(1,0,2,3,7,1,5,2)+f(1,1,0,3,4,1,2,2))^10*(f(1,-1,0,-3,2,1,-5,0)+f(1,2,0,3,4,1,-2,-2))^12*(f(-1,0,0,-2,3,0,0,0)+f(0,0,0,0,0,0,-1,-1))^23;
repeat;
id f(<xx1?int_>,...,<xx`NP'?int_>)*f(<yy1?int_>,...,<yy`NP'?int_>) = f(<xx1+yy1>,...,<xx`NP'+yy`NP'>);
endrepeat;
.end
is painfully slow and hence not good. With addargs the same calculation becomes much faster
cfunction f;
Autodeclare symbol xx,yy;
Autodeclare cfunction ff;
#define NP "8"
Local test = (f(1,0,2,3,7,1,5,2)+f(1,1,0,3,4,1,2,2))^10*(f(1,-1,0,-3,2,1,-5,0)+f(1,2,0,3,4,1,-2,-2))^12*(f(-1,0,0,-2,3,0,0,0)+f(0,0,0,0,0,0,-1,-1))^23;
id f(<xx1?int_>,...,<xx`NP'?int_>) = <ff1(xx1)>*...*<ff`NP'(xx`NP')>;
#do i=1,`NP'
chainin ff`i';
#enddo
#do i=1,`NP'
transform ff`i', addargs(1,last);
#enddo
id <ff1(xx1?)>*...*<ff`NP'(xx`NP'?)> = ff(<xx1>,...,<xx`NP'>);
.end
Probably it can be made even faster without using addargs (otherwise the bug I have reported would have been discovered much earlier), but I was not able to find a more direct way to add the arguments in one step.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#277 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFLxEk0BulKQDXGcIVEPk-_ZaGJshQ7Fks5tns2-gaJpZM4TPacP>.
|
Dear Jos, many thanks! It's always amazing to learn new tricks that make FORM work even faster than anticipated. Cheers, |
Could someone please explain me how to deal with cases where the application of
addargs
creates a function with zero arguments?Consider for example
Actually I would expect to see
f(0)
instead off()
, but perhaps it is some FORM convention. Now none of the obviousid
statements I tried allows me to pick up thisf()
and transform it into something else (e.g. set it to zero). On the other hand, thisand this
rule obviously work and return a correct result, while this
creates a weird
h(2,)
.I wonder whether I'm missing something here or if this behavior is a consequence of a bug.
The text was updated successfully, but these errors were encountered: