# Matrix Inversion no solver

**URL:** <https://community.freefem.org/t/matrix-inversion-no-solver/2238>\
**Category:** General Discussion\
**Created:** [January 21, 2023, 11:40pm UTC](https://community.freefem.org/t/matrix-inversion-no-solver/2238 "2023-01-21T23:40:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![themathsdude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/themathsdude/32/1503_2.png) [@themathsdude](https://community.freefem.org/u/themathsdude)\
**Post date:** [January 21, 2023, 11:40pm UTC](https://community.freefem.org/t/matrix-inversion-no-solver/2238/1 "2023-01-21T23:40:14Z")

</div>

Hello everyone,

I want to solve a linear system. I have a vandermonde matrix in a linear system. I figured out i should solve it with `real[int] sol = A^-1 * b` as suggested in the documentation, but i get the following error :

```auto
MATERROR 1 : VirtualMatrix:: no solver ?????
  current line = 90
 call interpolation at line 95
Exec error : MATERROR
   -- number :1
Exec error : MATERROR
   -- number :1
 err code 8 , mpirank 0

```

Why do i have to specify a solver, i thought this is regular matrix inversion (gauss-jordan?). How should i specify the solver ?

Here is the code :

```auto
func real[int] interpolation(real[int] A, real[int] B, real pente) {
  matrix vandermonde =
      [[A [0] ^ 3, A [0] ^ 2, A [0], 1], [B [0] ^ 3, B [0] ^ 2, B [0], 1],
       [3 * A [0] ^ 2, 2 * A [0], 1, 0], [3 * B [0] ^ 2, 2 * B [0], 1, 0]];
  real[int] sndmembre = [A[1], B[1], 0, pente ];
  real[int] sol = vandermonde ^ -1 * sndmembre;
  return sol;
}

real[int] p10 = p1 + departChauffe;
real[int] coeffs = interpolation(p1, p10, pente);

```

Thank you for your help 🙂

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 22, 2023, 1:24pm UTC](https://community.freefem.org/t/matrix-inversion-no-solver/2238/2 "2023-01-22T13:24:32Z")

</div>

What if you do `set(vandermonde, solver = sparse solver);` before the call to `^-1`?

---

<div class="post-metadata">

**Author:** ![themathsdude](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/themathsdude/32/1503_2.png) [@themathsdude](https://community.freefem.org/u/themathsdude)\
**Post date:** [January 22, 2023, 2:26pm UTC](https://community.freefem.org/t/matrix-inversion-no-solver/2238/3 "2023-01-22T14:26:50Z")

</div>

it worked, i used `sparsesolver` in one word, thank you 🙂

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [January 22, 2023, 2:39pm UTC](https://community.freefem.org/t/matrix-inversion-no-solver/2238/4 "2023-01-22T14:39:29Z")

</div>

Sorry for the small error on behalf of my auto-correct.
