Call matrix to fix into eigen matrix

I am computing eigenvalue and eigenvector for large matrix, then I found Eigen to solve the problem, however , my matrix is MX[i][j],how can i call my matrix into Eigen. I am new to C++ and Eigen.


#include <stdio.h>
#include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
#include <math.h>
#include <conio.h>//define getch
#include <ioManip>
#include <fstreaM>
#define KMAX 2
#define M ((KMAX+1)*(KMAX+2))/2



using namespace std;
using namespace Eigen;

int main()
{
int k = 1, L = 0, A = 0, i, j, m, e;
int z = 1, R = 0, C = 0; //variable for Q
int B = 0, T = 0, c = 1, q = 1, n = 0; // variable for diagonal
double P[KMAX];
double Q[KMAX];
double S[KMAX];
double MX[M][M];
double MA[M][M];
double W[M+1][M+1];
double D[M + 1][M + 1];
double Matrix[M + 1][M + 1];
double I[M + 1][M + 1];
double p = 0.95;
double a1 = 20.79, a2 = 0.005;
int V = 3, KM = 5;
cout.setf(ios::fixed);
cout.precision(3);

for (i = 0; i <= M; i++)//matrix 0
for (j = 0; j <= M; j++)
MX[i][j] = 0;
MA[i][j] = 0;


for (i = 1; i <= KMAX; i++)// kiraan untuk P
{
P[i] = (p*V*i) / (KM + i);
Q[i] = (1 - p)*V*i / (KM + i);

//cout <<"P["<<i<<"] = "<< P[i] << "\t"<<"Q["<<i<<"] = " << Q[i] << endl;
}
//cout << endl;




for (i = KMAX; i >= 1; i--)// P in matrix
{
for (j = 1; j <= i; j++)
{
MX[j - 1 + L][KMAX + k] = P[A + 1];
//cout <<"MX["<<j-1+L<<"]["<<KMAX+k<<"] = " <<MX[j-1+L][KMAX+k]<<endl;
k++;
}
//cout<<endl;
L = k + A;
A++;

}


for (i = KMAX; i >= 1; i--)// Q in matrix
{
for (j = 1; j <= i; j++)
{
MX[j + R][KMAX + z] = Q[C + 1];
//cout <<"MX["<<j+R<<"]["<<KMAX+z<<"] = " <<MX[j+R][KMAX+z]<<endl;
z++;
}
//cout<<endl;
R = z + C;
C++;

}




for (i = KMAX + 1; i >= 1; i--)// diagonal value

{
for (j = 1; j <= i; j++)
{
MX[B + c - q][B + c - q] = -(a1*double(j - 1) + a2*double(B)*double(B)) - ((V*double(B)) / (KM + double(B)));
//cout <<"MX["<<B+c-q<<"]["<<B+c-q<<"] = "<< MX[B+c-q][B+c-q] << endl;
c++;

}
q++;
B++;
}

cout << " The matrix is : " << endl;
/*for (i = 0; i<M; i++)//matrix
{
for (j = 0; j<M; j++)
{
cout << setw(7) << MX[i][j] << " " ;

}
cout << endl;

}










_getch();
}




this is how my matrix looks like
Topic archived. No new replies allowed.