user355843
user355843

Reputation: 63

How can I use Armadillo to compute eigenpairs?

I just got Armadillo and wanted to familiarized myself so I am doing a "test" run with it

int main(){
    double myMatrix[6][6];
    for (int i = 0; i < 6; i++){
        for (int j = 0; j < 6; j++){
            myMatrix[i][j] = i+2*j;
        }
    }

    mat ARMA_L;
    vec ARMA_eigenval;
    mat ARMA_eigenvec;

    for (int i = 0; i < 6; i++){
        for (int j = 0; j < 6; j++){
            ARMA_L(i,j) = myMatrix[i][j];
        }
    }
    eig_gen(ARMA_eigenval, ARMA_eigenvec, ARMA_L);
    return 0;
}

When I try to compile, it says there's no function for call to eig_gen() but the documentation seems like I'm doing what I should be doing, however.

Upvotes: 0

Views: 113

Answers (1)

ks1322
ks1322

Reputation: 35795

You are using wrong types for eig_gen() function. ARMA_eigenval and ARMA_eigenvec should be cx_vec and cx_mat respectively:

cx_vec ARMA_eigenval;
cx_mat ARMA_eigenvec;

See example in documentation:

mat A = randu<mat>(10,10);

cx_vec eigval;
cx_mat eigvec;

eig_gen(eigval, eigvec, A);

Upvotes: 1

Related Questions