\doxysection{bicgstab.\+hpp}
\hypertarget{bicgstab_8hpp_source}{}\label{bicgstab_8hpp_source}\index{ginkgo/core/solver/bicgstab.hpp@{ginkgo/core/solver/bicgstab.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\_SOLVER\_BICGSTAB\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_SOLVER\_BICGSTAB\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <vector>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/array.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/exception\_helpers.hpp>}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/lin\_op.hpp>}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/math.hpp>}}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/types.hpp>}}
\DoxyCodeLine{00016\ \textcolor{preprocessor}{\#include\ <ginkgo/core/config/config.hpp>}}
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#include\ <ginkgo/core/config/registry.hpp>}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#include\ <ginkgo/core/log/logger.hpp>}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#include\ <ginkgo/core/matrix/dense.hpp>}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#include\ <ginkgo/core/matrix/identity.hpp>}}
\DoxyCodeLine{00021\ \textcolor{preprocessor}{\#include\ <ginkgo/core/solver/solver\_base.hpp>}}
\DoxyCodeLine{00022\ \textcolor{preprocessor}{\#include\ <ginkgo/core/stop/combined.hpp>}}
\DoxyCodeLine{00023\ \textcolor{preprocessor}{\#include\ <ginkgo/core/stop/criterion.hpp>}}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00032\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1solver}{solver}}\ \{}
\DoxyCodeLine{00033\ }
\DoxyCodeLine{00034\ }
\DoxyCodeLine{00050\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ ValueType\ =\ default\_precision>}
\DoxyCodeLine{00051\ \textcolor{keyword}{class\ }Bicgstab}
\DoxyCodeLine{00052\ \ \ \ \ :\ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1EnableLinOp}{EnableLinOp}}<Bicgstab<ValueType>>,}
\DoxyCodeLine{00053\ \ \ \ \ \ \ \textcolor{keyword}{public}\ EnablePreconditionedIterativeSolver<ValueType,}
\DoxyCodeLine{00054\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Bicgstab<ValueType>>,}
\DoxyCodeLine{00055\ \ \ \ \ \ \ \textcolor{keyword}{public}\ \doxymbox{\hyperlink{classgko_1_1Transposable}{Transposable}}\ \{}
\DoxyCodeLine{00056\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1EnableLinOp}{EnableLinOp}}<Bicgstab>;}
\DoxyCodeLine{00057\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1EnablePolymorphicObject}{EnablePolymorphicObject}}<Bicgstab,\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}>;}
\DoxyCodeLine{00058\ \ \ \ \ GKO\_ASSERT\_SUPPORTED\_VALUE\_TYPE;}
\DoxyCodeLine{00059\ }
\DoxyCodeLine{00060\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keyword}{using\ }value\_type\ =\ ValueType;}
\DoxyCodeLine{00062\ \ \ \ \ \textcolor{keyword}{using\ }transposed\_type\ =\ Bicgstab<ValueType>;}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00064\ \ \ \ \ std::unique\_ptr<LinOp>\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab_a4d68ba2d33268ac365c962aa6ac2c813}{transpose}}()\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00065\ }
\DoxyCodeLine{00066\ \ \ \ \ std::unique\_ptr<LinOp>\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab_a31d1878251f2ebe3002a522e149fb0db}{conj\_transpose}}()\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00067\ }
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab_a96abb4c28be80401ff646e4b1009a630}{apply\_uses\_initial\_guess}}()\textcolor{keyword}{\ const\ override\ }\{\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{true};\ \}}
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \ \ \ \ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1solver_1_1Factory}{Factory}};}
\DoxyCodeLine{00076\ \ \ \ \ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1solver_1_1Bicgstab_1_1parameters__type}{parameters\_type}}}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{structgko_1_1solver_1_1enable__preconditioned__iterative__solver__factory__parameters}{enable\_preconditioned\_iterative\_solver\_factory\_parameters}}<}
\DoxyCodeLine{00078\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ parameters\_type,\ Factory>\ \{\};}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \ \ \ \ \doxymbox{\hyperlink{group__LinOp_ga8e0af90ec2414b768266f77cedffc309}{GKO\_ENABLE\_LIN\_OP\_FACTORY}}(Bicgstab,\ parameters,\ Factory);}
\DoxyCodeLine{00081\ \ \ \ \ \doxymbox{\hyperlink{group__LinOp_ga521f65604cc4cf427dcb2ecfa49b757c}{GKO\_ENABLE\_BUILD\_METHOD}}(Factory);}
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00096\ \ \ \ \ \textcolor{keyword}{static}\ parameters\_type\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab_a3d0b65cbc30192c0301de241162ce1fb}{parse}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1pnode}{config::pnode}}\&\ config,}
\DoxyCodeLine{00097\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1registry}{config::registry}}\&\ context,}
\DoxyCodeLine{00098\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1config_1_1type__descriptor}{config::type\_descriptor}}\&\ td\_for\_child\ =}
\DoxyCodeLine{00099\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ config::make\_type\_descriptor<ValueType>());}
\DoxyCodeLine{00100\ }
\DoxyCodeLine{00101\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00102\ \ \ \ \ \textcolor{keywordtype}{void}\ apply\_impl(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ b,\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ x)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00103\ }
\DoxyCodeLine{00104\ \ \ \ \ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ VectorType>}
\DoxyCodeLine{00105\ \ \ \ \ \textcolor{keywordtype}{void}\ apply\_dense\_impl(\textcolor{keyword}{const}\ VectorType*\ b,\ VectorType*\ x)\ \textcolor{keyword}{const};}
\DoxyCodeLine{00106\ }
\DoxyCodeLine{00107\ \ \ \ \ \textcolor{keywordtype}{void}\ apply\_impl(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ alpha,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ b,\ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ beta,}
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1LinOp}{LinOp}}*\ x)\ \textcolor{keyword}{const\ override};}
\DoxyCodeLine{00109\ }
\DoxyCodeLine{00110\ \ \ \ \ \textcolor{keyword}{explicit}\ Bicgstab(std::shared\_ptr<const\ Executor>\ exec)}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{classgko_1_1EnableLinOp}{EnableLinOp}}<Bicgstab>(\doxymbox{\hyperlink{namespacestd}{std}}::move(exec))}
\DoxyCodeLine{00112\ \ \ \ \ \{\}}
\DoxyCodeLine{00113\ }
\DoxyCodeLine{00114\ \ \ \ \ \textcolor{keyword}{explicit}\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{Bicgstab}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Factory}{Factory}}*\ factory,}
\DoxyCodeLine{00115\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ LinOp>\ system\_matrix)}
\DoxyCodeLine{00116\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{classgko_1_1EnableLinOp}{EnableLinOp}}<\doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{Bicgstab}}>(factory-\/>get\_executor(),}
\DoxyCodeLine{00117\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko}{gko}}::\doxymbox{\hyperlink{namespacegko_aacad7f87b38d3f26674ed034d442a1a0}{transpose}}(system\_matrix-\/>get\_size())),}
\DoxyCodeLine{00118\ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1solver_1_1EnablePreconditionedIterativeSolver}{EnablePreconditionedIterativeSolver}}<ValueType,\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{Bicgstab}}<ValueType>>\{}
\DoxyCodeLine{00119\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::move(system\_matrix),\ factory-\/>get\_parameters()\},}
\DoxyCodeLine{00120\ \ \ \ \ \ \ \ \ \ \ parameters\_\{factory-\/>get\_parameters()\}}
\DoxyCodeLine{00121\ \ \ \ \ \{\}}
\DoxyCodeLine{00122\ \};}
\DoxyCodeLine{00123\ }
\DoxyCodeLine{00124\ }
\DoxyCodeLine{00125\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ ValueType>}
\DoxyCodeLine{00126\ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1solver_1_1workspace__traits}{workspace\_traits}}<\doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{Bicgstab}}<ValueType>>\ \{}
\DoxyCodeLine{00127\ \ \ \ \ \textcolor{keyword}{using\ }Solver\ =\ \doxymbox{\hyperlink{classgko_1_1solver_1_1Bicgstab}{Bicgstab<ValueType>}};}
\DoxyCodeLine{00128\ \ \ \ \ \textcolor{comment}{//\ number\ of\ vectors\ used\ by\ this\ workspace}}
\DoxyCodeLine{00129\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ num\_vectors(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00130\ \ \ \ \ \textcolor{comment}{//\ number\ of\ arrays\ used\ by\ this\ workspace}}
\DoxyCodeLine{00131\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ num\_arrays(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00132\ \ \ \ \ \textcolor{comment}{//\ array\ containing\ the\ num\_vectors\ names\ for\ the\ workspace\ vectors}}
\DoxyCodeLine{00133\ \ \ \ \ \textcolor{keyword}{static}\ std::vector<std::string>\ op\_names(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00134\ \ \ \ \ \textcolor{comment}{//\ array\ containing\ the\ num\_arrays\ names\ for\ the\ workspace\ vectors}}
\DoxyCodeLine{00135\ \ \ \ \ \textcolor{keyword}{static}\ std::vector<std::string>\ array\_names(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00136\ \ \ \ \ \textcolor{comment}{//\ array\ containing\ all\ varying\ scalar\ vectors\ (independent\ of\ problem\ size)}}
\DoxyCodeLine{00137\ \ \ \ \ \textcolor{keyword}{static}\ std::vector<int>\ scalars(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00138\ \ \ \ \ \textcolor{comment}{//\ array\ containing\ all\ varying\ vectors\ (dependent\ on\ problem\ size)}}
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keyword}{static}\ std::vector<int>\ vectors(\textcolor{keyword}{const}\ Solver\&);}
\DoxyCodeLine{00140\ }
\DoxyCodeLine{00141\ \ \ \ \ \textcolor{comment}{//\ residual\ vector}}
\DoxyCodeLine{00142\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ r\ =\ 0;}
\DoxyCodeLine{00143\ \ \ \ \ \textcolor{comment}{//\ preconditioned\ residual\ vector}}
\DoxyCodeLine{00144\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ z\ =\ 1;}
\DoxyCodeLine{00145\ \ \ \ \ \textcolor{comment}{//\ y\ vector}}
\DoxyCodeLine{00146\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ y\ =\ 2;}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{comment}{//\ v\ vector}}
\DoxyCodeLine{00148\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ v\ =\ 3;}
\DoxyCodeLine{00149\ \ \ \ \ \textcolor{comment}{//\ s\ vector}}
\DoxyCodeLine{00150\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ s\ =\ 4;}
\DoxyCodeLine{00151\ \ \ \ \ \textcolor{comment}{//\ t\ vector}}
\DoxyCodeLine{00152\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ t\ =\ 5;}
\DoxyCodeLine{00153\ \ \ \ \ \textcolor{comment}{//\ p\ vector}}
\DoxyCodeLine{00154\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ p\ =\ 6;}
\DoxyCodeLine{00155\ \ \ \ \ \textcolor{comment}{//\ rr\ vector}}
\DoxyCodeLine{00156\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ rr\ =\ 7;}
\DoxyCodeLine{00157\ \ \ \ \ \textcolor{comment}{//\ alpha\ scalar}}
\DoxyCodeLine{00158\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ alpha\ =\ 8;}
\DoxyCodeLine{00159\ \ \ \ \ \textcolor{comment}{//\ beta\ scalar}}
\DoxyCodeLine{00160\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ beta\ =\ 9;}
\DoxyCodeLine{00161\ \ \ \ \ \textcolor{comment}{//\ gamma\ scalar}}
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ gamma\ =\ 10;}
\DoxyCodeLine{00163\ \ \ \ \ \textcolor{comment}{//\ previous\ rho\ scalar}}
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ prev\_rho\ =\ 11;}
\DoxyCodeLine{00165\ \ \ \ \ \textcolor{comment}{//\ current\ rho\ scalar}}
\DoxyCodeLine{00166\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ rho\ =\ 12;}
\DoxyCodeLine{00167\ \ \ \ \ \textcolor{comment}{//\ omega\ scalar}}
\DoxyCodeLine{00168\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ omega\ =\ 13;}
\DoxyCodeLine{00169\ \ \ \ \ \textcolor{comment}{//\ constant\ 1.0\ scalar}}
\DoxyCodeLine{00170\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ one\ =\ 14;}
\DoxyCodeLine{00171\ \ \ \ \ \textcolor{comment}{//\ constant\ -\/1.0\ scalar}}
\DoxyCodeLine{00172\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ minus\_one\ =\ 15;}
\DoxyCodeLine{00173\ }
\DoxyCodeLine{00174\ \ \ \ \ \textcolor{comment}{//\ stopping\ status\ array}}
\DoxyCodeLine{00175\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ stop\ =\ 0;}
\DoxyCodeLine{00176\ \ \ \ \ \textcolor{comment}{//\ reduction\ tmp\ array}}
\DoxyCodeLine{00177\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ tmp\ =\ 1;}
\DoxyCodeLine{00178\ \};}
\DoxyCodeLine{00179\ }
\DoxyCodeLine{00180\ }
\DoxyCodeLine{00181\ \}\ \ \textcolor{comment}{//\ namespace\ solver}}
\DoxyCodeLine{00182\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00183\ }
\DoxyCodeLine{00184\ }
\DoxyCodeLine{00185\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_SOLVER\_BICGSTAB\_HPP\_}}

\end{DoxyCode}
