vermaseren / form

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

'max'i'' does not work #444

Closed siddhesh-padval closed 1 year ago

siddhesh-padval commented 1 year ago

I am referring to the example given in the book.pdf (page.75) of FORM4.2:

when I run:

define max1 "2"

define max2 "3"

AutoDeclare Symbol x;

do i = 1, 2

do j = 1, 'max'i''

Local F'i''j' = x^'i''j';

enddo

enddo

Print; .end

I get the following error: test.frm Line 5 ==> Undefined preprocessor variable max

But when I change

do j = 1, 'max'i''

to

do j = 1, 'max{'i'}'

I do get the output as given in the manual.

I was wondering if it's an issue with my text editor or something else.

jodavies commented 1 year ago

Your pre-processor variable opening character should be a back-tick instead of apostrophe, like so:

#define max1 "2"
#define max2 "3"
AutoDeclare Symbol x;
#do i = 1, 2
#do j = 1, `max`i''
Local F`i'`j' = x^`i'`j';
#enddo
#enddo
Print;
.end

Then the nesting works.

siddhesh-padval commented 1 year ago

Thank you very much for the explanation.

I was also wondering why Tensors objects do not accept 0 index:

V v1; T t1; I [0]; L Vcomp = v1(0) + v1(3); L Tcomp1 = t1(1,1) + t1(1,2); L Tcomp2 = t1(0,1); L Tcomp3 = t1([0],1); P; .end

I was expecting that the output will be: Tcomp2 = t1(0,1);

rather than: Tcomp2 = 0;

The index 0 works for the vector as expected.

tueda commented 1 year ago

Tcomp2 = 0;

This behaviour was introduced in 689b72d, though it is unclear to me whether this was intentional or not.