\doxysection{range\+\_\+accessors.\+hpp}
\hypertarget{range__accessors_8hpp_source}{}\label{range__accessors_8hpp_source}\index{ginkgo/core/base/range\_accessors.hpp@{ginkgo/core/base/range\_accessors.hpp}}

\begin{DoxyCode}{0}
\DoxyCodeLine{00001\ \textcolor{comment}{//\ SPDX-\/FileCopyrightText:\ 2017\ -\/\ 2024\ 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\_BASE\_RANGE\_ACCESSORS\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_RANGE\_ACCESSORS\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <array>}}
\DoxyCodeLine{00010\ }
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/range.hpp>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/types.hpp>}}
\DoxyCodeLine{00013\ }
\DoxyCodeLine{00014\ }
\DoxyCodeLine{00015\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00021\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko_1_1accessor}{accessor}}\ \{}
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ }
\DoxyCodeLine{00039\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ ValueType,\ \textcolor{keywordtype}{size\_t}ype\ Dimensionality>}
\DoxyCodeLine{00040\ \textcolor{keyword}{class\ }row\_major\ \{}
\DoxyCodeLine{00041\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keyword}{friend}\ \textcolor{keyword}{class\ }\doxymbox{\hyperlink{classgko_1_1range}{range}}<row\_major>;}
\DoxyCodeLine{00043\ }
\DoxyCodeLine{00044\ \ \ \ \ \textcolor{keyword}{static\_assert}(Dimensionality\ ==\ 2,}
\DoxyCodeLine{00045\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}This\ accessor\ is\ only\ implemented\ for\ matrices"{}});}
\DoxyCodeLine{00046\ }
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a687bda931be92c31abf02965fa72ceba}{value\_type}}\ =\ ValueType;}
\DoxyCodeLine{00051\ }
\DoxyCodeLine{00055\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_af6e81060211b143c595ee4f77537dbc2}{data\_type}}\ =\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a687bda931be92c31abf02965fa72ceba}{value\_type}}*;}
\DoxyCodeLine{00056\ }
\DoxyCodeLine{00060\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_ae969fbac55f5ba6e6f95f25a0aac483d}{dimensionality}}\ =\ 2;}
\DoxyCodeLine{00061\ }
\DoxyCodeLine{00062\ \textcolor{keyword}{protected}:}
\DoxyCodeLine{00073\ \ \ \ \ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ \textcolor{keyword}{explicit}\ row\_major(\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_af6e81060211b143c595ee4f77537dbc2}{data\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}},}
\DoxyCodeLine{00074\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ num\_rows,}
\DoxyCodeLine{00075\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ num\_cols,}
\DoxyCodeLine{00076\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}})}
\DoxyCodeLine{00077\ \ \ \ \ \ \ \ \ :\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}}\{\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}}\},\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}\{num\_rows,\ num\_cols\},\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}}\{\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}}\}}
\DoxyCodeLine{00078\ \ \ \ \ \{\}}
\DoxyCodeLine{00079\ }
\DoxyCodeLine{00080\ \textcolor{keyword}{public}:}
\DoxyCodeLine{00089\ \ \ \ \ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a687bda931be92c31abf02965fa72ceba}{value\_type}}\&\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_af208638f030fa882d1aaef5737a4c161}{operator()}}(\doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ row,}
\DoxyCodeLine{00090\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ col)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00091\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{00092\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ GKO\_ASSERT(row\ <\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[0]),\ GKO\_ASSERT(col\ <\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[1]),}
\DoxyCodeLine{00093\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}}[row\ *\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}}\ +\ col];}
\DoxyCodeLine{00094\ \ \ \ \ \}}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00104\ \ \ \ \ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ \doxymbox{\hyperlink{classgko_1_1range}{range<row\_major>}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a1cd0b97c9e3b75e4dd957eff35831048}{operator()}}(\textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1span}{span}}\&\ rows,}
\DoxyCodeLine{00105\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{structgko_1_1span}{span}}\&\ cols)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00106\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{00107\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ GKO\_ASSERT(rows.is\_valid()),\ GKO\_ASSERT(cols.\doxymbox{\hyperlink{structgko_1_1span_a32a87f434708e6857820858503f9b133}{is\_valid}}()),}
\DoxyCodeLine{00108\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ GKO\_ASSERT(rows\ <=\ \doxymbox{\hyperlink{structgko_1_1span}{span}}\{\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[0]\}),}
\DoxyCodeLine{00109\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ GKO\_ASSERT(cols\ <=\ \doxymbox{\hyperlink{structgko_1_1span}{span}}\{\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[1]\}),}
\DoxyCodeLine{00110\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1range}{range<row\_major>}}(\doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}}\ +\ rows.begin\ *\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}}\ +\ cols.\doxymbox{\hyperlink{structgko_1_1span_a54ff06eda27a98b62e83c7e9e7b6dcd7}{begin}},}
\DoxyCodeLine{00111\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rows.end\ -\/\ rows.begin,\ cols.\doxymbox{\hyperlink{structgko_1_1span_af68200dea4456e1bd3511c3b14bc2886}{end}}\ -\/\ cols.\doxymbox{\hyperlink{structgko_1_1span_a54ff06eda27a98b62e83c7e9e7b6dcd7}{begin}},}
\DoxyCodeLine{00112\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}});}
\DoxyCodeLine{00113\ \ \ \ \ \}}
\DoxyCodeLine{00114\ }
\DoxyCodeLine{00122\ \ \ \ \ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a438bb22bf86a33db403119bcb914dacc}{length}}(\doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ dimension)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00123\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{00124\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{return}\ dimension\ <\ 2\ ?\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[dimension]\ :\ 1;}
\DoxyCodeLine{00125\ \ \ \ \ \}}
\DoxyCodeLine{00126\ }
\DoxyCodeLine{00139\ \ \ \ \ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ OtherAccessor>}
\DoxyCodeLine{00140\ \ \ \ \ GKO\_ATTRIBUTES\ \textcolor{keywordtype}{void}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a878a175c452549107d9db2521e481efe}{copy\_from}}(\textcolor{keyword}{const}\ OtherAccessor\&\ other)\textcolor{keyword}{\ const}}
\DoxyCodeLine{00141\ \textcolor{keyword}{\ \ \ \ }\{}
\DoxyCodeLine{00142\ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ i\ =\ 0;\ i\ <\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[0];\ ++i)\ \{}
\DoxyCodeLine{00143\ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keywordflow}{for}\ (\doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ j\ =\ 0;\ j\ <\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}}[1];\ ++j)\ \{}
\DoxyCodeLine{00144\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ (*this)(i,\ j)\ =\ other(i,\ j);}
\DoxyCodeLine{00145\ \ \ \ \ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00146\ \ \ \ \ \ \ \ \ \}}
\DoxyCodeLine{00147\ \ \ \ \ \}}
\DoxyCodeLine{00148\ }
\DoxyCodeLine{00152\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_af6e81060211b143c595ee4f77537dbc2}{data\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_aa83eec10535e8ac7f79c6a04c0c05b4c}{data}};}
\DoxyCodeLine{00153\ }
\DoxyCodeLine{00157\ \ \ \ \ \textcolor{keyword}{const}\ std::array<const\ size\_type,\ dimensionality>\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a4912695f06056d9e46cb335168bf28c9}{lengths}};}
\DoxyCodeLine{00158\ }
\DoxyCodeLine{00162\ \ \ \ \ \textcolor{keyword}{const}\ \doxymbox{\hyperlink{namespacegko_a9579c98b1d85bf4ad02d7cb5b96fc771}{size\_type}}\ \doxymbox{\hyperlink{classgko_1_1accessor_1_1row__major_a651793392dc0327f324289bb096b3316}{stride}};}
\DoxyCodeLine{00163\ \};}
\DoxyCodeLine{00164\ }
\DoxyCodeLine{00165\ }
\DoxyCodeLine{00166\ \}\ \ \textcolor{comment}{//\ namespace\ accessor}}
\DoxyCodeLine{00167\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{00168\ }
\DoxyCodeLine{00169\ }
\DoxyCodeLine{00170\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_RANGE\_ACCESSORS\_HPP\_}}

\end{DoxyCode}
