\chapter{The inverse-\/iteration program }
\hypertarget{inverse_iteration}{}\label{inverse_iteration}\index{The inverse-\/iteration program@{The inverse-\/iteration program}}
The inverse iteration example.

This example depends on simple-\/solver, .

 \label{three_pt_stencil_solver_Intro}%
\Hypertarget{three_pt_stencil_solver_Intro}%
 \label{three_pt_stencil_solver_Introduction}%
\Hypertarget{three_pt_stencil_solver_Introduction}%
\doxysection*{Introduction}

This example shows how components available in Ginkgo can be used to implement higher-\/level numerical methods. The method used here will be the shifted inverse iteration method for eigenvalue computation which find the eigenvalue and eigenvector of A closest to z, for some scalar z. The method requires repeatedly solving the shifted linear system (A -\/ zI)x = b, as well as performing matrix-\/vector products with the matrix {\ttfamily A}. Here is the complete pseudocode of the method:\+


\begin{DoxyCode}{0}
\DoxyCodeLine{x\_0\ =\ initial\ guess}
\DoxyCodeLine{\textcolor{keywordflow}{for}\ i\ =\ 0\ ..\ max\_iterations:}
\DoxyCodeLine{\ \ \ \ solve\ (A\ -\/\ zI)\ y\_i\ =\ x\_i\ \textcolor{keywordflow}{for}\ y\_i+1}
\DoxyCodeLine{\ \ \ \ x\_(i+1)\ =\ y\_i\ /\ ||\ y\_i\ ||\ \ \ \ \ \ \#\ compute\ next\ eigenvector\ approximation}
\DoxyCodeLine{\ \ \ \ g\_(i+1)\ =\ x\_(i+1)\string^*\ A\ x\_(i+1)\ \ \textcolor{preprocessor}{\#\ approximate\ eigenvalue\ (Rayleigh\ quotient)}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}\ ||A\ x\_(i+1)\ -\/\ g\_(i+1)x\_(i+1)||\ <\ tol\ *\ g\_(i+1):\ \ \textcolor{preprocessor}{\#\ check\ convergence}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{break}}

\end{DoxyCode}


\label{three_pt_stencil_solver_Abouttheexample}%
\Hypertarget{three_pt_stencil_solver_Abouttheexample}%
\doxysubsubsection*{About the example }

\label{three_pt_stencil_solver_CommProg}%
\Hypertarget{three_pt_stencil_solver_CommProg}%
 \doxysection*{The commented program}

Figure out where to run the code


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keywordflow}{if}\ (argc\ ==\ 2\ \&\&\ (std::string(argv[1])\ ==\ \textcolor{stringliteral}{"{}-\/-\/help"{}}))\ \{}
\DoxyCodeLine{\ \ \ \ std::cerr\ <<\ \textcolor{stringliteral}{"{}Usage:\ "{}}\ <<\ argv[0]\ <<\ \textcolor{stringliteral}{"{}\ [executor]"{}}\ <<\ std::endl;}
\DoxyCodeLine{\ \ \ \ std::exit(-\/1);}
\DoxyCodeLine{\}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ executor\_string\ =\ argc\ >=\ 2\ ?\ argv[1]\ :\ \textcolor{stringliteral}{"{}reference"{}};}
\DoxyCodeLine{std::map<std::string,\ std::function<std::shared\_ptr<gko::Executor>()>>}
\DoxyCodeLine{\ \ \ \ exec\_map\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}omp"{}},\ []\ \{\ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}();\ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}cuda"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1CudaExecutor_a075a1957241de65c0cad59f9534430a2}{gko::CudaExecutor::create}}(0,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}hip"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1HipExecutor_a8afc5210bf8dd8aedfceab4b73f0047b}{gko::HipExecutor::create}}(0,\ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}dpcpp"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1DpcppExecutor_af69a356ee07f641010df5d2e9e518bb0}{gko::DpcppExecutor::create}}(0,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}reference"{}},\ []\ \{\ \textcolor{keywordflow}{return}\ gko::ReferenceExecutor::create();\ \}\}\};}

\end{DoxyCode}


executor where Ginkgo will perform the computation


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ exec\ =\ exec\_map.at(executor\_string)();\ \ \textcolor{comment}{//\ throws\ if\ not\ valid}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{auto}\ this\_exec\ =\ exec-\/>get\_master();}

\end{DoxyCode}


linear system solver parameters


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ system\_max\_iterations\ =\ 100u;}
\DoxyCodeLine{\textcolor{keyword}{auto}\ system\_residual\_goal\ =\ real\_precision\{1e-\/16\};}

\end{DoxyCode}


eigensolver parameters


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ max\_iterations\ =\ 20u;}
\DoxyCodeLine{\textcolor{keyword}{auto}\ residual\_goal\ =\ real\_precision\{1e-\/8\};}
\DoxyCodeLine{\textcolor{keyword}{auto}\ z\ =\ precision\{20.0,\ 2.0\};}

\end{DoxyCode}


Read data


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ A\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{namespacegko_abc58509ecdcb48399e12f9a081ed7545}{gko::read<mtx>}}(std::ifstream(\textcolor{stringliteral}{"{}data/A.mtx"{}}),\ exec));}

\end{DoxyCode}


Generate shifted matrix A -\/ zI
\begin{DoxyItemize}
\item we avoid duplicating memory by not storing both A and A -\/ zI, but compute A -\/ zI on the fly by using Ginkgo\textquotesingle{}s utilities for creating linear combinations of operators
\end{DoxyItemize}


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one}}\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{precision\{1.0\}\},\ exec));}
\DoxyCodeLine{\textcolor{keyword}{auto}\ neg\_one\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/precision\{1.0\}\},\ exec));}
\DoxyCodeLine{\textcolor{keyword}{auto}\ neg\_z\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/z\},\ exec);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keyword}{auto}\ system\_matrix\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(gko::Combination<precision>::create(}
\DoxyCodeLine{\ \ \ \ one,\ A,\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/z\},\ exec),}
\DoxyCodeLine{\ \ \ \ \doxymbox{\hyperlink{classgko_1_1matrix_1_1Identity_a55417b971157946c8f5f4f8d30b11aba}{gko::matrix::Identity<precision>::create}}(exec,\ A-\/>get\_size()[0])));}

\end{DoxyCode}


Generate solver operator (A -\/ zI)\texorpdfstring{$^\wedge$}{\string^}-\/1


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a7cbf673200498a0d1324f4330825202a}{solver}}\ =}
\DoxyCodeLine{\ \ \ \ solver\_type::build()}
\DoxyCodeLine{\ \ \ \ \ \ \ \ .with\_criteria(gko::stop::Iteration::build().with\_max\_iters(}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ system\_max\_iterations),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ gko::stop::ResidualNorm<precision>::build()}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ .with\_reduction\_factor(system\_residual\_goal))}
\DoxyCodeLine{\ \ \ \ \ \ \ \ .on(exec)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ -\/>generate(system\_matrix);}

\end{DoxyCode}


inverse iterations

start with guess \+[1, 1, ..., 1]\+


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ x\ =\ [\&]\ \{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ work\ =\ vec::create(this\_exec,\ \doxymbox{\hyperlink{structgko_1_1dim}{gko::dim<2>}}\{A-\/>get\_size()[0],\ 1\});}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ n\ =\ work-\/>get\_size()[0];}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ n;\ ++i)\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ work-\/>get\_values()[i]\ =\ precision\{1.0\}\ /\ sqrt(n);}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec,\ work);}
\DoxyCodeLine{\}();}
\DoxyCodeLine{\textcolor{keyword}{auto}\ y\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(x);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ tmp\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(x);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ norm\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<real\_vec>}}(\{1.0\},\ exec);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ inv\_norm\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ one);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ g\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(one);}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ i\ =\ 0u;\ i\ <\ max\_iterations;\ ++i)\ \{}
\DoxyCodeLine{\ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\{\ "{}};}

\end{DoxyCode}


(A -\/ zI)y = x


\begin{DoxyCode}{0}
\DoxyCodeLine{\doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a7cbf673200498a0d1324f4330825202a}{solver}}-\/>apply(x,\ y);}
\DoxyCodeLine{system\_matrix-\/>apply(one,\ y,\ neg\_one,\ x);}
\DoxyCodeLine{x-\/>compute\_norm2(norm);}
\DoxyCodeLine{std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}system\_residual\(\backslash\)"{}:\ "{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ <<\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ norm)-\/>get\_values()[0]\ <<\ \textcolor{stringliteral}{"{},\ "{}};}
\DoxyCodeLine{x-\/>copy\_from(y);}

\end{DoxyCode}


x = y /\+ \texorpdfstring{$\vert$}{|}\texorpdfstring{$\vert$}{|} y \texorpdfstring{$\vert$}{|}\texorpdfstring{$\vert$}{|}


\begin{DoxyCode}{0}
\DoxyCodeLine{x-\/>compute\_norm2(norm);}
\DoxyCodeLine{inv\_norm-\/>get\_values()[0]\ =}
\DoxyCodeLine{\ \ \ \ real\_precision\{1.0\}\ /\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ norm)-\/>get\_values()[0];}
\DoxyCodeLine{x-\/>scale(\doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec,\ inv\_norm));}

\end{DoxyCode}


g = x\texorpdfstring{$^\wedge$}{\string^}\texorpdfstring{$\ast$}{*} A x


\begin{DoxyCode}{0}
\DoxyCodeLine{A-\/>apply(x,\ tmp);}
\DoxyCodeLine{x-\/>compute\_conj\_dot(tmp,\ g);}
\DoxyCodeLine{\textcolor{keyword}{auto}\ g\_val\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ g)-\/>get\_values()[0];}
\DoxyCodeLine{std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}eigenvalue\(\backslash\)"{}:\ "{}}\ <<\ g\_val\ <<\ \textcolor{stringliteral}{"{},\ "{}};}

\end{DoxyCode}


\texorpdfstring{$\vert$}{|}\texorpdfstring{$\vert$}{|}\+Ax -\/ gx\texorpdfstring{$\vert$}{|}\texorpdfstring{$\vert$}{|} \texorpdfstring{$<$}{<} tol \texorpdfstring{$\ast$}{*} g


\begin{DoxyCode}{0}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ v\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/g\_val\},\ exec);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ tmp-\/>add\_scaled(v,\ x);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ tmp-\/>compute\_norm2(norm);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ res\_val\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec-\/>get\_master(),\ norm)-\/>get\_values()[0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}residual\(\backslash\)"{}:\ "{}}\ <<\ res\_val\ /\ g\_val\ <<\ \textcolor{stringliteral}{"{}\ \},"{}}\ <<\ std::endl;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(res\_val)\ <\ residual\_goal\ *\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(g\_val))\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\}}

\end{DoxyCode}
 \label{three_pt_stencil_solver_Results}%
\Hypertarget{three_pt_stencil_solver_Results}%
\doxysection*{Results}

This is the expected output:\+


\begin{DoxyCode}{0}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +1.61736920e-\/14,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+2.03741410e+01,-\/1.17744356e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+2.92231055e-\/01,+1.68883476e-\/18)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +4.98014795e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.94878474e+01,+1.25948378e-\/15),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+7.94370276e-\/02,-\/5.13395071e-\/18)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +3.39296916e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.93282121e+01,-\/1.19329332e-\/15),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+4.11149623e-\/02,+2.53837290e-\/18)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +3.35953656e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92638912e+01,+3.28657016e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+2.34717040e-\/02,-\/4.00445585e-\/19)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.91474009e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92409166e+01,+3.65597737e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+1.34709547e-\/02,-\/2.55962367e-\/19)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +3.09863953e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92331106e+01,-\/1.07919176e-\/15),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+7.72060707e-\/03,+4.33212063e-\/19)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.31198069e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92305014e+01,-\/2.89755360e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+4.42106625e-\/03,+6.66143651e-\/20)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +3.02771202e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92296339e+01,+8.04259901e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+2.53081312e-\/03,-\/1.05848687e-\/19)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.02954523e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92293461e+01,+7.81834016e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+1.44862114e-\/03,-\/5.88985854e-\/20)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.31762332e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292506e+01,-\/1.11718775e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+8.29183451e-\/04,+4.81741912e-\/21)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +8.12541038e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292190e+01,-\/6.55606254e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+4.74636702e-\/04,+1.61823936e-\/20)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.77259926e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292085e+01,+4.30588140e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+2.71701077e-\/04,-\/6.08403935e-\/21)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +8.87888675e-\/14,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292051e+01,+9.67936313e-\/18),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+1.55539937e-\/04,-\/7.82937998e-\/23)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.85077117e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292039e+01,-\/4.52923128e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+8.90457139e-\/05,+2.09737561e-\/21)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +6.46865302e-\/14,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292035e+01,+1.58710681e-\/17),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+5.09805252e-\/05,-\/4.20774259e-\/23)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +4.18913713e-\/15,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292034e+01,+1.06839590e-\/15),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+2.91887365e-\/05,-\/1.62175862e-\/21)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +1.06421578e-\/11,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292034e+01,+3.26089685e-\/17),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+1.67126561e-\/05,-\/2.83413965e-\/23)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +2.97434420e-\/13,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292034e+01,-\/7.85427712e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+9.56961199e-\/06,+3.90876227e-\/22)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +1.63230281e-\/11,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292033e+01,+3.69307000e-\/16),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+5.47975753e-\/06,-\/1.05241636e-\/22)\ \},}
\DoxyCodeLine{\{\ \textcolor{stringliteral}{"{}system\_residual"{}}:\ +6.14939758e-\/14,\ \textcolor{stringliteral}{"{}eigenvalue"{}}:\ (+1.92292033e+01,+1.36057865e-\/15),\ \textcolor{stringliteral}{"{}residual"{}}:\ (+3.13794996e-\/06,-\/2.22028320e-\/22)\ \},}

\end{DoxyCode}


\label{three_pt_stencil_solver_Commentsaboutprogramminganddebugging}%
\Hypertarget{three_pt_stencil_solver_Commentsaboutprogramminganddebugging}%
\doxysubsubsection*{Comments about programming and debugging }

\label{three_pt_stencil_solver_PlainProg}%
\Hypertarget{three_pt_stencil_solver_PlainProg}%
 \doxysection*{The plain program}


\begin{DoxyCodeInclude}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <cmath>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <complex>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <fstream>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iomanip>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <iostream>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <map>}}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <string>}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{preprocessor}{\#include\ <ginkgo/ginkgo.hpp>}}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{keywordtype}{int}\ main(\textcolor{keywordtype}{int}\ argc,\ \textcolor{keywordtype}{char}*\ argv[])}
\DoxyCodeLine{\{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }precision\ =\ std::complex<double>;}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }real\_precision\ =\ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{gko::remove\_complex<precision>}};}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }vec\ =\ \doxymbox{\hyperlink{classgko_1_1matrix_1_1Dense}{gko::matrix::Dense<precision>}};}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }real\_vec\ =\ \doxymbox{\hyperlink{classgko_1_1matrix_1_1Dense}{gko::matrix::Dense<real\_precision>}};}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }mtx\ =\ \doxymbox{\hyperlink{classgko_1_1matrix_1_1Csr}{gko::matrix::Csr<precision>}};}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }solver\_type\ =\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{gko::solver::Bicgstab<precision>}};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }std::abs;}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{using\ }std::sqrt;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ std::cout\ <<\ \doxymbox{\hyperlink{classgko_1_1version__info_ab13efac1405dd90951d2d9485acc4f30}{gko::version\_info::get}}()\ <<\ std::endl;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ std::cout\ <<\ std::scientific\ <<\ std::setprecision(8)\ <<\ std::showpos;}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{if}\ (argc\ ==\ 2\ \&\&\ (std::string(argv[1])\ ==\ \textcolor{stringliteral}{"{}-\/-\/help"{}}))\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cerr\ <<\ \textcolor{stringliteral}{"{}Usage:\ "{}}\ <<\ argv[0]\ <<\ \textcolor{stringliteral}{"{}\ [executor]"{}}\ <<\ std::endl;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::exit(-\/1);}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ executor\_string\ =\ argc\ >=\ 2\ ?\ argv[1]\ :\ \textcolor{stringliteral}{"{}reference"{}};}
\DoxyCodeLine{\ \ \ \ std::map<std::string,\ std::function<std::shared\_ptr<gko::Executor>()>>}
\DoxyCodeLine{\ \ \ \ \ \ \ \ exec\_map\{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}omp"{}},\ []\ \{\ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}();\ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}cuda"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1CudaExecutor_a075a1957241de65c0cad59f9534430a2}{gko::CudaExecutor::create}}(0,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}hip"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1HipExecutor_a8afc5210bf8dd8aedfceab4b73f0047b}{gko::HipExecutor::create}}(0,\ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}dpcpp"{}},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ []\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{classgko_1_1DpcppExecutor_af69a356ee07f641010df5d2e9e518bb0}{gko::DpcppExecutor::create}}(0,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1OmpExecutor_af977cb680e0427ca4eb71eb7b1266211}{gko::OmpExecutor::create}}());}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \}\},}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \{\textcolor{stringliteral}{"{}reference"{}},\ []\ \{\ \textcolor{keywordflow}{return}\ gko::ReferenceExecutor::create();\ \}\}\};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ exec\ =\ exec\_map.at(executor\_string)();\ \ \textcolor{comment}{//\ throws\ if\ not\ valid}}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ this\_exec\ =\ exec-\/>get\_master();}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ system\_max\_iterations\ =\ 100u;}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ system\_residual\_goal\ =\ real\_precision\{1e-\/16\};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ max\_iterations\ =\ 20u;}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ residual\_goal\ =\ real\_precision\{1e-\/8\};}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ z\ =\ precision\{20.0,\ 2.0\};}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ A\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{namespacegko_abc58509ecdcb48399e12f9a081ed7545}{gko::read<mtx>}}(std::ifstream(\textcolor{stringliteral}{"{}data/A.mtx"{}}),\ exec));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one}}\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{precision\{1.0\}\},\ exec));}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ neg\_one\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(\doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/precision\{1.0\}\},\ exec));}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ neg\_z\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/z\},\ exec);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ system\_matrix\ =\ \doxymbox{\hyperlink{namespacegko_ae99fdd8bfa5ac694adcb7297d432967e}{share}}(gko::Combination<precision>::create(}
\DoxyCodeLine{\ \ \ \ \ \ \ \ one,\ A,\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/z\},\ exec),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1matrix_1_1Identity_a55417b971157946c8f5f4f8d30b11aba}{gko::matrix::Identity<precision>::create}}(exec,\ A-\/>get\_size()[0])));}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a7cbf673200498a0d1324f4330825202a}{solver}}\ =}
\DoxyCodeLine{\ \ \ \ \ \ \ \ solver\_type::build()}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ .with\_criteria(gko::stop::Iteration::build().with\_max\_iters(}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ system\_max\_iterations),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ gko::stop::ResidualNorm<precision>::build()}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ .with\_reduction\_factor(system\_residual\_goal))}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ .on(exec)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ -\/>generate(system\_matrix);}
\DoxyCodeLine{}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ x\ =\ [\&]\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ work\ =\ vec::create(this\_exec,\ \doxymbox{\hyperlink{structgko_1_1dim}{gko::dim<2>}}\{A-\/>get\_size()[0],\ 1\});}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keyword}{auto}\ n\ =\ work-\/>get\_size()[0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keywordtype}{int}\ i\ =\ 0;\ i\ <\ n;\ ++i)\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ work-\/>get\_values()[i]\ =\ precision\{1.0\}\ /\ sqrt(n);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec,\ work);}
\DoxyCodeLine{\ \ \ \ \}();}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ y\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(x);}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ tmp\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(x);}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ norm\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<real\_vec>}}(\{1.0\},\ exec);}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ inv\_norm\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ one);}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{auto}\ g\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(one);}
\DoxyCodeLine{}
\DoxyCodeLine{\ \ \ \ \textcolor{keywordflow}{for}\ (\textcolor{keyword}{auto}\ i\ =\ 0u;\ i\ <\ max\_iterations;\ ++i)\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\{\ "{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a7cbf673200498a0d1324f4330825202a}{solver}}-\/>apply(x,\ y);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ system\_matrix-\/>apply(one,\ y,\ neg\_one,\ x);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ x-\/>compute\_norm2(norm);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}system\_residual\(\backslash\)"{}:\ "{}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ <<\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ norm)-\/>get\_values()[0]\ <<\ \textcolor{stringliteral}{"{},\ "{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ x-\/>copy\_from(y);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ x-\/>compute\_norm2(norm);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ inv\_norm-\/>get\_values()[0]\ =}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ real\_precision\{1.0\}\ /\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ norm)-\/>get\_values()[0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ x-\/>scale(\doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec,\ inv\_norm));}
\DoxyCodeLine{\ \ \ \ \ \ \ \ A-\/>apply(x,\ tmp);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ x-\/>compute\_conj\_dot(tmp,\ g);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ g\_val\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(this\_exec,\ g)-\/>get\_values()[0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}eigenvalue\(\backslash\)"{}:\ "{}}\ <<\ g\_val\ <<\ \textcolor{stringliteral}{"{},\ "{}};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ v\ =\ \doxymbox{\hyperlink{group__LinOp_ga70851b4c3c9b01bb667b3a8e438fb6d2}{gko::initialize<vec>}}(\{-\/g\_val\},\ exec);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ tmp-\/>add\_scaled(v,\ x);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ tmp-\/>compute\_norm2(norm);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keyword}{auto}\ res\_val\ =\ \doxymbox{\hyperlink{namespacegko_aa194e34282452493231ca7b01ffb5e64}{clone}}(exec-\/>get\_master(),\ norm)-\/>get\_values()[0];}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::cout\ <<\ \textcolor{stringliteral}{"{}\(\backslash\)"{}residual\(\backslash\)"{}:\ "{}}\ <<\ res\_val\ /\ g\_val\ <<\ \textcolor{stringliteral}{"{}\ \},"{}}\ <<\ std::endl;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordflow}{if}\ (\doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(res\_val)\ <\ residual\_goal\ *\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(g\_val))\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{break};}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{\ \ \ \ \}}
\DoxyCodeLine{\}}

\end{DoxyCodeInclude}
 