# Can freefem + + find the largest element of the stiffness matrix?

Can freefem + + find the largest element of the stiffness matrix?

If the type of the stiffness matrix is sparse, then

int[int] I, J;
real[int] V;
[I, J, V] = A;
real Amax = V.max;


but if the type is real[int, int], then

int i, j;
ijmax(A, i, j);
real Amax = A(i, j);


Thank you for your answer, but my code runs as follows

– FreeFem++ v4.1 (Sat, Nov 13, 2021 7:40:01 PM - git v4.10)
Load: lg_fem lg_mesh lg_mesh3 eigenvalue
1 : load “Element_P3”(load: loadLibary C:\Program Files (x86)\FreeFem++\.\Element_P3 = 0)
2 : int n=64,m=64;
3 : mesh Th=square(n,m,[-8+16x,-8+16y]);
4 : fespace Xh(Th,P3);
5 : // ofstream stiffnessmatrix1(“1P3”+n+","+m+".txt");
6 : // ofstream stiffnessmatrix2(“2P3”+n+","+m+".txt");
7 : ofstream largeelement1(“1P3”+n+","+m+".txt");
8 : Xh f=exp(-x^2-y^2);
9 : Xh f1=dx(f);
10 : Xh f2=dy(f);
11 : Xh Lzf=-1i*(xf1-yf2);
12 : Xh Lzf1=-1i*(xf1-yf2);
13 : varf rhs(Lzf,v)=int2d(Th)(Lzfv);
14 : varf rhs1(Lzf1,v1)=int2d(Th)(Lzf1
(-1i)xdy(v1))-int2d(Th)(Lzf1*(-1i)ydx(v1));
15 : matrix A=rhs(Xh,Xh);
16 : matrix B=rhs1(Xh,Xh);
17 : int[int] I, J;
18 : real[int] V;
19 : [I, J, V] = A;
Error line number 19, in file C:\Users\weiqi\Desktop\Dr.wei\Lzf.edp, before token ;
we are waiting for [ lg,col,a] = A
current line = 19
Compile error : we are waiting for [ lg,col,a] = A
line number :19, ;
error Compile error : we are waiting for [ lg,col,a] = A
line number :19, ;
code = 1 mpirank: 0
try getConsole C:\Users\weiqi\Desktop\Dr.wei\测试变分项\Lzf.edp
wait enter ?
why?

I guess your matrix is complex, in this case, you can only get the maximum modulus of elements of matrix by A.linfty.

In addition, Xh should be Xh<complex> and matrix should be matrix<complex>.

1 Like

Thank you very much. According to your reply, the problem has been solved.What does this symbol mean?

linfty

For a n\times m matrix A, A.linfty in FreeFEM is ||A||_{\ell^\infty}:=\max\limits_{1\le i\le n,\\1\le j\le m}{|a_{ij}|}.

1 Like

Thank you very much for your answer. 