Simple problem related to `macro` keyword

Hi all, I’m trying to use the macro keyword to include some functions into my weak form (just to tidy up my code and to make mistakes less likely when typing). However, when playing around with the macro keyword, I ran into a strange issue where I receive the following error:

Warning ambiguity Polymorphic Find 2

The code which generates such an error is simply:

macro tt(u) 2*exp(u) //
cout<<"tt(2)="<<tt(2)<<endl;

I assumed that maybe this was because of the presence of exp() in my function; however the following code also contains exp() and does not result in any error:

macro L11(a1, a2) 1.16014e-7*exp(-24.0473*(-1.5048e-5*a2+0.239777)^0.399839)*exp(-2819.27*exp(-12.4785*(-1.5048e-5*a2+0.239777)^0.335995)*a1^(-1.5048e-5*a2+0.239777)) //
cout<<"L11="<<L11(2,3)<<endl;

Can someone explain to me why the first line of code generates such an error? Is there a work around?

Many thanks.

Hi all, I’ve found a solution, so I’ll put it here just in case anyone else has the same issue in the future:

The following equivalent code works:

macro tt(u) 2*exp(1e0*u) //
cout<<"tt(2)="<<tt(2)<<endl;

So, for some reason, you must include a coefficient in standard form next to your argument. So, if you just want exp(u) you must write exp(1e0*u).

Apologies, I know this is a very simple issue and probably didn’t need putting here.

When you call exp(), FF has to know what kind of argument it is (real, complex, matrix, vector of values…). exp is a polymorphic function.
In your first code, the type of “2” is not declared, which is the problem.
When you write your macro L11, you have real numbers, identified by “.”. Hence the result is a real number. The same occurs in your last def with 1e0*u.
Another way to make it work is

macro tt(u) 2*exp(u) //
cout<<"tt(2)="<<tt(2.)<<endl;

so that 2. is declared as a real number.
Note that “integer” is not an admissible type of argument for exp.

Hi, thanks for your reply! I’ll keep this all in mind.