\doxysection{convergence.\+hpp}
\hypertarget{convergence_8hpp_source}{}\label{convergence_8hpp_source}\index{ginkgo/core/log/convergence.hpp@{ginkgo/core/log/convergence.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2025\ The\ Ginkgo\ authors}}
\DoxyCodeLine{00002\ \textcolor{comment}{//}}
\DoxyCodeLine{00003\ \textcolor{comment}{//\ SPDX-\/License-\/Identifier:\ BSD-\/3-\/Clause}}
\DoxyCodeLine{00004\ }
\DoxyCodeLine{00005\ \textcolor{preprocessor}{\#ifndef\ GKO\_PUBLIC\_CORE\_LOG\_CONVERGENCE\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_LOG\_CONVERGENCE\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <memory>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/log/logger.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/matrix/dense.hpp>}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <ginkgo/core/stop/criterion.hpp>}}
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ }
\DoxyCodeLine{00016\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00022\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1log}{log}}\ \{}
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00036\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ ValueType\ =\ default\_precision>}
\DoxyCodeLine{00037\ \textcolor{keyword}{class\ }Convergence\ :\ \textcolor{keyword}{public}\ Logger\ \{}
\DoxyCodeLine{00038\ \ \ \ \ GKO\_ASSERT\_SUPPORTED\_VALUE\_TYPE;}
\DoxyCodeLine{00039\ }
\DoxyCodeLine{00040\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00041\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a376a52171a2c57c0800e7f0cb9061132}{on\_criterion\_check\_completed}}(}
\DoxyCodeLine{00042\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1stop_1_1Criterion}{stop::Criterion}}*\ \doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a4d4b370ab9b3dbca1ccdb1a5cca6a728}{criterion}},\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\&\ num\_iterations,}
\DoxyCodeLine{00043\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual\_norm,}
\DoxyCodeLine{00044\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ solution,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a06d96f1ecdca6b86399173969771c3fb}{uint8}}\&\ stopping\_id,}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ set\_finalized,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<stopping\_status>}}*\ status,}
\DoxyCodeLine{00046\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ one\_changed,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ all\_stopped)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00047\ }
\DoxyCodeLine{00048\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a2fec30042868dab3d1781eef6df85484}{on\_criterion\_check\_completed}}(}
\DoxyCodeLine{00049\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1stop_1_1Criterion}{stop::Criterion}}*\ \doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a4d4b370ab9b3dbca1ccdb1a5cca6a728}{criterion}},\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\&\ num\_iterations,}
\DoxyCodeLine{00050\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual\_norm,}
\DoxyCodeLine{00051\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ implicit\_sq\_resnorm,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ solution,}
\DoxyCodeLine{00052\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a06d96f1ecdca6b86399173969771c3fb}{uint8}}\&\ stopping\_id,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ set\_finalized,}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<stopping\_status>}}*\ status,\ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ one\_changed,}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \textcolor{keywordtype}{bool}\&\ all\_stopped)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00055\ }
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_aa39eb47967814d4ae0c65cb3e1961f6f}{on\_iteration\_complete}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ \doxymbox{\hyperlink{namespacegko_1_1solver}{solver}},\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ b,}
\DoxyCodeLine{00057\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ x,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\&\ num\_iterations,}
\DoxyCodeLine{00058\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual,}
\DoxyCodeLine{00059\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ residual\_norm,}
\DoxyCodeLine{00060\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ implicit\_resnorm\_sq,}
\DoxyCodeLine{00061\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1array}{array<stopping\_status>}}*\ status,}
\DoxyCodeLine{00062\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ stopped)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00074\ \ \ \ \ GKO\_DEPRECATED(\textcolor{stringliteral}{"{}use\ single-\/parameter\ create"{}})}
\DoxyCodeLine{00075\ \ \ \ \ static\ \doxymbox{\hyperlink{namespacestd}{std}}::unique\_ptr<Convergence>\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_ab0ec7b5f1f08c7237e2181e71cf7d5ed}{create}}(}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacestd}{std}}::shared\_ptr<const\ \doxymbox{\hyperlink{classgko_1_1Executor}{Executor}}>,}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ const\ mask\_type\&\ enabled\_events\ =\ Logger::\doxymbox{\hyperlink{classgko_1_1log_1_1Logger_a7f4ac79625bd3f0287230236013f6048}{criterion\_events\_mask}}\ |}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Logger::iteration\_complete\_mask)}
\DoxyCodeLine{00079\ \ \ \ \ \{}
\DoxyCodeLine{00080\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::unique\_ptr<Convergence>(\textcolor{keyword}{new}\ Convergence(enabled\_events));}
\DoxyCodeLine{00081\ \ \ \ \ \}}
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00092\ \ \ \ \ \textcolor{keyword}{static}\ std::unique\_ptr<Convergence>\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a15e31bb09b5e56f71d4a07b87d0d6b16}{create}}(}
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ mask\_type\&\ enabled\_events\ =\ \doxymbox{\hyperlink{classgko_1_1log_1_1Logger_a7f4ac79625bd3f0287230236013f6048}{Logger::criterion\_events\_mask}}\ |}
\DoxyCodeLine{00094\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Logger::iteration\_complete\_mask)}
\DoxyCodeLine{00095\ \ \ \ \ \{}
\DoxyCodeLine{00096\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ std::unique\_ptr<Convergence>(\textcolor{keyword}{new}\ Convergence(enabled\_events));}
\DoxyCodeLine{00097\ \ \ \ \ \}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00104\ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a137eb7b867e64fdf158ddf2c0a8add60}{has\_converged}}()\ const\ noexcept\ \{\ \textcolor{keywordflow}{return}\ convergence\_status\_;\ \}}
\DoxyCodeLine{00105\ }
\DoxyCodeLine{00109\ \ \ \ \ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_ab5426d709fd7cb4e26458be3c484d8aa}{reset\_convergence\_status}}()\ \{\ this-\/>convergence\_status\_\ =\ \textcolor{keyword}{false};\ \}}
\DoxyCodeLine{00110\ }
\DoxyCodeLine{00116\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\&\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a2f047de515c4e1a4008fb01257e7187c}{get\_num\_iterations}}()\ const\ noexcept}
\DoxyCodeLine{00117\ \ \ \ \ \{}
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ num\_iterations\_;}
\DoxyCodeLine{00119\ \ \ \ \ \}}
\DoxyCodeLine{00120\ }
\DoxyCodeLine{00126\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a89ffcb30e7f32941dad8fd5b976875f4}{get\_residual}}()\ const\ noexcept\ \{\ \textcolor{keywordflow}{return}\ residual\_.get();\ \}}
\DoxyCodeLine{00127\ }
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_a99f236c3263873567d6fe12576886c57}{get\_residual\_norm}}()\ const\ noexcept}
\DoxyCodeLine{00134\ \ \ \ \ \{}
\DoxyCodeLine{00135\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ residual\_norm\_.get();}
\DoxyCodeLine{00136\ \ \ \ \ \}}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence_aea7b50cb0ca47fdf7308276e24b7e2f6}{get\_implicit\_sq\_resnorm}}()\ const\ noexcept}
\DoxyCodeLine{00144\ \ \ \ \ \{}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ implicit\_sq\_resnorm\_.get();}
\DoxyCodeLine{00146\ \ \ \ \ \}}
\DoxyCodeLine{00147\ }
\DoxyCodeLine{00148\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00156\ \ \ \ \ GKO\_DEPRECATED(\textcolor{stringliteral}{"{}use\ single-\/parameter\ constructor"{}})}
\DoxyCodeLine{00157\ \ \ \ \ explicit\ \doxymbox{\hyperlink{classgko_1_1log_1_1Convergence}{Convergence}}(}
\DoxyCodeLine{00158\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacestd}{std}}::shared\_ptr<const\ \doxymbox{\hyperlink{namespacegko}{gko}}::\doxymbox{\hyperlink{classgko_1_1Executor}{Executor}}>,}
\DoxyCodeLine{00159\ \ \ \ \ \ \ \ \ const\ mask\_type\&\ enabled\_events\ =\ \doxymbox{\hyperlink{classgko_1_1log_1_1Logger}{Logger}}::\doxymbox{\hyperlink{classgko_1_1log_1_1Logger_a7f4ac79625bd3f0287230236013f6048}{criterion\_events\_mask}}\ |}
\DoxyCodeLine{00160\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1log_1_1Logger}{Logger}}::iteration\_complete\_mask)}
\DoxyCodeLine{00161\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{classgko_1_1log_1_1Logger}{Logger}}(enabled\_events)}
\DoxyCodeLine{00162\ \ \ \ \ \{\}}
\DoxyCodeLine{00163\ }
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keyword}{explicit}\ Convergence(}
\DoxyCodeLine{00171\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ mask\_type\&\ enabled\_events\ =\ \doxymbox{\hyperlink{classgko_1_1log_1_1Logger_a7f4ac79625bd3f0287230236013f6048}{Logger::criterion\_events\_mask}}\ |}
\DoxyCodeLine{00172\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Logger::iteration\_complete\_mask)}
\DoxyCodeLine{00173\ \ \ \ \ \ \ \ \ :\ Logger(enabled\_events)}
\DoxyCodeLine{00174\ \ \ \ \ \{\}}
\DoxyCodeLine{00175\ }
\DoxyCodeLine{00176\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{keyword}{mutable}\ \textcolor{keywordtype}{bool}\ convergence\_status\_\{\textcolor{keyword}{false}\};}
\DoxyCodeLine{00178\ \ \ \ \ \textcolor{keyword}{mutable}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ num\_iterations\_\{\};}
\DoxyCodeLine{00179\ \ \ \ \ \textcolor{keyword}{mutable}\ std::unique\_ptr<LinOp>\ residual\_\{\};}
\DoxyCodeLine{00180\ \ \ \ \ \textcolor{keyword}{mutable}\ std::unique\_ptr<LinOp>\ residual\_norm\_\{\};}
\DoxyCodeLine{00181\ \ \ \ \ \textcolor{keyword}{mutable}\ std::unique\_ptr<LinOp>\ implicit\_sq\_resnorm\_\{\};}
\DoxyCodeLine{00182\ \};}
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00185\ \}\ \ \textcolor{comment}{//\ namespace\ log}}
\DoxyCodeLine{00186\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00187\ }
\DoxyCodeLine{00188\ }
\DoxyCodeLine{00189\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_LOG\_CONVERGENCE\_HPP\_}}

\end{DoxyCode}
