m.lbolok
(Mohsen)
June 16, 2023, 10:08am
1
Hi,
I would like to pass an array by reference in a function. I have tried this:
func real myfunc2(real a,real b,real[int] &c(2))
{
c(0)=a+b;
c(1)=a-b;
return 0.;
}
But it does not work. Is there any way to pass an array or matrix by reference in FreeFem++ ?
jbl
June 16, 2023, 10:22am
2
Hi,
I’m not sure I understand what you want.
func real myfunc2(real a,real b,real[int] &c)
{
c(0)=a+b;
c(1)=a-b;
return 0.;
}
real a = 10;
real b = 1;
real[int] c(2) ;
real Exec = myfunc2(a,b,c);
cout << c << endl;
Does this code give you what you want?
1 Like
m.lbolok
(Mohsen)
June 16, 2023, 10:32am
3
Hi,
Yes, it is exactly what I wanted to know. Many thanks for your help.