wys
April 10, 2019, 2:03pm
#1
Dear all,

I am new to FreeFEM++ and I want to ask a simple question.
If I have already obtained a matrix by matrix A = va(Vh, Vh); , how to get the sub-matrix of A? For example in Matlab, you can simply write A(1:i, 1:j) .

Thanks for your time.
wys

I do not know if a simple technique exists for sparse matrix, but you can use the [I, J, C] decomposition (see here ) to manually modify your matrix

Update: It is possible using indexes.

A working example:

```
mesh Th = square(10, 10);
fespace Uh(Th, P1);
macro grad(u)[dx(u), dy(u)]//
varf vL (u, uh)
= int2d(Th)(
u * uh
+ grad(u)'*grad(uh)
)
+ on(1, 2, u=0)
;
matrix L = vL(Uh, Uh);
int imin = 10;
int imax = 50;
int jmin = 15;
int jmax = 45;
int[int] I(imax-imin);
for (int i = 0; i < I.n; i++)
I[i] = imin + i;
int[int] J(jmax-jmin);
for (int j = 0; j < J.n; j++)
J[j] = jmin + j;
matrix L2;
L2 = L(I, J);
```