vermaseren / form

The FORM project for symbolic manipulation of very big expressions
GNU General Public License v3.0
982 stars 118 forks source link

Tensors with zeros as arguments vanish #445

Open tueda opened 1 year ago

tueda commented 1 year ago

This was pointed out in the discussion of #444.

The following code:

T t;
L F = t(0);
P;
.end

gives

   F = 0;

Indeed, this behaviour was introduced in the big change for 4.2.1, 689b72d, which is mysterious/unclear to me. If I set AM.vectorzero to a non-zero value (e.g., in main()), then it gives

   F =
      t(0);

as expected.

So, what is AM.vectorzero? The commentary says https://github.com/vermaseren/form/blob/2319a49ef0a2add63c6caac011e482d0d5d8737f/sources/structs.h#L1599 which is a good way to leave people at a loss.

vermaseren commented 1 year ago

This vectorzero was introduced to facilitate substitutions like t(p)*replace_(p,0) If you like to restore the old behaviour, you will have to see to it that the above will also work.

On 14 May 2023, at 03:15, Takahiro Ueda @.***> wrote:

This was pointed out in the discussion of #444 https://github.com/vermaseren/form/issues/444.

The following code:

T t; L F = t(0); P; .end gives

F = 0; Indeed, this behaviour was introduced in the big change for 4.2.1, 689b72d https://github.com/vermaseren/form/commit/689b72dd76f3da7b52ee0fd9bd00d325c1cc0c9b, which is mysterious/unclear to me. If I set AM.vectorzero to a non-zero value (e.g., in main()), then it gives

F = t(0); as expected.

So, what is AM.vectorzero? The commentary says https://github.com/vermaseren/form/blob/2319a49ef0a2add63c6caac011e482d0d5d8737f/sources/structs.h#L1599 which is a good way to leave people at a loss.

— Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/445, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEXXETTGTKUS44YZCTLXGAW4HANCNFSM6AAAAAAYA2IARM. You are receiving this because you are subscribed to this thread.

tueda commented 1 year ago

Thanks for the explanation, Jos. But it doesn't seem to work:

T t;
V p;
L F = t(p)*replace_(p,0);
P;
.end
   F =
      replace_(p,0)*t(p);
vermaseren commented 1 year ago

Actually, I am not sure the implementation was complete. The code mentions a vector p0 which should be taking the place of the zero vector. But I do not find it antywhere else. My guess is that the vector p0 should be defined in the startup code after which AM.vectorzero should get its number. In that case the replace should read t(p)*replace(p,p0_) and it would give zero, while the t(0) would regain its old meaning. I think the implementation of this was interrupted by something more urgent and then forgotten.

On 15 May 2023, at 10:10, Takahiro Ueda @.***> wrote:

Thanks for the explanation, Jos. But it doesn't seem to work:

T t; V p; L F = t(p)replace(p,0); P; .end F = replace(p,0)t(p); — Reply to this email directly, view it on GitHub https://github.com/vermaseren/form/issues/445#issuecomment-1547390593, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJPCEU24ILP4R4T4IW4JHLXGHQIXANCNFSM6AAAAAAYA2IARM. You are receiving this because you commented.