310 Introduction to C++ Programming and Graphics
mxArray * Eigv = engGetVariable(bouboulina, "V");
double * V = mxGetPr(Eigv);
//--- Define the real (EVR) and imaginary (EVI) parts
//--- of the eigenvalue matrix:
double EVR[N][N];
double EVI[N][N];
int Ic=-1, Jc;
for (int j=0; j<=N-1; j++)
{
for (int i=0; i<=N-1; i++)
{
Ic=Ic+1;
EVR[i][j]=V[Ic];
Jc = Ic+N*N;
EVI[i][j]=V[Jc];
}
}
//--- Print the real part of the eigenvector matrix:
cout << setiosflags(ios::fixed | ios::showpoint);
cout << endl;
cout << "C++ domain:" << endl << endl;
for (int i=0; i<=N-1; i++)
{
for (int j=0; j<=N-1; j++)
{
cout << setprecision(5) << setw(10) << EVR[i][j] << " ";
}
cout << endl;
}
//--- Print the imaginary part of the eigenvector matrix:
cout << endl;
for (int i=0; i<=N-1; i++)
{
for (int j=0; j<=N-1; j++)
{
cout << setprecision(5) << setw(10) << EVI[i][j] << " ";
}
cout << endl;