\doxysection{Batch\+Lin\+Op }
\hypertarget{group__BatchLinOp}{}\label{group__BatchLinOp}\index{BatchLinOp@{BatchLinOp}}
Collaboration diagram for Batch\+Lin\+Op:\+
\nopagebreak
\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=350pt]{group__BatchLinOp}
\end{center}
\end{figure}
\doxysubsubsection*{Classes}
\begin{DoxyCompactItemize}
\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1BatchLinOpFactory}{gko::\+batch::\+\+Batch\+Lin\+Op\+Factory}}
\begin{DoxyCompactList}\small\item\em A \doxylink{classgko_1_1batch_1_1BatchLinOpFactory}{Batch\+Lin\+Op\+Factory} represents a higher order mapping which transforms one batch linear operator into another. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1EnableBatchLinOp}{gko::\+batch::\+\+Enable\+Batch\+Lin\+Op$<$ Concrete\+Batch\+Lin\+Op, Polymorphic\+Base $>$}}
\begin{DoxyCompactList}\small\item\em The \doxylink{classgko_1_1batch_1_1EnableBatchLinOp}{Enable\+Batch\+Lin\+Op} mixin can be used to provide sensible default implementations of the majority of the \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} and \doxylink{classgko_1_1PolymorphicObject}{Polymorphic\+Object} interface. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Csr}{gko::\+batch::\+matrix::\+\+Csr$<$ Value\+Type, Index\+Type $>$}}
\begin{DoxyCompactList}\small\item\em \doxylink{classgko_1_1batch_1_1matrix_1_1Csr}{Csr} is a general sparse matrix format that stores the column indices for each nonzero entry and a cumulative sum of the number of nonzeros in each row. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Dense}{gko::\+batch::\+matrix::\+\+Dense$<$ Value\+Type $>$}}
\begin{DoxyCompactList}\small\item\em \doxylink{classgko_1_1batch_1_1matrix_1_1Dense}{Dense} is a batch matrix format which explicitly stores all values of the matrix in each of the batches. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Ell}{gko::\+batch::\+matrix::\+\+Ell$<$ Value\+Type, Index\+Type $>$}}
\begin{DoxyCompactList}\small\item\em \doxylink{classgko_1_1batch_1_1matrix_1_1Ell}{Ell} is a sparse matrix format that stores the same number of nonzeros in each row, enabling coalesced accesses. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Identity}{gko::\+batch::\+matrix::\+\+Identity$<$ Value\+Type $>$}}
\begin{DoxyCompactList}\small\item\em The batch \doxylink{classgko_1_1batch_1_1matrix_1_1Identity}{Identity} matrix, which represents a batch of \doxylink{classgko_1_1batch_1_1matrix_1_1Identity}{Identity} matrices. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1preconditioner_1_1Jacobi}{gko::\+batch::\+preconditioner::\+\+Jacobi$<$ Value\+Type, Index\+Type $>$}}
\begin{DoxyCompactList}\small\item\em A block-\/\+Jacobi preconditioner is a block-\/diagonal linear operator, obtained by inverting the diagonal blocks (stored in a dense row major fashion) of the source operator. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1solver_1_1Bicgstab}{gko::\+batch::\+solver::\+\+Bicgstab$<$ Value\+Type $>$}}
\begin{DoxyCompactList}\small\item\em Bi\+CGSTAB or the Bi-\/\+Conjugate Gradient-\/\+Stabilized is a Krylov subspace solver. \end{DoxyCompactList}\item 
class \doxymbox{\hyperlink{classgko_1_1batch_1_1solver_1_1Cg}{gko::\+batch::\+solver::\+\+Cg$<$ Value\+Type $>$}}
\begin{DoxyCompactList}\small\item\em \doxylink{classgko_1_1batch_1_1solver_1_1Cg}{Cg} or the Conjugate Gradient is a Krylov subspace solver. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\+\#define \doxymbox{\hyperlink{group__BatchLinOp_gab7f0cd5a4520a215974412e6fff4f25f}{GKO\+\_\+\+ENABLE\+\_\+\+BATCH\+\_\+\+LIN\+\_\+\+OP\+\_\+\+FACTORY}}(\+\_\+batch\+\_\+lin\+\_\+op,  \+\_\+parameters\+\_\+name,  \+\_\+factory\+\_\+name)
\begin{DoxyCompactList}\small\item\em This macro will generate a default implementation of a Batch\+Lin\+Op\+Factory for the Batch\+Lin\+Op subclass it is defined in. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsubsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
{\footnotesize template$<$typename Concrete\+Factory, typename Concrete\+Batch\+Lin\+Op, typename Parameters\+Type, typename Polymorphic\+Base = Batch\+Lin\+Op\+Factory$>$ }\\using \doxymbox{\hyperlink{group__BatchLinOp_ga1fdadb2cde82e36813fd16add2756bef}{gko::\+batch::\+\+Enable\+Default\+Batch\+Lin\+Op\+Factory}}
\begin{DoxyCompactList}\small\item\em This is an alias for the \doxylink{classgko_1_1EnableDefaultFactory}{Enable\+Default\+Factory} mixin, which correctly sets the template parameters to enable a subclass of \doxylink{classgko_1_1batch_1_1BatchLinOpFactory}{Batch\+Lin\+Op\+Factory}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}


\hypertarget{group__BatchLinOp_batch_linop_concept}{}\doxysubsection{\texorpdfstring{Batched Linear operator as a concept}{Batched Linear operator as a concept}}\label{group__BatchLinOp_batch_linop_concept}
A batch linear operator (\doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op}) forms the base class for all batched linear algebra objects. In general, it follows the same structure as the \doxylink{classgko_1_1LinOp}{Lin\+Op} class, but has some crucial differences which make it not strictly representable through or with the \doxylink{classgko_1_1LinOp}{Lin\+Op} class.

A batched operator is defined as a set of independent linear operators which have no communication/\+information exchange between them. Therefore, any collective operations between the batches is not possible and not implemented. This allows for each batch to be computed and operated on in an embarrassingly parallel fashion.

A key difference between the \doxylink{classgko_1_1LinOp}{Lin\+Op} and the \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} class is that the apply between Batch\+Lin\+Ops is no longer supported. The user can apply a \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} to a \doxylink{classgko_1_1batch_1_1MultiVector}{batch::\+\+Multi\+Vector} but not to any general \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op}.

Therefore, the \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} serves only as a base class providing necessary core functionality from Polymorphic object and store the dimensions of the batched object.

\begin{DoxyNote}{Note}
Apply to \doxylink{classgko_1_1batch_1_1MultiVector}{batch::\+\+Multi\+Vector} objects are handled by the concrete \doxylink{classgko_1_1LinOp}{Lin\+Op} and may be moved to the base \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} class in the future.
\end{DoxyNote}
\doxylink{group__BatchLinOp}{Batch\+Lin\+Op} 

\label{doc-define-members}
\Hypertarget{group__BatchLinOp_doc-define-members}
\doxysubsection{Macro Definition Documentation}
\Hypertarget{group__BatchLinOp_gab7f0cd5a4520a215974412e6fff4f25f}\index{BatchLinOp@{BatchLinOp}!GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY@{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY}}
\index{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY@{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY}!BatchLinOp@{BatchLinOp}}
\doxysubsubsection{\texorpdfstring{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY}{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY}}
{\footnotesize\ttfamily \label{group__BatchLinOp_gab7f0cd5a4520a215974412e6fff4f25f} 
\+\#define GKO\+\_\+\+ENABLE\+\_\+\+BATCH\+\_\+\+LIN\+\_\+\+OP\+\_\+\+FACTORY(\begin{DoxyParamCaption}\item[{}]{\+\_\+batch\+\_\+lin\+\_\+op}{, }\item[{}]{\+\_\+parameters\+\_\+name}{, }\item[{}]{\+\_\+factory\+\_\+name}{}\end{DoxyParamCaption})}



This macro will generate a default implementation of a Batch\+Lin\+Op\+Factory for the Batch\+Lin\+Op subclass it is defined in. 

It is required to first call the macro \doxylink{group__LinOp_ga1fc8e9d8be0c9ad2d72bc1ddfc6d8358}{GKO\+\_\+\+CREATE\+\_\+\+FACTORY\+\_\+\+PARAMETERS()} before this one in order to instantiate the parameters type first.

The list of parameters for the factory should be defined in a code block after the macro definition, and should contain a list of GKO\+\_\+\+FACTORY\+\_\+\+PARAMETER\+\_\+\texorpdfstring{$\ast$}{*} declarations. The class should provide a constructor with signature \+\_\+batch\+\_\+lin\+\_\+op(const \+\_\+factory\+\_\+name \texorpdfstring{$\ast$}{*}, std::\+shared\+\_\+ptr$<$const Batch\+Lin\+Op$>$) which the factory will use a callback to construct the object.

A minimal example of a batch linear operator is the following:\+


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{struct\ }MyBatchLinOp\ :\ \textcolor{keyword}{public}\ EnableBatchLinOp<MyBatchLinOp>\ \{}
\DoxyCodeLine{\ \ \ \ \doxymbox{\hyperlink{group__BatchLinOp_gab7f0cd5a4520a215974412e6fff4f25f}{GKO\_ENABLE\_BATCH\_LIN\_OP\_FACTORY}}(MyBatchLinOp,\ my\_parameters,\ Factory)\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ a\ factory\ parameter\ named\ "{}my\_value"{},\ of\ type\ int\ and\ default}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ value\ of\ 5}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ \doxymbox{\hyperlink{group__LinOp_ga49d4c09c39f06b22bebbbfd1d8bfe450}{GKO\_FACTORY\_PARAMETER\_SCALAR}}(my\_value,\ 5);}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ a\ factory\ parameter\ named\ \`{}my\_pair`\ of\ type\ \`{}std::pair<int,int>`}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ and\ default\ value\ \{5,\ 5\}}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ std::pair<int,\ int>\ \doxymbox{\hyperlink{group__LinOp_gaa292314d27ec1fb7ad54debaa3606ea8}{GKO\_FACTORY\_PARAMETER\_VECTOR}}(my\_pair,\ 5,\ 5);}
\DoxyCodeLine{\ \ \ \ \};}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ constructor\ needed\ by\ EnableBatchLinOp}}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{explicit}\ MyBatchLinOp(std::shared\_ptr<const\ Executor>\ exec)\ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ :\ EnableBatchLinOp<MyBatchLinOp>(exec)\ \{\}}
\DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ constructor\ needed\ by\ the\ factory}}
\DoxyCodeLine{\ \ \ \ \textcolor{keyword}{explicit}\ MyBatchLinOp(\textcolor{keyword}{const}\ Factory\ *factory,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::shared\_ptr<const\ BatchLinOp>\ matrix)}
\DoxyCodeLine{\ \ \ \ \ \ \ \ :\ EnableBatchLinOp<MyBatchLinOp>(\doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a9549dd6065d019211460c59a86dd6536}{factory}}-\/>get\_executor()),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ matrix-\/>get\_size()),}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ store\ factory's\ parameters\ locally}}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ my\_parameters\_\{\doxymbox{\hyperlink{namespacegko_1_1log_a15f71654c6c4f4defc95f9359343fa27a9549dd6065d019211460c59a86dd6536}{factory}}-\/>get\_parameters()\}}
\DoxyCodeLine{\ \ \ \ \{}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \textcolor{keywordtype}{int}\ value\ =\ my\_parameters\_.my\_value;}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \textcolor{comment}{//\ do\ something\ with\ value}}
\DoxyCodeLine{\ \ \ \ \}}

\end{DoxyCode}


My\+Batch\+Lin\+Op can then be created as follows:\+


\begin{DoxyCode}{0}
\DoxyCodeLine{\textcolor{keyword}{auto}\ exec\ =\ gko::ReferenceExecutor::create();}
\DoxyCodeLine{\textcolor{comment}{//\ create\ a\ factory\ with\ default\ \`{}my\_value`\ parameter}}
\DoxyCodeLine{\textcolor{keyword}{auto}\ fact\ =\ MyBatchLinOp::build().on(exec);}
\DoxyCodeLine{\textcolor{comment}{//\ create\ a\ operator\ using\ the\ factory:}}
\DoxyCodeLine{\textcolor{keyword}{auto}\ my\_op\ =\ fact-\/>generate(\doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Identity_a97d983b2715d4ba66e428e30b1f54202}{gko::batch::matrix::Identity::create}}(exec,\ 2));}
\DoxyCodeLine{std::cout\ <<\ my\_op-\/>get\_my\_parameters().my\_value;\ \ \textcolor{comment}{//\ prints\ 5}}
\DoxyCodeLine{}
\DoxyCodeLine{\textcolor{comment}{//\ create\ a\ factory\ with\ custom\ \`{}my\_value`\ parameter}}
\DoxyCodeLine{\textcolor{keyword}{auto}\ fact\ =\ MyLinOp::build().with\_my\_value(0).on(exec);}
\DoxyCodeLine{\textcolor{comment}{//\ create\ a\ operator\ using\ the\ factory:}}
\DoxyCodeLine{\textcolor{keyword}{auto}\ my\_op\ =\ fact-\/>generate(\doxymbox{\hyperlink{classgko_1_1batch_1_1matrix_1_1Identity_a97d983b2715d4ba66e428e30b1f54202}{gko::batch::matrix::Identity::create}}(exec,\ 2));}
\DoxyCodeLine{std::cout\ <<\ my\_op-\/>get\_my\_parameters().my\_value;\ \ \textcolor{comment}{//\ prints\ 0}}

\end{DoxyCode}


\begin{DoxyNote}{Note}
It is possible to combine both the \+\#\+GKO\+\_\+\+CREATE\+\_\+\+FACTORY\+\_\+\+PARAMETER\+\_\+\texorpdfstring{$\ast$}{*}() macros with this one in a unique macro for class {\bfseries{templates}} (not with regular classes). Splitting this into two distinct macros allows to use them in all contexts. See \href{https://stackoverflow.com/q/50202718/9385966}{\texttt{https:\+/\+/\+stackoverflow.\+com/\+q/\+50202718/\+9385966}} for more details.
\end{DoxyNote}

\begin{DoxyParams}{Parameters}
{\em \+\_\+batch\+\_\+lin\+\_\+op} & concrete operator for which the factory is to be created \+[CRTP parameter]\+ \\
\hline
{\em \+\_\+parameters\+\_\+name} & name of the parameters member in the class (its type is {\ttfamily \texorpdfstring{$<$}{<}\+\_\+parameters\+\_\+name\texorpdfstring{$>$}{>}\+\_\+type}, the protected member\textquotesingle{}s name is {\ttfamily \texorpdfstring{$<$}{<}\+\_\+parameters\+\_\+name\texorpdfstring{$>$}{>}\+\_\+}, and the public getter\textquotesingle{}s name is {\ttfamily get\+\_\+\texorpdfstring{$<$}{<}\+\_\+parameters\+\_\+name\texorpdfstring{$>$}{>}()}) \\
\hline
{\em \+\_\+factory\+\_\+name} & name of the generated factory type \\
\hline
\end{DoxyParams}


\label{doc-typedef-members}
\Hypertarget{group__BatchLinOp_doc-typedef-members}
\doxysubsection{Typedef Documentation}
\Hypertarget{group__BatchLinOp_ga1fdadb2cde82e36813fd16add2756bef}\index{BatchLinOp@{BatchLinOp}!EnableDefaultBatchLinOpFactory@{EnableDefaultBatchLinOpFactory}}
\index{EnableDefaultBatchLinOpFactory@{EnableDefaultBatchLinOpFactory}!BatchLinOp@{BatchLinOp}}
\doxysubsubsection{\texorpdfstring{EnableDefaultBatchLinOpFactory}{EnableDefaultBatchLinOpFactory}}
{\footnotesize\ttfamily \label{group__BatchLinOp_ga1fdadb2cde82e36813fd16add2756bef} 
template$<$typename Concrete\+Factory, typename Concrete\+Batch\+Lin\+Op, typename Parameters\+Type, typename Polymorphic\+Base = Batch\+Lin\+Op\+Factory$>$ \\
using \doxymbox{\hyperlink{group__BatchLinOp_ga1fdadb2cde82e36813fd16add2756bef}{gko::\+batch::\+\+Enable\+Default\+Batch\+Lin\+Op\+Factory}}}

{\bfseries Initial value:\+}
\begin{DoxyCode}{0}
\DoxyCodeLine{}
\DoxyCodeLine{\doxymbox{\hyperlink{classgko_1_1EnableDefaultFactory}{EnableDefaultFactory}}<ConcreteFactory,\ ConcreteBatchLinOp,\ ParametersType,}
\DoxyCodeLine{\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ PolymorphicBase>}

\end{DoxyCode}


This is an alias for the \doxylink{classgko_1_1EnableDefaultFactory}{Enable\+Default\+Factory} mixin, which correctly sets the template parameters to enable a subclass of \doxylink{classgko_1_1batch_1_1BatchLinOpFactory}{Batch\+Lin\+Op\+Factory}. 


\begin{DoxyTemplParams}{Template Parameters}
{\em Concrete\+Factory} & the concrete factory which is being implemented \+[CRTP parameter]\+ \\
\hline
{\em Concrete\+Batch\+Lin\+Op} & the concrete \doxylink{classgko_1_1batch_1_1BatchLinOp}{Batch\+Lin\+Op} type which this factory produces, needs to have a constructor which takes a const Concrete\+Factory \texorpdfstring{$\ast$}{*}, and an std::\+shared\+\_\+ptr$<$const Batch\+Lin\+Op$>$ as parameters. \\
\hline
{\em Parameters\+Type} & a subclass of \doxylink{classgko_1_1enable__parameters__type}{enable\+\_\+parameters\+\_\+type} template which defines all of the parameters of the factory \\
\hline
{\em Polymorphic\+Base} & parent of Concrete\+Factory in the polymorphic hierarchy, has to be a subclass of \doxylink{classgko_1_1batch_1_1BatchLinOpFactory}{Batch\+Lin\+Op\+Factory} \\
\hline
\end{DoxyTemplParams}
