Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F65560288
main.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 4, 16:57
Size
738 B
Mime Type
text/x-c
Expires
Thu, Jun 6, 16:57 (2 d)
Engine
blob
Format
Raw Data
Handle
18065766
Attached To
R7934 PCSC_project
main.cpp
View Options
#include <iostream>
#include <cassert>
#include <cmath>
#include "Functions.hpp"
#include "Conjugate_gradient.hpp"
int
main
(
int
argc
,
char
*
argv
[]){
int
size
=
2
;
double
**
A
=
AllocateMemory
(
size
,
size
);
double
*
b
=
AllocateMemory
(
size
);
double
*
x_0
=
AllocateMemory
(
size
);
A
[
0
][
0
]
=
4
;
A
[
0
][
1
]
=
1
;
A
[
1
][
0
]
=
1
;
A
[
1
][
1
]
=
3
;
b
[
0
]
=
1
;
b
[
1
]
=
2
;
x_0
[
0
]
=
2
;
x_0
[
1
]
=
1
;
std
::
cout
<<
"Matrix A:"
<<
std
::
endl
;
TerminalPrint
(
A
,
size
,
size
);
std
::
cout
<<
"Vector b:"
<<
std
::
endl
;
TerminalPrint
(
b
,
size
);
Conjugate_Gradient
linsys
(
A
,
b
,
x_0
,
size
);
std
::
cout
<<
"Solution of system is :
\n
"
;
TerminalPrint
(
linsys
.
Solve
(),
size
);
std
::
cout
<<
"Number of iterations needed :
\n
"
<<
linsys
.
n_iter
<<
std
::
endl
;
return
0
;
}
Event Timeline
Log In to Comment