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

**URL:** https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736
**Category:** General Discussion
**Created:** [May 13, 2022, 3:21am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736 "2022-05-13T03:21:46Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Qianrui](https://avatars.discourse-cdn.com/v4/letter/q/9fc348/32.png) [@Qianrui](https://community.freefem.org/u/Qianrui)
#### Post date: [May 13, 2022, 3:21am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/1 "2022-05-13T03:21:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![zhaog6](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zhaog6](https://community.freefem.org/u/zhaog6)
#### Post date: [May 14, 2022, 7:06am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/2 "2022-05-14T07:06:58Z")

</div>

If the type of the stiffness matrix is sparse, then

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

```

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

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

```

---

<div class="post-metadata">

### Author: ![Qianrui](https://avatars.discourse-cdn.com/v4/letter/q/9fc348/32.png) [@Qianrui](https://community.freefem.org/u/Qianrui)
#### Post date: [May 14, 2022, 12:15pm UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/3 "2022-05-14T12:15:23Z")

</div>

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+16_x,-8+16_y]);  
> 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\*(x_f1-y_f2);  
> 12 : Xh Lzf1=-1i\*(x_f1-y_f2);  
> 13 : varf rhs(Lzf,v)=int2d(Th)(Lzf_v);  
> 14 : varf rhs1(Lzf1,v1)=int2d(Th)(Lzf1_(-1i)_x_dy(v1))-int2d(Th)(Lzf1\*(-1i)_y_dx(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  
> save log in : ‘C:\Users\weiqi\Desktop\Dr.wei\测试变分项\Lzf.log’  
> wait enter ?  
> why?

---

<div class="post-metadata">

### Author: ![zhaog6](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zhaog6](https://community.freefem.org/u/zhaog6)
#### Post date: [May 15, 2022, 3:23am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/4 "2022-05-15T03:23:13Z")

</div>

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>`.

---

<div class="post-metadata">

### Author: ![Qianrui](https://avatars.discourse-cdn.com/v4/letter/q/9fc348/32.png) [@Qianrui](https://community.freefem.org/u/Qianrui)
#### Post date: [May 15, 2022, 11:13am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/5 "2022-05-15T11:13:01Z")

</div>

> [@zhaog6](#):
>
> A.linfty

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

> linfty

---

<div class="post-metadata">

### Author: ![zhaog6](https://avatars.discourse-cdn.com/v4/letter/z/4af34b/32.png) [@zhaog6](https://community.freefem.org/u/zhaog6)
#### Post date: [May 16, 2022, 5:07am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/6 "2022-05-16T05:07:27Z")

</div>

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}|}.

---

<div class="post-metadata">

### Author: ![Qianrui](https://avatars.discourse-cdn.com/v4/letter/q/9fc348/32.png) [@Qianrui](https://community.freefem.org/u/Qianrui)
#### Post date: [May 16, 2022, 6:51am UTC](https://community.freefem.org/t/can-freefem-find-the-largest-element-of-the-stiffness-matrix/1736/7 "2022-05-16T06:51:46Z")

</div>

Thank you very much for your answer. 🥰
