Registered Member
|
Hi All,
I have this code that creates a 2,000 by 2,000 matrix (2D pointer), xran[i][j]. I want to take the eigenvalues and eigenvectors of xran[i][j] using EIGEN but I don't know how to go from a 2d pointer to an Eigen matrix MatrixXd. int main() { int N=2000; double alpha=40; double *x; x= new double[N]; double *y; y=new double[N]; //Itilialize Array double **xran = new double *[N]; for (int i=0; i<N; i++){ xran[i]= new double[N]; } for (int i=0; i<N; i++) { for(int j=0;j<N; j++) { double a=0; xran[i][j]= a;} } for (int i=0;i<N; i++) { for ( int j=0; j<N; j++) { xran[i][j]=exp(-alpha*sqrt( (x[i]-x[j]) * (x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) )); myfile << xran [i][j]<< " "; } myfile<<endl; } for (int i=0; i<N; i++){ delete [] xran[i];} delete [] xran; } Thanks GH |
Registered Member
|
There is no easy way to go from a "2D pointer" to an Eigen matrix. Eigen matrices store the matrix entries in one big array. Depending on your situation, you can take these approaches:
|
Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]