Lapack with complex matrices

48 Views Asked by At

I am writing a routine to invert complex matrices. I tested it for a real matrix, and it worked (and gave correct answers). However, when working with a matrix with complex, it does not compile (No matching function...). As far as I understand, the Lapack routine should work for a complex matrix.

So, I have changed the data type of the matrix and work space. But clearly I have done something wrong. Can anyone help me?

Best // Johan


void DysonsEq::matrixInversion(int size, double in[CMAX][CMAX][2], double out[CMAX][CMAX][2])
{
    int *IPIV=new int[size];
    int LWORK=size*size;
    complex<double> *WORK=new complex<double>[LWORK];
    int INFO;
    complex<double> mat[size*size];
    
    for(int i=0;i<size;i++)
    {
        for(int j=0;j<size;j++)
        {
            mat[i+j*size]=in[i][j][0]+1i*in[i][j][1];
        }
    }
    
    cgetrf_(&size, &size, mat, &size, IPIV, &INFO);
    
    //cgetri_(&size, mat, &size, IPIV, WORK, &LWORK, &INFO);
}

Tried to use lapack to invert complex matrix. Did not compile.

0

There are 0 best solutions below