Actual source code: example5.edp
 1 /*******************************************************
 2  *  This file is part of the FreeFEM tutorial made by  *
 3  *      Pierre Jolivet <pierre@joliv.et>               *
 4  *                                                     *
 5  *  See https://joliv.et/FreeFem-tutorial for more     *
 6  *                                                     *
 7  *   Description: sparse matrices and solvers          *
 8  *******************************************************/
  
10 mesh sq = square(10, 10);
 
12 func f = 1;
13 varf vPb(u, v) = int2d(sq)(dx(u) * dx(v) + dy(u) * dy(v)) + int2d(sq)(f * v) + on(1, u = 1.0);
14 fespace Vh(sq, P1);
 
16 matrix A = vPb(Vh, Vh);
17 Vh b = vPb(0, Vh);
18 Vh x;
 
20 x[] = A^-1 * b[];
21 plot(x);
 
23 set(A, solver = sparsesolver);
24 x[] = A^-1 * b[];
25 plot(x);
 
27 x[] = A'^-1 * b[];
28 plot(x);