-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdsyev_example.cpp
More file actions
42 lines (35 loc) · 822 Bytes
/
dsyev_example.cpp
File metadata and controls
42 lines (35 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include "myLapack.h"
int main(){
int dim = 3;
double * Matrix;
double * EigVec;
double * Eig;
EigVec = new double[dim*dim];
Eig = new double[dim];
Matrix = new double[dim*dim];
std::fill(Matrix, Matrix+dim*dim, 0.0e0);
Matrix[0]=0.0;
Matrix[1]=-1.0;
Matrix[2]=0.0;
Matrix[3]=-1.0;
Matrix[4]=0.0;
Matrix[5]=-1.0;
Matrix[6]=0.0;
Matrix[7]=-1.0;
Matrix[8]=0.0;
Diag(Matrix, dim, Eig, EigVec);
printf("Eigenvalues\n");
for (int i=0; i < dim; i++) printf(" %17.10e ", Eig[i]);
printf("\n\n");
printf("Eigenvectors\n");
for (int i=0; i < dim; i++)
{
for (int j=0; j < dim; j++)
{
printf(" %17.10e ", EigVec[j*dim+i]);
}
printf("\n");
}
printf("\n");
}