I learned how to find the inverse matrix using Eigen . But when I find the return array, which is the output of the function, I got an error
query for the element 'inverse in' x, which is a non-class type of "Double **
Please help me using the C ++ library to find the inverse matrix.
The code I wrote is:
#include <iostream>
#include <armadillo>
#include <cmath>
#include <Eigen/Dense>
using namespace std;
using namespace arma;
using namespace Eigen;
int main()
{
vec a;
double ** x;
double ** inv_x;
a <<0 << 1 << 2 << 3 << 4;
double ** f (vec a);
x= f(a);
cout << "The inverse of x is:\n" << x.inverse() << endl;
return 0;
}
double ** f(vec a)
{
double ** b = 0;
int h=5;
for(int i1=0;i1<h;i1++)
{
b[i1] = new double[h];
{
b[i1][0]=1;
b[i1][1]=a[i1];
b[i1][2]=a[i1]*a[i1]+1/12;
b[i1][3]=pow(a[i1],3)+a[i1]/4;
b[i1][4]=1/80+pow(a[i1],2)/2+pow(a[i1],4);
}
}
return b;
}
Here the user-defined function freturns an array x. I am trying to find the inverse xusing my own library.
source
share