Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tnl-dev
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
TNL
tnl-dev
Commits
310e0425
There was an error fetching the commit references. Please try again later.
Commit
310e0425
authored
3 years ago
by
Tomáš Oberhuber
Browse files
Options
Downloads
Patches
Plain Diff
Writtin documentation for CG method.
parent
faa4166e
No related branches found
No related tags found
1 merge request
!116
Documentation for linear solvers and preconditioners
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TNL/Solvers/Linear/CG.h
+57
-16
57 additions, 16 deletions
src/TNL/Solvers/Linear/CG.h
with
57 additions
and
16 deletions
src/TNL/Solvers/Linear/CG.h
+
57
−
16
View file @
310e0425
...
...
@@ -10,35 +10,76 @@
#pragma once
#include
"
LinearSolver.h
"
#include
<TNL/Solvers/Linear/
LinearSolver.h
>
namespace
TNL
{
namespace
Solvers
{
namespace
Linear
{
namespace
Solvers
{
namespace
Linear
{
/**
* \brief Iterative solver of linear systems based on the conjugate gradient method.
*
* This solver can be used only for positive-definite linear systems.
*
* See [Wikipedia](https://en.wikipedia.org/wiki/Conjugate_gradient_method) for more details.
*
* \tparam Matrix is type of matrix describing the linear system.
*/
template
<
typename
Matrix
>
class
CG
:
public
LinearSolver
<
Matrix
>
{
using
Base
=
LinearSolver
<
Matrix
>
;
public:
using
RealType
=
typename
Base
::
RealType
;
using
DeviceType
=
typename
Base
::
DeviceType
;
using
IndexType
=
typename
Base
::
IndexType
;
using
VectorViewType
=
typename
Base
::
VectorViewType
;
using
ConstVectorViewType
=
typename
Base
::
ConstVectorViewType
;
using
VectorType
=
typename
Traits
<
Matrix
>::
VectorType
;
bool
solve
(
ConstVectorViewType
b
,
VectorViewType
x
)
override
;
public:
/**
* \brief Floating point type used for computations.
*/
using
RealType
=
typename
Base
::
RealType
;
protected:
void
setSize
(
const
VectorViewType
&
x
);
/**
* \brief Device where the solver will run on and auxillary data will alloacted on.
*
* See \ref Devices::Host or \ref Devices::Cuda.
*/
using
DeviceType
=
typename
Base
::
DeviceType
;
VectorType
r
,
p
,
Ap
,
z
;
/**
* \brief Type for indexing.
*/
using
IndexType
=
typename
Base
::
IndexType
;
/**
* \brief Type for vector view.
*/
using
VectorViewType
=
typename
Base
::
VectorViewType
;
/**
* \brief Type for constant vector view.
*/
using
ConstVectorViewType
=
typename
Base
::
ConstVectorViewType
;
/**
* \brief Method for solving of a linear system.
*
* See \ref LinearSolver::solve for more details.
*
* \param b vector with the right-hand side of the linear system.
* \param x vector for the solution of the linear system.
* \return true if the solver converged.
* \return false if the solver did not converge.
*/
bool
solve
(
ConstVectorViewType
b
,
VectorViewType
x
)
override
;
protected:
void
setSize
(
const
VectorViewType
&
x
);
VectorType
r
,
p
,
Ap
,
z
;
};
}
// namespace Linear
}
// namespace Solvers
}
// namespace Linear
}
// namespace Solvers
}
// namespace TNL
#include
"
CG.hpp
"
#include
<TNL/Solvers/Linear/
CG.hpp
>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment