-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
73 lines (64 loc) · 1.45 KB
/
main.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "SDP.h"
#include "GradConj.h"
#include "Gradpo.h"
#include "Residumin.h"
#include "FOM.h"
#include <string>
#include <iostream>
#include <math.h>
using namespace Eigen;
using namespace std;
int main()
{
//initiation de test par matrice sdp
int n=12;
MatrixXd A (n,n);
VectorXd b(n);
for (int i=0; i<n; i++)
{
b[i]=i+1;
for (int j=0; j<n; j++)
{
if(i==j)
{
A(i,i)=2.;
}
else if((j==i+1) || (j==i-1) )
{
A(i,j)=-1.;
}
else
{A(i,j)=0.;}
}
}
cout<<"----------------la matrice A---------------------"<<endl;
cout<<A<<endl;
cout<<"----------------le second terme b---------------------"<<endl;
cout<<b<<endl;
cout<<"-------------------------------------"<<endl;
SDP sdp(A) ;
bool T=sdp.check () ;
//Test Arnoldi et Fom
FOM v(A,b);
MatrixXd V(n,n),H(n,n);
v.Arnoldi(b,V,H);
cout<<"----------------la matrice V---------------------"<<endl;
cout<<V<<endl;
cout<<"----------------la matrice H---------------------"<<endl;
cout<<H<<endl;
//test des méthodes gconj,gop,rm
if (T)
{
Residumin u(A,b);
VectorXd x=u.Solve();
cout<<"----------------la solution---------------------"<<endl;
cout<<x<<endl;
cout<<"--------------------le produit------------"<<endl;
cout<<A*x<<endl;
return 0 ;
}
else{
std:: cout << "la matrice n'est pas sdp"<< std::endl ;
return 0 ;
}
};