Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121358104
CG_Serial.hpp
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
Thu, Jul 10, 06:45
Size
1 KB
Mime Type
text/x-c++
Expires
Sat, Jul 12, 06:45 (2 d)
Engine
blob
Format
Raw Data
Handle
27282067
Attached To
R8929 Conjugate Gradient Solver
CG_Serial.hpp
View Options
//
// Created by shernand on 29/05/19.
//
/**
* @file CG_Serial.hpp
* @author Sergio Hernandez
* This file is part of the Conjugate Gradient Project
*
* This class implements the serial version of the Conjugate Gradient
*
*/
#ifndef CG_SERIAL_CG_SERIAL_HPP
#define CG_SERIAL_CG_SERIAL_HPP
#include <tuple>
#include <vector>
#include <string>
class
CG_Serial
{
public
:
CG_Serial
(
std
::
vector
<
double
>
const
&
matrixA
,
std
::
vector
<
double
>
const
&
vectorB
,
double
const
&
tol
,
int
const
&
maxIter
);
void
computeCG
(
std
::
vector
<
double
>
&
x_0
);
std
::
vector
<
double
>
vectorScalarMul
(
const
std
::
vector
<
double
>
&
pVector1
,
const
double
pScalar
);
std
::
vector
<
double
>
vectorVectorSum
(
const
std
::
vector
<
double
>
&
pVector1
,
const
std
::
vector
<
double
>
pVector2
);
double
vectorVectorDot
(
const
std
::
vector
<
double
>
&
pVector1
,
const
std
::
vector
<
double
>
pVector2
);
std
::
vector
<
double
>
matrixVector
(
const
std
::
vector
<
double
>
&
pMatrix
,
const
std
::
vector
<
double
>
pVector
);
void
saveVector
(
std
::
string
&
filename
);
//Getter and Setters methods
const
std
::
vector
<
double
>
&
getMatrixA
()
const
;
void
setMatrixA
(
const
std
::
vector
<
double
>
&
matrixA
);
const
std
::
vector
<
double
>
&
getVectorB
()
const
;
void
setVectorB
(
const
std
::
vector
<
double
>
&
vectorB
);
double
getTol
()
const
;
void
setTol
(
double
tol
);
int
getMaxIterations
()
const
;
void
setMaxIterations
(
int
maxIterations
);
const
std
::
vector
<
double
>
&
getSolution
()
const
;
void
setSolution
(
const
std
::
vector
<
double
>
&
vectorSolution
);
int
getNIterations
()
const
;
void
setNIterations
(
int
nIterations
);
private
:
std
::
vector
<
double
>
matrixA
;
std
::
vector
<
double
>
vectorB
;
std
::
vector
<
double
>
vectorSolution
;
int
n_iterations
;
double
tol
;
int
max_iterations
;
};
#endif
//CG_SERIAL_CG_SERIAL_HPP
Event Timeline
Log In to Comment