# Complex matrix for EPSSolve

**URL:** <https://community.freefem.org/t/complex-matrix-for-epssolve/2886>\
**Category:** General Discussion\
**Created:** [January 16, 2024, 5:39pm UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886 "2024-01-16T17:39:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaulGomezz](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/paulgomezz/32/1976_2.png) [@PaulGomezz](https://community.freefem.org/u/PaulGomezz)\
**Post date:** [January 16, 2024, 5:39pm UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886/1 "2024-01-16T17:39:47Z")

</div>

Hi,

I’m trying to convert a complex matrix AA into a matrix named dA via this method :

```auto
    matrix<complex> AA = a(Vh,Vh,solver = sparsesolver);
    matrix<complex> BB = b(Vh,Vh,solver = sparsesolver);

   Mat<complex> dA(AA);
   Mat<complex> dB(BB);

    real[int] nevEPS(nev);
    Vh[int] [eVEPS,eWEPS](nev);

    int epsK = EPSSolve(dA, dB, vectors = eVEPS, values = nevEPS, sparams =" -eps_largest_real " + 100
             + " -eps_type krylovschur" + " -eps_target 0" + " -st_type sinvert");

```

I’ve got the following error :  
Mat dA(AA) error operator ←   
\<  
N5PETSc14DistributedCSRIN5HPDDM7SchwarzISt7complexIdEEEEE\>

\<14Matrice\_CreuseISt7complexIdEE\>

and a giant list of choices.

This method worked well for a non-complex case. My goal is to compute the eigenvalues and eigenmodes with EPSSolve. How can I make it worked ?

Thanks in advance for those who will take time to help me.

---

<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 16, 2024, 5:58pm UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886/2 "2024-01-16T17:58:57Z")

</div>

`real[int] nevEPS(nev);` should be `complex[int] nevEPS(nev);`, and the same for the eigenvectors.

---

<div class="post-metadata">

**Author:** ![PaulGomezz](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/paulgomezz/32/1976_2.png) [@PaulGomezz](https://community.freefem.org/u/PaulGomezz)\
**Post date:** [January 16, 2024, 6:15pm UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886/3 "2024-01-16T18:15:09Z")

</div>

Thanks for your quick answer but my problem is about the line

Mat dA(AA)

It makes the error mention above. I will edit my original post.

---

<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 16, 2024, 6:24pm UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886/4 "2024-01-16T18:24:46Z")

</div>

Please copy/paste a runable code. If you have an issue with the following snippet, then the issue likely comes from your installation.

```auto
load "PETSc-complex"
matrix<complex> AA = eye(10, 10);
matrix<complex> BB = eye(10, 10);

Mat<complex> dA(AA);
Mat<complex> dB(BB);

```

---

<div class="post-metadata">

**Author:** ![PaulGomezz](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/paulgomezz/32/1976_2.png) [@PaulGomezz](https://community.freefem.org/u/PaulGomezz)\
**Post date:** [January 17, 2024, 7:50am UTC](https://community.freefem.org/t/complex-matrix-for-epssolve/2886/5 "2024-01-17T07:50:30Z")

</div>

Thanks, I only had loaded “PETSc”, and with “PETSc-complex” it works.
