\doxysection{sor.\+hpp}
\hypertarget{sor_8hpp_source}{}\label{sor_8hpp_source}\index{ginkgo/core/preconditioner/sor.hpp@{ginkgo/core/preconditioner/sor.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\_PRECONDITIONER\_SOR\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_PRECONDITIONER\_SOR\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <vector>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/abstract\_factory.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/composition.hpp>}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/lin\_op.hpp>}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/polymorphic\_object.hpp>}}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ <ginkgo/core/config/config.hpp>}}
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00017\ }
\DoxyCodeLine{00018\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00019\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1preconditioner}{preconditioner}}\ \{}
\DoxyCodeLine{00020\ }
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00050\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ ValueType\ =\ default\_precision,\ \textcolor{keyword}{typename}\ IndexType\ =\ \textcolor{keywordtype}{int}32>}
\DoxyCodeLine{00051\ \textcolor{keyword}{class\ }Sor}
\DoxyCodeLine{00052\ \ \ \ \ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<Sor<ValueType,\ IndexType>,\ LinOpFactory>,}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1EnablePolymorphicAssignment}{EnablePolymorphicAssignment}}<Sor<ValueType,\ IndexType>>\ \{}
\DoxyCodeLine{00054\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<Sor,\ \doxymbox{\hyperlink{classgko_1_1LinOpFactory}{LinOpFactory}}>;}
\DoxyCodeLine{00055\ \ \ \ \ GKO\_ASSERT\_SUPPORTED\_VALUE\_AND\_INDEX\_TYPE;}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00057\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00058\ \ \ \ \ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}};}
\DoxyCodeLine{00059\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1enable__parameters__type}{enable\_parameters\_type}}<\doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}},\ Sor>;}
\DoxyCodeLine{00060\ }
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keyword}{using\ }value\_type\ =\ ValueType;}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keyword}{using\ }index\_type\ =\ IndexType;}
\DoxyCodeLine{00063\ \ \ \ \ \textcolor{keyword}{using\ }composition\_type\ =\ \doxymbox{\hyperlink{classgko_1_1Composition}{Composition<ValueType>}};}
\DoxyCodeLine{00064\ }
\DoxyCodeLine{00065\ \ \ \ \ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}}}
\DoxyCodeLine{00066\ \ \ \ \ \ \ \ \ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1enable__parameters__type}{enable\_parameters\_type}}<parameters\_type,\ Sor>\ \{}
\DoxyCodeLine{00067\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ skip\ sorting\ of\ input\ matrix}}
\DoxyCodeLine{00068\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{group__LinOp_ga49d4c09c39f06b22bebbbfd1d8bfe450}{GKO\_FACTORY\_PARAMETER\_SCALAR}}(skip\_sorting,\ \textcolor{keyword}{false});}
\DoxyCodeLine{00069\ }
\DoxyCodeLine{00070\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ determines\ if\ SOR\ or\ SSOR\ should\ be\ used}}
\DoxyCodeLine{00071\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{group__LinOp_ga49d4c09c39f06b22bebbbfd1d8bfe450}{GKO\_FACTORY\_PARAMETER\_SCALAR}}(symmetric,\ \textcolor{keyword}{false});}
\DoxyCodeLine{00072\ }
\DoxyCodeLine{00073\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ has\ to\ be\ between\ 0.0\ and\ 2.0}}
\DoxyCodeLine{00074\ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<value\_type>}}\ \doxymbox{\hyperlink{group__LinOp_ga49d4c09c39f06b22bebbbfd1d8bfe450}{GKO\_FACTORY\_PARAMETER\_SCALAR}}(}
\DoxyCodeLine{00075\ \ \ \ \ \ \ \ \ \ \ \ \ relaxation\_factor,\ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<value\_type>}}(1.2));}
\DoxyCodeLine{00076\ }
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ factory\ for\ the\ lower\ triangular\ factor\ solver,\ defaults\ to\ LowerTrs}}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ LinOpFactory>\ GKO\_DEFERRED\_FACTORY\_PARAMETER(}
\DoxyCodeLine{00079\ \ \ \ \ \ \ \ \ \ \ \ \ l\_solver);}
\DoxyCodeLine{00080\ }
\DoxyCodeLine{00081\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ factory\ for\ the\ upper\ triangular\ factor\ solver,\ unused\ if\ symmetric}}
\DoxyCodeLine{00082\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ is\ false,\ defaults\ to\ UpperTrs}}
\DoxyCodeLine{00083\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ LinOpFactory>\ GKO\_DEFERRED\_FACTORY\_PARAMETER(}
\DoxyCodeLine{00084\ \ \ \ \ \ \ \ \ \ \ \ \ u\_solver);}
\DoxyCodeLine{00085\ \ \ \ \ \};}
\DoxyCodeLine{00086\ }
\DoxyCodeLine{00092\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}}\&\ \doxymbox{\hyperlink{classgko_1_1preconditioner_1_1Sor_a026946b410cd5a3d64482e85c4e7e2e8}{get\_parameters}}()\ \{\ \textcolor{keywordflow}{return}\ parameters\_;\ \}}
\DoxyCodeLine{00093\ }
\DoxyCodeLine{00097\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}}\&\ \doxymbox{\hyperlink{classgko_1_1preconditioner_1_1Sor_a2b16cf310c09bf80e9915521c6224f60}{get\_parameters}}()\textcolor{keyword}{\ const\ }\{\ \textcolor{keywordflow}{return}\ parameters\_;\ \}}
\DoxyCodeLine{00098\ }
\DoxyCodeLine{00106\ \ \ \ \ std::unique\_ptr<composition\_type>\ \doxymbox{\hyperlink{classgko_1_1preconditioner_1_1Sor_a815786e2fe73cf8640cf9823dec59b7c}{generate}}(}
\DoxyCodeLine{00107\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ LinOp>\ system\_matrix)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00108\ }
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{keyword}{static}\ \doxymbox{\hyperlink{structgko_1_1preconditioner_1_1Sor_1_1parameters__type}{parameters\_type}}\ \doxymbox{\hyperlink{classgko_1_1preconditioner_1_1Sor_a23c746f50487fe2824c3957995645099}{build}}()\ \{\ \textcolor{keywordflow}{return}\ \{\};\ \}}
\DoxyCodeLine{00111\ }
\DoxyCodeLine{00112\ \ \ \ \ \textcolor{keyword}{static}\ parameters\_type\ parse(}
\DoxyCodeLine{00113\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1pnode}{config::pnode}}\&\ config,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1registry}{config::registry}}\&\ context,}
\DoxyCodeLine{00114\ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1type__descriptor}{config::type\_descriptor}}\&\ td\_for\_child\ =}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ \ \ \ \ config::make\_type\_descriptor<ValueType,\ IndexType>());}
\DoxyCodeLine{00116\ }
\DoxyCodeLine{00117\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00118\ \ \ \ \ \textcolor{keyword}{explicit}\ \doxymbox{\hyperlink{classgko_1_1preconditioner_1_1Sor}{Sor}}(std::shared\_ptr<const\ Executor>\ exec,}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ parameters\_type\&\ params\ =\ \{\})}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<Sor,\ \doxymbox{\hyperlink{classgko_1_1LinOpFactory}{LinOpFactory}}>(exec),\ parameters\_(params)}
\DoxyCodeLine{00121\ \ \ \ \ \{}
\DoxyCodeLine{00122\ \ \ \ \ \ \ \ \ GKO\_ASSERT(parameters\_.relaxation\_factor\ >\ 0.0\ \&\&}
\DoxyCodeLine{00123\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ parameters\_.relaxation\_factor\ <\ 2.0);}
\DoxyCodeLine{00124\ \ \ \ \ \}}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00126\ \ \ \ \ std::unique\_ptr<LinOp>\ generate\_impl(}
\DoxyCodeLine{00127\ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ LinOp>\ system\_matrix)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00128\ }
\DoxyCodeLine{00129\ \textcolor{keyword}{private}:}
\DoxyCodeLine{00130\ \ \ \ \ parameters\_type\ parameters\_;}
\DoxyCodeLine{00131\ \};}
\DoxyCodeLine{00132\ \}\ \ \textcolor{comment}{//\ namespace\ preconditioner}}
\DoxyCodeLine{00133\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00134\ }
\DoxyCodeLine{00135\ }
\DoxyCodeLine{00136\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_PRECONDITIONER\_SOR\_HPP\_}}

\end{DoxyCode}
