Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
code
pugs
Merge requests
!48
Add a static switch to choose verbosity of PCG/BiCGStab
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Add a static switch to choose verbosity of PCG/BiCGStab
feature/solvers-verbosity
into
develop
Overview
0
Commits
1
Pipelines
0
Changes
4
Merged
Stéphane Del Pino
requested to merge
feature/solvers-verbosity
into
develop
4 years ago
Overview
0
Commits
1
Pipelines
0
Changes
4
Expand
0
0
Merge request reports
Viewing commit
7b23124b
Show latest version
4 files
+
38
−
20
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
7b23124b
Add a static switch to choose verbosity of PCG/BiCGStab
· 7b23124b
Stéphane Del Pino
authored
4 years ago
src/algebra/BiCGStab.hpp
+
18
−
9
Options
@@ -5,14 +5,19 @@
#include
<iomanip>
#include
<iostream>
#include
<rang.hpp>
template
<
bool
verbose
=
true
>
struct
BiCGStab
{
template
<
typename
VectorType
,
typename
MatrixType
>
BiCGStab
(
const
VectorType
&
b
,
const
MatrixType
&
A
,
VectorType
&
x
,
const
size_t
max_iter
,
const
double
epsilon
=
1e-6
)
{
std
::
cout
<<
"- bi-conjugate gradient stabilized
\n
"
;
std
::
cout
<<
" epsilon = "
<<
epsilon
<<
'\n'
;
std
::
cout
<<
" maximum number of iterations: "
<<
max_iter
<<
'\n'
;
if
constexpr
(
verbose
)
{
std
::
cout
<<
"- bi-conjugate gradient stabilized
\n
"
;
std
::
cout
<<
" epsilon = "
<<
epsilon
<<
'\n'
;
std
::
cout
<<
" maximum number of iterations: "
<<
max_iter
<<
'\n'
;
}
VectorType
r_k_1
{
b
.
size
()};
@@ -33,10 +38,14 @@ struct BiCGStab
VectorType
r_k
{
x
.
size
()};
std
::
cout
<<
" initial residu: "
<<
resid0
<<
'\n'
;
if
constexpr
(
verbose
)
{
std
::
cout
<<
" initial residu: "
<<
resid0
<<
'\n'
;
}
for
(
size_t
i
=
1
;
i
<=
max_iter
;
++
i
)
{
std
::
cout
<<
" - iteration: "
<<
std
::
setw
(
6
)
<<
i
<<
"
\t
residu: "
<<
residu
/
resid0
<<
"
\t
absolute: "
<<
residu
<<
'\n'
;
if
constexpr
(
verbose
)
{
std
::
cout
<<
" - iteration: "
<<
std
::
setw
(
6
)
<<
i
<<
"
\t
residu: "
<<
residu
/
resid0
<<
"
\t
absolute: "
<<
residu
<<
'\n'
;
}
Ap_k
=
A
*
p_k
;
@@ -64,14 +73,14 @@ struct BiCGStab
}
if
(
residu
/
resid0
>
epsilon
)
{
std
::
cout
<<
" bi_conjugate gradient stabilized: *NOT CONVERGED*
\n
"
;
std
::
cout
<<
" bi-conjugate gradient stabilized: "
<<
rang
::
fgB
::
red
<<
"*NOT CONVERGED*"
<<
rang
::
style
::
reset
<<
'\n'
;
;
std
::
cout
<<
" - epsilon: "
<<
epsilon
<<
'\n'
;
std
::
cout
<<
" - relative residu : "
<<
residu
/
resid0
<<
'\n'
;
std
::
cout
<<
" - absolute residu : "
<<
residu
<<
'\n'
;
}
}
std
::
cout
<<
"- bi-conjugate gradient stabilized: done
\n
"
;
}
};
Loading