# Error operator \* product of matrices

**URL:** <https://community.freefem.org/t/error-operator-product-of-matrices/469>\
**Category:** General Discussion\
**Created:** [June 15, 2020, 8:28am UTC](https://community.freefem.org/t/error-operator-product-of-matrices/469 "2020-06-15T08:28:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathieu.S](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@Mathieu.S](https://community.freefem.org/u/Mathieu.S)\
**Post date:** [June 15, 2020, 8:28am UTC](https://community.freefem.org/t/error-operator-product-of-matrices/469/1 "2020-06-15T08:28:20Z")

</div>

Hello,

I am currently working with FreeFrem during my internship and I get an error which I don’t understand. You can find my code following the link bellow my message. I took the code (which works) already written in the study made by Emil Garnell, Olivier Doaré and Corinne Rouby on Coupled vibro-acoustic modeling of a dielectric elastomer loudspeaker published in the Journal of the Acoustical Society of America. Their code allows to get the pressure field created by a membrane which vibrates with the implementation of perfectly matched layers. The acceleration g of the membrane is settled at the beggining of the code. I try to implement the electro-mechanical coupling to represent a real loud-speaker taking to account the action of the pressure on the membrane.

To do so I have taken the original code and I have made some modifications. I start with creating the mesh, the finite element space and writing the variationnal formulation which change a little bit compared to the initial program. The linear system is then of the shape : AP=F. Then I add two rows and two columns corresponding the the electro-mechanical equations to the matrix A, the position X and the electric charge Q are now new unknown. I also add two rows in the F vector. When I try to get the solution of this problem : Pn=An^-1\*Fn, FreeFem writes the following error message :

« error operator \* \<18Matrice\_Creuse\_invISt7complexIdEE\>, \<14Matrice\_CreuseISt7complexIdEE\> »

I understand that FreeFem does not allow to give An^-1 and Fn as an argument to the operator \*. It could stems from the difficulty to reverse the matrix, I tried the program with the initial solver (sparsesolver) and I tried UMFPACK but without more success. It is possible to reverse the matrix An, Matlab managed to do it. Do you know what is wrong with my code ? Could you advocate a solver relevant in the problem I try to solve ?

Here is the link towards my code(piston\_norayleigh\_strongcoupling\_forum.edp) and the original code (without electromechanical coupling : piston\_norayleigh.edp) :

> **[Matouwado/Code-FreeFem](https://github.com/Matouwado/Code-FreeFem)**
>
> Contribute to Matouwado/Code-FreeFem development by creating an account on GitHub.

Best

Mathieu S

---

<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:** [June 15, 2020, 2:54pm UTC](https://community.freefem.org/t/error-operator-product-of-matrices/469/2 "2020-06-15T14:54:00Z")

</div>

~~You are trying to solve a system with multiple right-hand sides. That’s not possible with the standard interface, but you can do that with PETSc, see this GitHub [issue](https://github.com/FreeFem/FreeFem-sources/issues/121#issuecomment-563204045) for more details. Also, you should store your solutions and RHS as dense matrices, `complex[int, int]`, not sparse matrices.~~

OK, after reading more carefully your problem, it looks like you in fact have a single right-hand side. You should just use `complex[int]` instead of `matrix<complex>` to store your solution and RHS, that will solve your problem.

---

<div class="post-metadata">

**Author:** ![Mathieu.S](https://avatars.discourse-cdn.com/v4/letter/m/ccd318/32.png) [@Mathieu.S](https://community.freefem.org/u/Mathieu.S)\
**Post date:** [June 15, 2020, 4:24pm UTC](https://community.freefem.org/t/error-operator-product-of-matrices/469/3 "2020-06-15T16:24:47Z")

</div>

Indeed it solved my problem.  
Thank you very much !!
