\doxysection{math.\+hpp}
\hypertarget{math_8hpp_source}{}\label{math_8hpp_source}\index{ginkgo/core/base/math.hpp@{ginkgo/core/base/math.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\_BASE\_MATH\_HPP\_}}
\DoxyCodeLine{00006\ \textcolor{preprocessor}{\#define\ GKO\_PUBLIC\_CORE\_BASE\_MATH\_HPP\_}}
\DoxyCodeLine{00007\ }
\DoxyCodeLine{00008\ }
\DoxyCodeLine{00009\ \textcolor{preprocessor}{\#include\ <cmath>}}
\DoxyCodeLine{00010\ \textcolor{preprocessor}{\#include\ <complex>}}
\DoxyCodeLine{00011\ \textcolor{preprocessor}{\#include\ <cstdlib>}}
\DoxyCodeLine{00012\ \textcolor{preprocessor}{\#include\ <limits>}}
\DoxyCodeLine{00013\ \textcolor{preprocessor}{\#include\ <tuple>}}
\DoxyCodeLine{00014\ \textcolor{preprocessor}{\#include\ <type\_traits>}}
\DoxyCodeLine{00015\ \textcolor{preprocessor}{\#include\ <utility>}}
\DoxyCodeLine{00016\ }
\DoxyCodeLine{00017\ \textcolor{preprocessor}{\#include\ <ginkgo/config.hpp>}}
\DoxyCodeLine{00018\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/half.hpp>}}
\DoxyCodeLine{00019\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/types.hpp>}}
\DoxyCodeLine{00020\ \textcolor{preprocessor}{\#include\ <ginkgo/core/base/utils.hpp>}}
\DoxyCodeLine{00021\ }
\DoxyCodeLine{00022\ }
\DoxyCodeLine{00023\ \textcolor{keyword}{namespace\ }\doxymbox{\hyperlink{namespacegko}{gko}}\ \{}
\DoxyCodeLine{00024\ }
\DoxyCodeLine{00025\ }
\DoxyCodeLine{00026\ \textcolor{comment}{//\ type\ manipulations}}
\DoxyCodeLine{00027\ }
\DoxyCodeLine{00028\ }
\DoxyCodeLine{00034\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00035\ }
\DoxyCodeLine{00036\ }
\DoxyCodeLine{00040\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00041\ \textcolor{keyword}{struct\ }remove\_complex\_impl\ \{}
\DoxyCodeLine{00042\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ T;}
\DoxyCodeLine{00043\ \};}
\DoxyCodeLine{00044\ }
\DoxyCodeLine{00048\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00049\ \textcolor{keyword}{struct\ }remove\_complex\_impl<std::complex<T>>\ \{}
\DoxyCodeLine{00050\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ T;}
\DoxyCodeLine{00051\ \};}
\DoxyCodeLine{00052\ }
\DoxyCodeLine{00053\ }
\DoxyCodeLine{00059\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00060\ \textcolor{keyword}{struct\ }to\_complex\_impl\ \{}
\DoxyCodeLine{00061\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<T>;}
\DoxyCodeLine{00062\ \};}
\DoxyCodeLine{00063\ }
\DoxyCodeLine{00069\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00070\ \textcolor{keyword}{struct\ }to\_complex\_impl<std::complex<T>>\ \{}
\DoxyCodeLine{00071\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<T>;}
\DoxyCodeLine{00072\ \};}
\DoxyCodeLine{00073\ }
\DoxyCodeLine{00074\ }
\DoxyCodeLine{00075\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00076\ \textcolor{keyword}{struct\ }is\_complex\_impl\ :\ \textcolor{keyword}{public}\ std::integral\_constant<bool,\ false>\ \{\};}
\DoxyCodeLine{00077\ }
\DoxyCodeLine{00078\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00079\ \textcolor{keyword}{struct\ }is\_complex\_impl<std::complex<T>>}
\DoxyCodeLine{00080\ \ \ \ \ :\ \textcolor{keyword}{public}\ std::integral\_constant<bool,\ true>\ \{\};}
\DoxyCodeLine{00081\ }
\DoxyCodeLine{00082\ }
\DoxyCodeLine{00083\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00084\ \textcolor{keyword}{struct\ }is\_complex\_or\_scalar\_impl\ :\ std::is\_scalar<T>\ \{\};}
\DoxyCodeLine{00085\ }
\DoxyCodeLine{00086\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00087\ \textcolor{keyword}{struct\ }is\_complex\_or\_scalar\_impl<half>\ :\ std::true\_type\ \{\};}
\DoxyCodeLine{00088\ }
\DoxyCodeLine{00089\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00090\ \textcolor{keyword}{struct\ }is\_complex\_or\_scalar\_impl<bfloat16>\ :\ std::true\_type\ \{\};}
\DoxyCodeLine{00091\ }
\DoxyCodeLine{00092\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00093\ \textcolor{keyword}{struct\ }is\_complex\_or\_scalar\_impl<std::complex<T>>}
\DoxyCodeLine{00094\ \ \ \ \ :\ is\_complex\_or\_scalar\_impl<T>\ \{\};}
\DoxyCodeLine{00095\ }
\DoxyCodeLine{00096\ }
\DoxyCodeLine{00104\ \textcolor{keyword}{template}\ <\textcolor{keyword}{template}\ <\textcolor{keyword}{typename}>\ \textcolor{keyword}{class\ }converter,\ \textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00105\ \textcolor{keyword}{struct\ }template\_converter\ \{\};}
\DoxyCodeLine{00106\ }
\DoxyCodeLine{00116\ \textcolor{keyword}{template}\ <\textcolor{keyword}{template}\ <\textcolor{keyword}{typename}>\ \textcolor{keyword}{class\ }converter,\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}...>\ \textcolor{keyword}{class\ }T,}
\DoxyCodeLine{00117\ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}...\ Rest>}
\DoxyCodeLine{00118\ \textcolor{keyword}{struct\ }template\_converter<converter,\ T<Rest...>>\ \{}
\DoxyCodeLine{00119\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ T<typename\ converter<Rest>::type...>;}
\DoxyCodeLine{00120\ \};}
\DoxyCodeLine{00121\ }
\DoxyCodeLine{00122\ }
\DoxyCodeLine{00123\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keyword}{typename}\ =\ \textcolor{keywordtype}{void}>}
\DoxyCodeLine{00124\ \textcolor{keyword}{struct\ }remove\_complex\_s\ \{\};}
\DoxyCodeLine{00125\ }
\DoxyCodeLine{00132\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00133\ \textcolor{keyword}{struct\ }remove\_complex\_s<T,}
\DoxyCodeLine{00134\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ std::enable\_if\_t<is\_complex\_or\_scalar\_impl<T>::value>>\ \{}
\DoxyCodeLine{00135\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{typename}\ detail::remove\_complex\_impl<T>::type;}
\DoxyCodeLine{00136\ \};}
\DoxyCodeLine{00137\ }
\DoxyCodeLine{00144\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00145\ \textcolor{keyword}{struct\ }remove\_complex\_s<}
\DoxyCodeLine{00146\ \ \ \ \ T,\ std::enable\_if\_t<!is\_complex\_or\_scalar\_impl<T>::value>>\ \{}
\DoxyCodeLine{00147\ \ \ \ \ \textcolor{keyword}{using\ }type\ =}
\DoxyCodeLine{00148\ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ detail::template\_converter<detail::remove\_complex\_impl,}
\DoxyCodeLine{00149\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ T>::type;}
\DoxyCodeLine{00150\ \};}
\DoxyCodeLine{00151\ }
\DoxyCodeLine{00152\ }
\DoxyCodeLine{00153\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keyword}{typename}\ =\ \textcolor{keywordtype}{void}>}
\DoxyCodeLine{00154\ \textcolor{keyword}{struct\ }to\_complex\_s\ \{\};}
\DoxyCodeLine{00155\ }
\DoxyCodeLine{00162\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00163\ \textcolor{keyword}{struct\ }to\_complex\_s<T,\ std::enable\_if\_t<is\_complex\_or\_scalar\_impl<T>::value>>\ \{}
\DoxyCodeLine{00164\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{typename}\ detail::to\_complex\_impl<T>::type;}
\DoxyCodeLine{00165\ \};}
\DoxyCodeLine{00166\ }
\DoxyCodeLine{00173\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00174\ \textcolor{keyword}{struct\ }to\_complex\_s<T,\ std::enable\_if\_t<!is\_complex\_or\_scalar\_impl<T>::value>>\ \{}
\DoxyCodeLine{00175\ \ \ \ \ \textcolor{keyword}{using\ }type\ =}
\DoxyCodeLine{00176\ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ detail::template\_converter<detail::to\_complex\_impl,\ T>::type;}
\DoxyCodeLine{00177\ \};}
\DoxyCodeLine{00178\ }
\DoxyCodeLine{00179\ }
\DoxyCodeLine{00180\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00181\ }
\DoxyCodeLine{00182\ }
\DoxyCodeLine{00188\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00189\ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1cpx__real__type}{cpx\_real\_type}}\ \{}
\DoxyCodeLine{00191\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{structgko_1_1cpx__real__type_a6fec5b28321901b6da393b424afb144b}{type}}\ =\ T;}
\DoxyCodeLine{00192\ \};}
\DoxyCodeLine{00193\ }
\DoxyCodeLine{00199\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00200\ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1cpx__real__type}{cpx\_real\_type}}<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T>>\ \{}
\DoxyCodeLine{00202\ \ \ \ \ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{structgko_1_1cpx__real__type_a6fec5b28321901b6da393b424afb144b}{type}}\ =\ \textcolor{keyword}{typename}\ std::complex<T>::value\_type;}
\DoxyCodeLine{00203\ \};}
\DoxyCodeLine{00204\ }
\DoxyCodeLine{00205\ }
\DoxyCodeLine{00214\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00215\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a700d12db3a341bb7a46bede49e1d6715}{is\_complex\_s}}\ =\ detail::is\_complex\_impl<T>;}
\DoxyCodeLine{00216\ }
\DoxyCodeLine{00224\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00225\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{namespacegko_a9b3e79911bb6145d7ba865dbe436b915}{is\_complex}}()}
\DoxyCodeLine{00226\ \{}
\DoxyCodeLine{00227\ \ \ \ \ \textcolor{keywordflow}{return}\ detail::is\_complex\_impl<T>::value;}
\DoxyCodeLine{00228\ \}}
\DoxyCodeLine{00229\ }
\DoxyCodeLine{00230\ }
\DoxyCodeLine{00238\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00239\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_abf707c1057eb7f959355ab06990441a8}{is\_complex\_or\_scalar\_s}}\ =\ detail::is\_complex\_or\_scalar\_impl<T>;}
\DoxyCodeLine{00240\ }
\DoxyCodeLine{00248\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00249\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{namespacegko_a6881ebae53e15cb88342c0540d953f59}{is\_complex\_or\_scalar}}()}
\DoxyCodeLine{00250\ \{}
\DoxyCodeLine{00251\ \ \ \ \ \textcolor{keywordflow}{return}\ detail::is\_complex\_or\_scalar\_impl<T>::value;}
\DoxyCodeLine{00252\ \}}
\DoxyCodeLine{00253\ }
\DoxyCodeLine{00254\ }
\DoxyCodeLine{00263\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00264\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex}}\ =\ \textcolor{keyword}{typename}\ detail::remove\_complex\_s<T>::type;}
\DoxyCodeLine{00265\ }
\DoxyCodeLine{00266\ }
\DoxyCodeLine{00282\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00283\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a4ad20e5381a84928753efde0b2bc7f85}{to\_complex}}\ =\ \textcolor{keyword}{typename}\ detail::to\_complex\_s<T>::type;}
\DoxyCodeLine{00284\ }
\DoxyCodeLine{00285\ }
\DoxyCodeLine{00291\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00292\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_ad6b4f42aaf509f2f3660fcba0d230cac}{to\_real}}\ =\ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}};}
\DoxyCodeLine{00293\ }
\DoxyCodeLine{00294\ }
\DoxyCodeLine{00295\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00296\ }
\DoxyCodeLine{00297\ }
\DoxyCodeLine{00298\ \textcolor{comment}{//\ singly\ linked\ list\ of\ all\ our\ supported\ precisions}}
\DoxyCodeLine{00299\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00300\ \textcolor{keyword}{struct\ }next\_precision\_base\_impl\ \{\};}
\DoxyCodeLine{00301\ }
\DoxyCodeLine{00302\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00303\ \textcolor{keyword}{struct\ }next\_precision\_base\_impl<float>\ \{}
\DoxyCodeLine{00304\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ double;}
\DoxyCodeLine{00305\ \};}
\DoxyCodeLine{00306\ }
\DoxyCodeLine{00307\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00308\ \textcolor{keyword}{struct\ }next\_precision\_base\_impl<double>\ \{}
\DoxyCodeLine{00309\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ float;}
\DoxyCodeLine{00310\ \};}
\DoxyCodeLine{00311\ }
\DoxyCodeLine{00312\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00313\ \textcolor{keyword}{struct\ }next\_precision\_base\_impl<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T>>\ \{}
\DoxyCodeLine{00314\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ next\_precision\_base\_impl<T>::type>;}
\DoxyCodeLine{00315\ \};}
\DoxyCodeLine{00316\ }
\DoxyCodeLine{00317\ }
\DoxyCodeLine{00323\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step,\ \textcolor{keyword}{typename}\ Visited,\ \textcolor{keyword}{typename}...\ Rest>}
\DoxyCodeLine{00324\ \textcolor{keyword}{struct\ }find\_precision\_list\_impl;}
\DoxyCodeLine{00325\ }
\DoxyCodeLine{00326\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step,\ \textcolor{keyword}{typename}...\ Visited,\ \textcolor{keyword}{typename}\ U,}
\DoxyCodeLine{00327\ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}...\ Rest>}
\DoxyCodeLine{00328\ \textcolor{keyword}{struct\ }find\_precision\_list\_impl<T,\ step,\ \doxymbox{\hyperlink{namespacestd}{std}}::tuple<Visited...>,\ U,\ Rest...>\ \{}
\DoxyCodeLine{00329\ \ \ \ \ \textcolor{keyword}{using\ }type\ =}
\DoxyCodeLine{00330\ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ find\_precision\_list\_impl<T,\ step,\ std::tuple<Visited...,\ U>,}
\DoxyCodeLine{00331\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Rest...>::type;}
\DoxyCodeLine{00332\ \};}
\DoxyCodeLine{00333\ }
\DoxyCodeLine{00334\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step,\ \textcolor{keyword}{typename}...\ Visited,\ \textcolor{keyword}{typename}...\ Rest>}
\DoxyCodeLine{00335\ \textcolor{keyword}{struct\ }find\_precision\_list\_impl<T,\ step,\ \doxymbox{\hyperlink{namespacestd}{std}}::tuple<Visited...>,\ T,\ Rest...>\ \{}
\DoxyCodeLine{00336\ \ \ \ \ \textcolor{keyword}{using\ }tuple\ =\ std::tuple<T,\ Rest...,\ Visited...>;}
\DoxyCodeLine{00337\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keyword}{auto}\ tuple\_size\ =}
\DoxyCodeLine{00338\ \ \ \ \ \ \ \ \ \textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{int}\textcolor{keyword}{>}(std::tuple\_size\_v<tuple>);}
\DoxyCodeLine{00339\ \ \ \ \ \textcolor{comment}{//\ It\ turns\ the\ first\ part\ into\ positive\ when\ step\ is\ negative}}
\DoxyCodeLine{00340\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{static}\ \textcolor{keywordtype}{int}\ index\ =\ (tuple\_size\ +\ step\ \%\ tuple\_size)\ \%\ tuple\_size;}
\DoxyCodeLine{00341\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::tuple\_element\_t<index,\ tuple>;}
\DoxyCodeLine{00342\ \};}
\DoxyCodeLine{00343\ }
\DoxyCodeLine{00344\ }
\DoxyCodeLine{00345\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step\ =\ 1>}
\DoxyCodeLine{00346\ \textcolor{keyword}{struct\ }find\_precision\_impl\ \{}
\DoxyCodeLine{00347\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{typename}\ find\_precision\_list\_impl<T,\ step,\ std::tuple<>,}
\DoxyCodeLine{00348\ \textcolor{preprocessor}{\#if\ GINKGO\_ENABLE\_HALF}}
\DoxyCodeLine{00349\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1half}{half}},}
\DoxyCodeLine{00350\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00351\ \textcolor{preprocessor}{\#if\ GINKGO\_ENABLE\_BFLOAT16}}
\DoxyCodeLine{00352\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{classgko_1_1bfloat16}{bfloat16}},}
\DoxyCodeLine{00353\ \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{00354\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ float,\ \textcolor{keywordtype}{double}>::type;}
\DoxyCodeLine{00355\ \};}
\DoxyCodeLine{00356\ }
\DoxyCodeLine{00357\ }
\DoxyCodeLine{00358\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step>}
\DoxyCodeLine{00359\ \textcolor{keyword}{struct\ }find\_precision\_impl<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T>,\ step>\ \{}
\DoxyCodeLine{00360\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ find\_precision\_impl<T,\ step>::type>;}
\DoxyCodeLine{00361\ \};}
\DoxyCodeLine{00362\ }
\DoxyCodeLine{00363\ }
\DoxyCodeLine{00364\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00365\ \textcolor{keyword}{struct\ }reduce\_precision\_impl\ \{}
\DoxyCodeLine{00366\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ T;}
\DoxyCodeLine{00367\ \};}
\DoxyCodeLine{00368\ }
\DoxyCodeLine{00369\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00370\ \textcolor{keyword}{struct\ }reduce\_precision\_impl<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T>>\ \{}
\DoxyCodeLine{00371\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ reduce\_precision\_impl<T>::type>;}
\DoxyCodeLine{00372\ \};}
\DoxyCodeLine{00373\ }
\DoxyCodeLine{00374\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00375\ \textcolor{keyword}{struct\ }reduce\_precision\_impl<double>\ \{}
\DoxyCodeLine{00376\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ float;}
\DoxyCodeLine{00377\ \};}
\DoxyCodeLine{00378\ }
\DoxyCodeLine{00379\ \textcolor{comment}{//\ for\ block\ jacobi}}
\DoxyCodeLine{00380\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00381\ \textcolor{keyword}{struct\ }reduce\_precision\_impl<float>\ \{}
\DoxyCodeLine{00382\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \doxymbox{\hyperlink{classgko_1_1half}{half}};}
\DoxyCodeLine{00383\ \};}
\DoxyCodeLine{00384\ }
\DoxyCodeLine{00385\ }
\DoxyCodeLine{00386\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00387\ \textcolor{keyword}{struct\ }increase\_precision\_impl\ \{}
\DoxyCodeLine{00388\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ T;}
\DoxyCodeLine{00389\ \};}
\DoxyCodeLine{00390\ }
\DoxyCodeLine{00391\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00392\ \textcolor{keyword}{struct\ }increase\_precision\_impl<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T>>\ \{}
\DoxyCodeLine{00393\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ increase\_precision\_impl<T>::type>;}
\DoxyCodeLine{00394\ \};}
\DoxyCodeLine{00395\ }
\DoxyCodeLine{00396\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00397\ \textcolor{keyword}{struct\ }increase\_precision\_impl<float>\ \{}
\DoxyCodeLine{00398\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ double;}
\DoxyCodeLine{00399\ \};}
\DoxyCodeLine{00400\ }
\DoxyCodeLine{00401\ \textcolor{comment}{//\ for\ block\ jacobi}}
\DoxyCodeLine{00402\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00403\ \textcolor{keyword}{struct\ }increase\_precision\_impl<\doxymbox{\hyperlink{classgko_1_1half}{half}}>\ \{}
\DoxyCodeLine{00404\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ float;}
\DoxyCodeLine{00405\ \};}
\DoxyCodeLine{00406\ }
\DoxyCodeLine{00407\ }
\DoxyCodeLine{00408\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00409\ \textcolor{keyword}{struct\ }infinity\_impl\ \{}
\DoxyCodeLine{00410\ \ \ \ \ \textcolor{comment}{//\ CUDA\ doesn't\ allow\ us\ to\ call\ std::numeric\_limits\ functions}}
\DoxyCodeLine{00411\ \ \ \ \ \textcolor{comment}{//\ so\ we\ need\ to\ store\ the\ value\ instead.}}
\DoxyCodeLine{00412\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ value\ =\ std::numeric\_limits<T>::infinity();}
\DoxyCodeLine{00413\ \};}
\DoxyCodeLine{00414\ }
\DoxyCodeLine{00415\ }
\DoxyCodeLine{00419\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T1,\ \textcolor{keyword}{typename}\ T2>}
\DoxyCodeLine{00420\ \textcolor{keyword}{struct\ }highest\_precision\_impl\ \{}
\DoxyCodeLine{00421\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{decltype}(T1\{\}\ +\ T2\{\});}
\DoxyCodeLine{00422\ \};}
\DoxyCodeLine{00423\ }
\DoxyCodeLine{00424\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T1,\ \textcolor{keyword}{typename}\ T2>}
\DoxyCodeLine{00425\ \textcolor{keyword}{struct\ }highest\_precision\_impl<\doxymbox{\hyperlink{namespacestd}{std}}::complex<T1>,\ std::complex<T2>>\ \{}
\DoxyCodeLine{00426\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ highest\_precision\_impl<T1,\ T2>::type>;}
\DoxyCodeLine{00427\ \};}
\DoxyCodeLine{00428\ }
\DoxyCodeLine{00429\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Head,\ \textcolor{keyword}{typename}...\ Tail>}
\DoxyCodeLine{00430\ \textcolor{keyword}{struct\ }highest\_precision\_variadic\ \{}
\DoxyCodeLine{00431\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{typename}\ highest\_precision\_impl<}
\DoxyCodeLine{00432\ \ \ \ \ \ \ \ \ Head,\ \textcolor{keyword}{typename}\ highest\_precision\_variadic<Tail...>::type>::type;}
\DoxyCodeLine{00433\ \};}
\DoxyCodeLine{00434\ }
\DoxyCodeLine{00435\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Head>}
\DoxyCodeLine{00436\ \textcolor{keyword}{struct\ }highest\_precision\_variadic<Head>\ \{}
\DoxyCodeLine{00437\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ Head;}
\DoxyCodeLine{00438\ \};}
\DoxyCodeLine{00439\ }
\DoxyCodeLine{00440\ }
\DoxyCodeLine{00441\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00442\ }
\DoxyCodeLine{00443\ }
\DoxyCodeLine{00447\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00448\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a2c2416a808014f8b0647d5e4ba42a735}{next\_precision\_base}}\ =\ \textcolor{keyword}{typename}\ detail::next\_precision\_base\_impl<T>::type;}
\DoxyCodeLine{00449\ }
\DoxyCodeLine{00450\ }
\DoxyCodeLine{00457\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00458\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a7f9e0f5413aca83838f94cbe9863e15c}{previous\_precision\_base}}\ =\ \doxymbox{\hyperlink{namespacegko_a2c2416a808014f8b0647d5e4ba42a735}{next\_precision\_base<T>}};}
\DoxyCodeLine{00459\ }
\DoxyCodeLine{00460\ }
\DoxyCodeLine{00465\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step\ =\ 1>}
\DoxyCodeLine{00466\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_aee37f85b217e5e26fe64207d41fa4bac}{next\_precision}}\ =\ \textcolor{keyword}{typename}\ detail::find\_precision\_impl<T,\ step>::type;}
\DoxyCodeLine{00467\ }
\DoxyCodeLine{00472\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{int}\ step\ =\ 1>}
\DoxyCodeLine{00473\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_ada2119004771922e8f7fcb6910a0363c}{previous\_precision}}\ =\ \textcolor{keyword}{typename}\ detail::find\_precision\_impl<T,\ -\/step>::type;}
\DoxyCodeLine{00474\ }
\DoxyCodeLine{00475\ }
\DoxyCodeLine{00479\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00480\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a87a96a1b78352538d905c10518bf5571}{reduce\_precision}}\ =\ \textcolor{keyword}{typename}\ detail::reduce\_precision\_impl<T>::type;}
\DoxyCodeLine{00481\ }
\DoxyCodeLine{00482\ }
\DoxyCodeLine{00486\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00487\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_ad6883fe3514ba0b125a4fc26c94ea9d1}{increase\_precision}}\ =\ \textcolor{keyword}{typename}\ detail::increase\_precision\_impl<T>::type;}
\DoxyCodeLine{00488\ }
\DoxyCodeLine{00489\ }
\DoxyCodeLine{00501\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}...\ Ts>}
\DoxyCodeLine{00502\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_ad643dd5de46195d05150e07455fa5712}{highest\_precision}}\ =}
\DoxyCodeLine{00503\ \ \ \ \ \textcolor{keyword}{typename}\ detail::highest\_precision\_variadic<Ts...>::type;}
\DoxyCodeLine{00504\ }
\DoxyCodeLine{00505\ }
\DoxyCodeLine{00515\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00516\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{namespacegko_a87a96a1b78352538d905c10518bf5571}{reduce\_precision<T>}}\ \doxymbox{\hyperlink{namespacegko_a8f5c64893cb6241b6c91c3aad724158f}{round\_down}}(T\ val)}
\DoxyCodeLine{00517\ \{}
\DoxyCodeLine{00518\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}\doxymbox{\hyperlink{namespacegko_a87a96a1b78352538d905c10518bf5571}{reduce\_precision<T>}}\textcolor{keyword}{>}(val);}
\DoxyCodeLine{00519\ \}}
\DoxyCodeLine{00520\ }
\DoxyCodeLine{00521\ }
\DoxyCodeLine{00531\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00532\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{namespacegko_ad6883fe3514ba0b125a4fc26c94ea9d1}{increase\_precision<T>}}\ \doxymbox{\hyperlink{namespacegko_a1a24c8b8654e0027471eee100e76e639}{round\_up}}(T\ val)}
\DoxyCodeLine{00533\ \{}
\DoxyCodeLine{00534\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}\doxymbox{\hyperlink{namespacegko_ad6883fe3514ba0b125a4fc26c94ea9d1}{increase\_precision<T>}}\textcolor{keyword}{>}(val);}
\DoxyCodeLine{00535\ \}}
\DoxyCodeLine{00536\ }
\DoxyCodeLine{00537\ }
\DoxyCodeLine{00538\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ FloatType,\ \textcolor{keywordtype}{size\_t}ype\ NumComponents,\ \textcolor{keywordtype}{size\_t}ype\ ComponentId>}
\DoxyCodeLine{00539\ \textcolor{keyword}{class\ }truncated;}
\DoxyCodeLine{00540\ }
\DoxyCodeLine{00541\ }
\DoxyCodeLine{00542\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00543\ }
\DoxyCodeLine{00544\ }
\DoxyCodeLine{00545\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00546\ \textcolor{keyword}{struct\ }truncate\_type\_impl\ \{}
\DoxyCodeLine{00547\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ truncated<T,\ 2,\ 0>;}
\DoxyCodeLine{00548\ \};}
\DoxyCodeLine{00549\ }
\DoxyCodeLine{00550\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}ype\ Components>}
\DoxyCodeLine{00551\ \textcolor{keyword}{struct\ }truncate\_type\_impl<truncated<T,\ Components,\ 0>>\ \{}
\DoxyCodeLine{00552\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ truncated<T,\ 2\ *\ Components,\ 0>;}
\DoxyCodeLine{00553\ \};}
\DoxyCodeLine{00554\ }
\DoxyCodeLine{00555\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00556\ \textcolor{keyword}{struct\ }truncate\_type\_impl<std::complex<T>>\ \{}
\DoxyCodeLine{00557\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ std::complex<typename\ truncate\_type\_impl<T>::type>;}
\DoxyCodeLine{00558\ \};}
\DoxyCodeLine{00559\ }
\DoxyCodeLine{00560\ }
\DoxyCodeLine{00561\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00562\ \textcolor{keyword}{struct\ }type\_size\_impl\ \{}
\DoxyCodeLine{00563\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ value\ =\ \textcolor{keyword}{sizeof}(T)\ *\ \doxymbox{\hyperlink{namespacegko_acae2e648052ec788bd8ba9e0192652a6}{byte\_size}};}
\DoxyCodeLine{00564\ \};}
\DoxyCodeLine{00565\ }
\DoxyCodeLine{00566\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00567\ \textcolor{keyword}{struct\ }type\_size\_impl<std::complex<T>>\ \{}
\DoxyCodeLine{00568\ \ \ \ \ \textcolor{keyword}{static}\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ value\ =\ \textcolor{keyword}{sizeof}(T)\ *\ \doxymbox{\hyperlink{namespacegko_acae2e648052ec788bd8ba9e0192652a6}{byte\_size}};}
\DoxyCodeLine{00569\ \};}
\DoxyCodeLine{00570\ }
\DoxyCodeLine{00571\ }
\DoxyCodeLine{00572\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00573\ }
\DoxyCodeLine{00574\ }
\DoxyCodeLine{00579\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T,\ \textcolor{keywordtype}{size\_t}ype\ Limit\ =\ sizeof(u\textcolor{keywordtype}{int}16)\ *\ \textcolor{keywordtype}{byte}\_size>}
\DoxyCodeLine{00580\ \textcolor{keyword}{using\ }\doxymbox{\hyperlink{namespacegko_a7b2d4de99c595e68fb962b862c1c532f}{truncate\_type}}\ =}
\DoxyCodeLine{00581\ \ \ \ \ std::conditional\_t<detail::type\_size\_impl<T>::value\ >=\ 2\ *\ Limit,}
\DoxyCodeLine{00582\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ detail::truncate\_type\_impl<T>::type,\ T>;}
\DoxyCodeLine{00583\ }
\DoxyCodeLine{00584\ }
\DoxyCodeLine{00591\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ S,\ \textcolor{keyword}{typename}\ R>}
\DoxyCodeLine{00592\ \textcolor{keyword}{struct\ }\doxymbox{\hyperlink{structgko_1_1default__converter}{default\_converter}}\ \{}
\DoxyCodeLine{00599\ \ \ \ \ GKO\_ATTRIBUTES\ R\ \doxymbox{\hyperlink{structgko_1_1default__converter_aeeb535f41abb975f20857989c8ac2470}{operator()}}(S\ val)\ \{\ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}R\textcolor{keyword}{>}(val);\ \}}
\DoxyCodeLine{00600\ \};}
\DoxyCodeLine{00601\ }
\DoxyCodeLine{00602\ }
\DoxyCodeLine{00603\ \textcolor{comment}{//\ mathematical\ functions}}
\DoxyCodeLine{00604\ }
\DoxyCodeLine{00605\ }
\DoxyCodeLine{00614\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}\ \doxymbox{\hyperlink{namespacegko_a93065a86872e6511b701b73b75823483}{ceildiv}}(\doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}\ num,\ \doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}\ den)}
\DoxyCodeLine{00615\ \{}
\DoxyCodeLine{00616\ \ \ \ \ \textcolor{keywordflow}{return}\ (num\ +\ den\ -\/\ 1)\ /\ den;}
\DoxyCodeLine{00617\ \}}
\DoxyCodeLine{00618\ }
\DoxyCodeLine{00619\ }
\DoxyCodeLine{00625\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00626\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero}}()}
\DoxyCodeLine{00627\ \{}
\DoxyCodeLine{00628\ \ \ \ \ \textcolor{keywordflow}{return}\ T\{\};}
\DoxyCodeLine{00629\ \}}
\DoxyCodeLine{00630\ }
\DoxyCodeLine{00631\ }
\DoxyCodeLine{00641\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00642\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero}}(\textcolor{keyword}{const}\ T\&)}
\DoxyCodeLine{00643\ \{}
\DoxyCodeLine{00644\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}();}
\DoxyCodeLine{00645\ \}}
\DoxyCodeLine{00646\ }
\DoxyCodeLine{00647\ }
\DoxyCodeLine{00653\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00654\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one}}()}
\DoxyCodeLine{00655\ \{}
\DoxyCodeLine{00656\ \ \ \ \ \textcolor{keywordflow}{return}\ T(1);}
\DoxyCodeLine{00657\ \}}
\DoxyCodeLine{00658\ }
\DoxyCodeLine{00659\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00660\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ half\ one<half>()}
\DoxyCodeLine{00661\ \{}
\DoxyCodeLine{00662\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ bits\ =\ \textcolor{keyword}{static\_cast<}\doxymbox{\hyperlink{namespacegko_af07ab7e285d68cde5e10f9c4ed642213}{uint16}}\textcolor{keyword}{>}(0b0'01111'0000000000u);}
\DoxyCodeLine{00663\ \ \ \ \ \textcolor{keywordflow}{return}\ half::create\_from\_bits(bits);}
\DoxyCodeLine{00664\ \}}
\DoxyCodeLine{00665\ }
\DoxyCodeLine{00666\ \textcolor{keyword}{template}\ <>}
\DoxyCodeLine{00667\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{classgko_1_1bfloat16}{bfloat16}}\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one<bfloat16>}}()}
\DoxyCodeLine{00668\ \{}
\DoxyCodeLine{00669\ \ \ \ \ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ bits\ =\ \textcolor{keyword}{static\_cast<}\doxymbox{\hyperlink{namespacegko_af07ab7e285d68cde5e10f9c4ed642213}{uint16}}\textcolor{keyword}{>}(0b0'01111111'0000000u);}
\DoxyCodeLine{00670\ \ \ \ \ \textcolor{keywordflow}{return}\ bfloat16::create\_from\_bits(bits);}
\DoxyCodeLine{00671\ \}}
\DoxyCodeLine{00672\ }
\DoxyCodeLine{00673\ }
\DoxyCodeLine{00683\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00684\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one}}(\textcolor{keyword}{const}\ T\&)}
\DoxyCodeLine{00685\ \{}
\DoxyCodeLine{00686\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one<T>}}();}
\DoxyCodeLine{00687\ \}}
\DoxyCodeLine{00688\ }
\DoxyCodeLine{00689\ }
\DoxyCodeLine{00698\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00699\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{namespacegko_a785976e6dbc9d8511325617ca46040bf}{is\_zero}}(T\ value)}
\DoxyCodeLine{00700\ \{}
\DoxyCodeLine{00701\ \ \ \ \ \textcolor{keywordflow}{return}\ value\ ==\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}();}
\DoxyCodeLine{00702\ \}}
\DoxyCodeLine{00703\ }
\DoxyCodeLine{00704\ }
\DoxyCodeLine{00713\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00714\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keywordtype}{bool}\ \doxymbox{\hyperlink{namespacegko_aef9b29733e6eb45475a2b84f79a6d012}{is\_nonzero}}(T\ value)}
\DoxyCodeLine{00715\ \{}
\DoxyCodeLine{00716\ \ \ \ \ \textcolor{keywordflow}{return}\ value\ !=\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}();}
\DoxyCodeLine{00717\ \}}
\DoxyCodeLine{00718\ }
\DoxyCodeLine{00719\ }
\DoxyCodeLine{00731\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00732\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_af1812df45c6ec07780d579a12b64c753}{max}}(\textcolor{keyword}{const}\ T\&\ x,\ \textcolor{keyword}{const}\ T\&\ y)}
\DoxyCodeLine{00733\ \{}
\DoxyCodeLine{00734\ \ \ \ \ \textcolor{keywordflow}{return}\ x\ >=\ y\ ?\ x\ :\ y;}
\DoxyCodeLine{00735\ \}}
\DoxyCodeLine{00736\ }
\DoxyCodeLine{00737\ }
\DoxyCodeLine{00749\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00750\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_aaaf8487194bcb40b528969c187a413a0}{min}}(\textcolor{keyword}{const}\ T\&\ x,\ \textcolor{keyword}{const}\ T\&\ y)}
\DoxyCodeLine{00751\ \{}
\DoxyCodeLine{00752\ \ \ \ \ \textcolor{keywordflow}{return}\ x\ <=\ y\ ?\ x\ :\ y;}
\DoxyCodeLine{00753\ \}}
\DoxyCodeLine{00754\ }
\DoxyCodeLine{00755\ }
\DoxyCodeLine{00756\ \textcolor{keyword}{namespace\ }detail\ \{}
\DoxyCodeLine{00757\ }
\DoxyCodeLine{00758\ }
\DoxyCodeLine{00768\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref,\ \textcolor{keyword}{typename}\ Dummy\ =\ std::\textcolor{keywordtype}{void}\_t<>>}
\DoxyCodeLine{00769\ \textcolor{keyword}{struct\ }has\_to\_arithmetic\_type\ :\ std::false\_type\ \{}
\DoxyCodeLine{00770\ \ \ \ \ \textcolor{keyword}{static\_assert}(std::is\_same<Dummy,\ void>::value,}
\DoxyCodeLine{00771\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Do\ not\ modify\ the\ Dummy\ value!"{}});}
\DoxyCodeLine{00772\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ Ref;}
\DoxyCodeLine{00773\ \};}
\DoxyCodeLine{00774\ }
\DoxyCodeLine{00775\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref>}
\DoxyCodeLine{00776\ \textcolor{keyword}{struct\ }has\_to\_arithmetic\_type<}
\DoxyCodeLine{00777\ \ \ \ \ Ref,\ std::\doxymbox{\hyperlink{namespacegko_1_1xstd_a2d53b45325a9d6c46906d80caf180869}{void\_t}}<decltype(std::declval<Ref>().to\_arithmetic\_type())>>}
\DoxyCodeLine{00778\ \ \ \ \ :\ std::true\_type\ \{}
\DoxyCodeLine{00779\ \ \ \ \ \textcolor{keyword}{using\ }type\ =\ \textcolor{keyword}{decltype}(std::declval<Ref>().to\_arithmetic\_type());}
\DoxyCodeLine{00780\ \};}
\DoxyCodeLine{00781\ }
\DoxyCodeLine{00782\ }
\DoxyCodeLine{00787\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref,\ \textcolor{keyword}{typename}\ Dummy\ =\ std::\textcolor{keywordtype}{void}\_t<>>}
\DoxyCodeLine{00788\ \textcolor{keyword}{struct\ }has\_arithmetic\_type\ :\ std::false\_type\ \{}
\DoxyCodeLine{00789\ \ \ \ \ \textcolor{keyword}{static\_assert}(std::is\_same<Dummy,\ void>::value,}
\DoxyCodeLine{00790\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{stringliteral}{"{}Do\ not\ modify\ the\ Dummy\ value!"{}});}
\DoxyCodeLine{00791\ \};}
\DoxyCodeLine{00792\ }
\DoxyCodeLine{00793\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref>}
\DoxyCodeLine{00794\ \textcolor{keyword}{struct\ }has\_arithmetic\_type<Ref,\ std::\doxymbox{\hyperlink{namespacegko_1_1xstd_a2d53b45325a9d6c46906d80caf180869}{void\_t}}<typename\ Ref::arithmetic\_type>>}
\DoxyCodeLine{00795\ \ \ \ \ :\ std::true\_type\ \{\};}
\DoxyCodeLine{00796\ }
\DoxyCodeLine{00797\ }
\DoxyCodeLine{00809\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref>}
\DoxyCodeLine{00810\ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES}
\DoxyCodeLine{00811\ \ \ \ \ std::enable\_if\_t<has\_to\_arithmetic\_type<Ref>::value,}
\DoxyCodeLine{00812\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ has\_to\_arithmetic\_type<Ref>::type>}
\DoxyCodeLine{00813\ \ \ \ \ to\_arithmetic\_type(\textcolor{keyword}{const}\ Ref\&\ ref)}
\DoxyCodeLine{00814\ \{}
\DoxyCodeLine{00815\ \ \ \ \ \textcolor{keywordflow}{return}\ ref.to\_arithmetic\_type();}
\DoxyCodeLine{00816\ \}}
\DoxyCodeLine{00817\ }
\DoxyCodeLine{00818\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref>}
\DoxyCodeLine{00819\ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ std::enable\_if\_t<!has\_to\_arithmetic\_type<Ref>::value\ \&\&}
\DoxyCodeLine{00820\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ has\_arithmetic\_type<Ref>::value,}
\DoxyCodeLine{00821\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{typename}\ Ref::arithmetic\_type>}
\DoxyCodeLine{00822\ to\_arithmetic\_type(\textcolor{keyword}{const}\ Ref\&\ ref)}
\DoxyCodeLine{00823\ \{}
\DoxyCodeLine{00824\ \ \ \ \ \textcolor{keywordflow}{return}\ ref;}
\DoxyCodeLine{00825\ \}}
\DoxyCodeLine{00826\ }
\DoxyCodeLine{00827\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ Ref>}
\DoxyCodeLine{00828\ \textcolor{keyword}{constexpr}\ GKO\_ATTRIBUTES\ std::enable\_if\_t<!has\_to\_arithmetic\_type<Ref>::value\ \&\&}
\DoxyCodeLine{00829\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ !has\_arithmetic\_type<Ref>::value,}
\DoxyCodeLine{00830\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Ref>}
\DoxyCodeLine{00831\ to\_arithmetic\_type(\textcolor{keyword}{const}\ Ref\&\ ref)}
\DoxyCodeLine{00832\ \{}
\DoxyCodeLine{00833\ \ \ \ \ \textcolor{keywordflow}{return}\ ref;}
\DoxyCodeLine{00834\ \}}
\DoxyCodeLine{00835\ }
\DoxyCodeLine{00836\ }
\DoxyCodeLine{00837\ \textcolor{comment}{//\ Note:\ All\ functions\ have\ postfix\ \`{}impl`\ so\ they\ are\ not\ considered\ for}}
\DoxyCodeLine{00838\ \textcolor{comment}{//\ overload\ resolution\ (in\ case\ a\ class\ /\ function\ also\ is\ in\ the\ namespace}}
\DoxyCodeLine{00839\ \textcolor{comment}{//\ \`{}detail`)}}
\DoxyCodeLine{00840\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00841\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ T>}
\DoxyCodeLine{00842\ real\_impl(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00843\ \{}
\DoxyCodeLine{00844\ \ \ \ \ \textcolor{keywordflow}{return}\ x;}
\DoxyCodeLine{00845\ \}}
\DoxyCodeLine{00846\ }
\DoxyCodeLine{00847\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00848\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<is\_complex\_s<T>::value,}
\DoxyCodeLine{00849\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}>}
\DoxyCodeLine{00850\ real\_impl(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00851\ \{}
\DoxyCodeLine{00852\ \ \ \ \ \textcolor{keywordflow}{return}\ x.real();}
\DoxyCodeLine{00853\ \}}
\DoxyCodeLine{00854\ }
\DoxyCodeLine{00855\ }
\DoxyCodeLine{00856\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00857\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ T>}
\DoxyCodeLine{00858\ imag\_impl(\textcolor{keyword}{const}\ T\&)}
\DoxyCodeLine{00859\ \{}
\DoxyCodeLine{00860\ \ \ \ \ \textcolor{keywordflow}{return}\ T\{\};}
\DoxyCodeLine{00861\ \}}
\DoxyCodeLine{00862\ }
\DoxyCodeLine{00863\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00864\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<is\_complex\_s<T>::value,}
\DoxyCodeLine{00865\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}>}
\DoxyCodeLine{00866\ imag\_impl(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00867\ \{}
\DoxyCodeLine{00868\ \ \ \ \ \textcolor{keywordflow}{return}\ x.imag();}
\DoxyCodeLine{00869\ \}}
\DoxyCodeLine{00870\ }
\DoxyCodeLine{00871\ }
\DoxyCodeLine{00872\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00873\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ T>}
\DoxyCodeLine{00874\ conj\_impl(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00875\ \{}
\DoxyCodeLine{00876\ \ \ \ \ \textcolor{keywordflow}{return}\ x;}
\DoxyCodeLine{00877\ \}}
\DoxyCodeLine{00878\ }
\DoxyCodeLine{00879\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00880\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<is\_complex\_s<T>::value,\ T>}
\DoxyCodeLine{00881\ conj\_impl(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00882\ \{}
\DoxyCodeLine{00883\ \ \ \ \ \textcolor{keywordflow}{return}\ T\{real\_impl(x),\ -\/imag\_impl(x)\};}
\DoxyCodeLine{00884\ \}}
\DoxyCodeLine{00885\ }
\DoxyCodeLine{00886\ }
\DoxyCodeLine{00887\ \}\ \ \textcolor{comment}{//\ namespace\ detail}}
\DoxyCodeLine{00888\ }
\DoxyCodeLine{00889\ }
\DoxyCodeLine{00899\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00900\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_af21648097306adbabc6234b4609ce297}{real}}(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00901\ \{}
\DoxyCodeLine{00902\ \ \ \ \ \textcolor{keywordflow}{return}\ detail::real\_impl(detail::to\_arithmetic\_type(x));}
\DoxyCodeLine{00903\ \}}
\DoxyCodeLine{00904\ }
\DoxyCodeLine{00905\ }
\DoxyCodeLine{00915\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00916\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_a795f649e3744fbfe128aec0b0f928aaa}{imag}}(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00917\ \{}
\DoxyCodeLine{00918\ \ \ \ \ \textcolor{keywordflow}{return}\ detail::imag\_impl(detail::to\_arithmetic\_type(x));}
\DoxyCodeLine{00919\ \}}
\DoxyCodeLine{00920\ }
\DoxyCodeLine{00921\ }
\DoxyCodeLine{00929\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00930\ GKO\_ATTRIBUTES\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_ad79fd5c1fb85403796c40c0a916a15f2}{conj}}(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00931\ \{}
\DoxyCodeLine{00932\ \ \ \ \ \textcolor{keywordflow}{return}\ detail::conj\_impl(detail::to\_arithmetic\_type(x));}
\DoxyCodeLine{00933\ \}}
\DoxyCodeLine{00934\ }
\DoxyCodeLine{00935\ }
\DoxyCodeLine{00943\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00944\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ \textcolor{keyword}{auto}\ \doxymbox{\hyperlink{namespacegko_abbb55709b10d707b2cbef803832aa834}{squared\_norm}}(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00945\ \ \ \ \ -\/>\ \textcolor{keyword}{decltype}(\doxymbox{\hyperlink{namespacegko_af21648097306adbabc6234b4609ce297}{real}}(\doxymbox{\hyperlink{namespacegko_ad79fd5c1fb85403796c40c0a916a15f2}{conj}}(x)\ *\ x))}
\DoxyCodeLine{00946\ \{}
\DoxyCodeLine{00947\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_af21648097306adbabc6234b4609ce297}{real}}(\doxymbox{\hyperlink{namespacegko_ad79fd5c1fb85403796c40c0a916a15f2}{conj}}(x)\ *\ x);}
\DoxyCodeLine{00948\ \}}
\DoxyCodeLine{00949\ }
\DoxyCodeLine{00950\ \textcolor{keyword}{using\ }std::abs;}
\DoxyCodeLine{00951\ }
\DoxyCodeLine{00961\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00962\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ T>\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(}
\DoxyCodeLine{00963\ \ \ \ \ \textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00964\ \{}
\DoxyCodeLine{00965\ \ \ \ \ \textcolor{keywordflow}{return}\ x\ >=\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}()\ ?\ x\ :\ -\/x;}
\DoxyCodeLine{00966\ \}}
\DoxyCodeLine{00967\ }
\DoxyCodeLine{00968\ }
\DoxyCodeLine{00969\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{00970\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<is\_complex\_s<T>::value,\ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}>}
\DoxyCodeLine{00971\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(\textcolor{keyword}{const}\ T\&\ x)}
\DoxyCodeLine{00972\ \{}
\DoxyCodeLine{00973\ \ \ \ \ \textcolor{keywordflow}{return}\ sqrt(\doxymbox{\hyperlink{namespacegko_abbb55709b10d707b2cbef803832aa834}{squared\_norm}}(x));}
\DoxyCodeLine{00974\ \}}
\DoxyCodeLine{00975\ }
\DoxyCodeLine{00976\ \textcolor{comment}{//\ increase\ the\ priority\ in\ function\ lookup}}
\DoxyCodeLine{00977\ GKO\_INLINE\ gko::half\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(\textcolor{keyword}{const}\ std::complex<gko::half>\&\ x)}
\DoxyCodeLine{00978\ \{}
\DoxyCodeLine{00979\ \ \ \ \ \textcolor{comment}{//\ Using\ float\ abs\ not\ sqrt\ on\ norm\ to\ avoid\ overflow}}
\DoxyCodeLine{00980\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}gko::half\textcolor{keyword}{>}(\doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(std::complex<float>(x)));}
\DoxyCodeLine{00981\ \}}
\DoxyCodeLine{00982\ }
\DoxyCodeLine{00983\ GKO\_INLINE\ gko::bfloat16\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(\textcolor{keyword}{const}\ std::complex<gko::bfloat16>\&\ x)}
\DoxyCodeLine{00984\ \{}
\DoxyCodeLine{00985\ \ \ \ \ \textcolor{comment}{//\ Using\ float\ abs\ not\ sqrt\ on\ norm\ to\ avoid\ overflow}}
\DoxyCodeLine{00986\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}gko::bfloat16\textcolor{keyword}{>}(\doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(std::complex<float>(x)));}
\DoxyCodeLine{00987\ \}}
\DoxyCodeLine{00988\ }
\DoxyCodeLine{00989\ }
\DoxyCodeLine{00990\ \textcolor{keyword}{using\ }std::sqrt;}
\DoxyCodeLine{00991\ }
\DoxyCodeLine{00992\ GKO\_INLINE\ gko::half\ sqrt(gko::half\ a)}
\DoxyCodeLine{00993\ \{}
\DoxyCodeLine{00994\ \ \ \ \ \textcolor{keywordflow}{return}\ gko::half(std::sqrt(\textcolor{keywordtype}{float}(a)));}
\DoxyCodeLine{00995\ \}}
\DoxyCodeLine{00996\ }
\DoxyCodeLine{00997\ GKO\_INLINE\ std::complex<gko::half>\ sqrt(std::complex<gko::half>\ a)}
\DoxyCodeLine{00998\ \{}
\DoxyCodeLine{00999\ \ \ \ \ \textcolor{keywordflow}{return}\ std::complex<gko::half>(sqrt(std::complex<float>(}
\DoxyCodeLine{01000\ \ \ \ \ \ \ \ \ \textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{float}\textcolor{keyword}{>}(a.real()),\ \textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{float}\textcolor{keyword}{>}(a.imag()))));}
\DoxyCodeLine{01001\ \}}
\DoxyCodeLine{01002\ }
\DoxyCodeLine{01003\ GKO\_INLINE\ gko::bfloat16\ sqrt(gko::bfloat16\ a)}
\DoxyCodeLine{01004\ \{}
\DoxyCodeLine{01005\ \ \ \ \ \textcolor{keywordflow}{return}\ gko::bfloat16(std::sqrt(\textcolor{keywordtype}{float}(a)));}
\DoxyCodeLine{01006\ \}}
\DoxyCodeLine{01007\ }
\DoxyCodeLine{01008\ GKO\_INLINE\ std::complex<gko::bfloat16>\ sqrt(std::complex<gko::bfloat16>\ a)}
\DoxyCodeLine{01009\ \{}
\DoxyCodeLine{01010\ \ \ \ \ \textcolor{keywordflow}{return}\ std::complex<gko::bfloat16>(sqrt(std::complex<float>(}
\DoxyCodeLine{01011\ \ \ \ \ \ \ \ \ \textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{float}\textcolor{keyword}{>}(a.real()),\ \textcolor{keyword}{static\_cast<}\textcolor{keywordtype}{float}\textcolor{keyword}{>}(a.imag()))));}
\DoxyCodeLine{01012\ \}}
\DoxyCodeLine{01013\ }
\DoxyCodeLine{01014\ }
\DoxyCodeLine{01020\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01021\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_a0603ce0a60183a6698ac9b523694fb68}{pi}}()}
\DoxyCodeLine{01022\ \{}
\DoxyCodeLine{01023\ \ \ \ \ \textcolor{keywordflow}{return}\ \textcolor{keyword}{static\_cast<}T\textcolor{keyword}{>}(3.1415926535897932384626433);}
\DoxyCodeLine{01024\ \}}
\DoxyCodeLine{01025\ }
\DoxyCodeLine{01026\ }
\DoxyCodeLine{01035\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01036\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::complex<remove\_complex<T>>\ \doxymbox{\hyperlink{namespacegko_a7d18aa213befc4d1dac5dbc8eeed6e7d}{unit\_root}}(\doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}\ n,}
\DoxyCodeLine{01037\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a913ec044df518649fa5a891f8dffae34}{int64}}\ k\ =\ 1)}
\DoxyCodeLine{01038\ \{}
\DoxyCodeLine{01039\ \ \ \ \ \textcolor{keywordflow}{return}\ std::polar(\doxymbox{\hyperlink{namespacegko_a0059e27f8f4bc348ff65c1e60caf47c8}{one}}<\doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}>(),}
\DoxyCodeLine{01040\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}\{2\}\ *\ \doxymbox{\hyperlink{namespacegko_a0603ce0a60183a6698ac9b523694fb68}{pi<remove\_complex<T>}}>()\ *\ k\ /\ n);}
\DoxyCodeLine{01041\ \}}
\DoxyCodeLine{01042\ }
\DoxyCodeLine{01043\ }
\DoxyCodeLine{01056\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01057\ \textcolor{keyword}{constexpr}\ \doxymbox{\hyperlink{namespacegko_a7cf056fa904140b50658e0637fba428c}{uint32}}\ \doxymbox{\hyperlink{namespacegko_a4eea40e4123a3fdb60fcd92f902c6d6d}{get\_significant\_bit}}(\textcolor{keyword}{const}\ T\&\ n,\ \doxymbox{\hyperlink{namespacegko_a7cf056fa904140b50658e0637fba428c}{uint32}}\ hint\ =\ 0u)\ \textcolor{keyword}{noexcept}}
\DoxyCodeLine{01058\ \{}
\DoxyCodeLine{01059\ \ \ \ \ \textcolor{keywordflow}{return}\ (T\{1\}\ <<\ (hint\ +\ 1))\ >\ n\ ?\ hint\ :\ \doxymbox{\hyperlink{namespacegko_a4eea40e4123a3fdb60fcd92f902c6d6d}{get\_significant\_bit}}(n,\ hint\ +\ 1u);}
\DoxyCodeLine{01060\ \}}
\DoxyCodeLine{01061\ }
\DoxyCodeLine{01062\ }
\DoxyCodeLine{01074\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01075\ \textcolor{keyword}{constexpr}\ T\ \doxymbox{\hyperlink{namespacegko_ad39645fe8148a8a812a9528865a77600}{get\_superior\_power}}(\textcolor{keyword}{const}\ T\&\ base,\ \textcolor{keyword}{const}\ T\&\ limit,}
\DoxyCodeLine{01076\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \textcolor{keyword}{const}\ T\&\ hint\ =\ T\{1\})\ \textcolor{keyword}{noexcept}}
\DoxyCodeLine{01077\ \{}
\DoxyCodeLine{01078\ \ \ \ \ \textcolor{keywordflow}{return}\ hint\ >=\ limit\ ?\ hint\ :\ \doxymbox{\hyperlink{namespacegko_ad39645fe8148a8a812a9528865a77600}{get\_superior\_power}}(base,\ limit,\ hint\ *\ base);}
\DoxyCodeLine{01079\ \}}
\DoxyCodeLine{01080\ }
\DoxyCodeLine{01081\ }
\DoxyCodeLine{01093\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01094\ GKO\_INLINE\ GKO\_ATTRIBUTES\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ \textcolor{keywordtype}{bool}>}
\DoxyCodeLine{01095\ \doxymbox{\hyperlink{namespacegko_a01e4cc92b86977c60de3fe3ee991fa40}{is\_finite}}(\textcolor{keyword}{const}\ T\&\ value)}
\DoxyCodeLine{01096\ \{}
\DoxyCodeLine{01097\ \ \ \ \ \textcolor{keyword}{constexpr}\ T\ infinity\{detail::infinity\_impl<T>::value\};}
\DoxyCodeLine{01098\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_a0cb7d0ece3444fcf3a7ebd82e1cb0a69}{abs}}(value)\ <\ infinity;}
\DoxyCodeLine{01099\ \}}
\DoxyCodeLine{01100\ }
\DoxyCodeLine{01101\ }
\DoxyCodeLine{01113\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01114\ GKO\_INLINE\ GKO\_ATTRIBUTES\ std::enable\_if\_t<is\_complex\_s<T>::value,\ \textcolor{keywordtype}{bool}>}
\DoxyCodeLine{01115\ \doxymbox{\hyperlink{namespacegko_a01e4cc92b86977c60de3fe3ee991fa40}{is\_finite}}(\textcolor{keyword}{const}\ T\&\ value)}
\DoxyCodeLine{01116\ \{}
\DoxyCodeLine{01117\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_a01e4cc92b86977c60de3fe3ee991fa40}{is\_finite}}(value.real())\ \&\&\ \doxymbox{\hyperlink{namespacegko_a01e4cc92b86977c60de3fe3ee991fa40}{is\_finite}}(value.imag());}
\DoxyCodeLine{01118\ \}}
\DoxyCodeLine{01119\ }
\DoxyCodeLine{01120\ }
\DoxyCodeLine{01132\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01133\ GKO\_INLINE\ GKO\_ATTRIBUTES\ T\ \doxymbox{\hyperlink{namespacegko_aa1470fdc2a75dcda76bea4b879a29886}{safe\_divide}}(T\ a,\ T\ b)}
\DoxyCodeLine{01134\ \{}
\DoxyCodeLine{01135\ \ \ \ \ \textcolor{keywordflow}{return}\ b\ ==\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}()\ ?\ \doxymbox{\hyperlink{namespacegko_a70dbe01ff95c7b953d3d737424c6feb5}{zero<T>}}()\ :\ a\ /\ b;}
\DoxyCodeLine{01136\ \}}
\DoxyCodeLine{01137\ }
\DoxyCodeLine{01138\ }
\DoxyCodeLine{01148\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01149\ GKO\_DEPRECATED(}
\DoxyCodeLine{01150\ \ \ \ \ \textcolor{stringliteral}{"{}is\_nan\ can't\ be\ used\ safely\ on\ the\ device\ (MSVC+CUDA),\ and\ will\ thus\ be\ "{}}}
\DoxyCodeLine{01151\ \ \ \ \ \textcolor{stringliteral}{"{}removed\ in\ a\ future\ release,\ without\ replacement"{}})}
\DoxyCodeLine{01152\ GKO\_INLINE\ GKO\_ATTRIBUTES}
\DoxyCodeLine{01153\ \ \ \ \ \doxymbox{\hyperlink{namespacestd}{std}}::enable\_if\_t<!\doxymbox{\hyperlink{namespacegko_a700d12db3a341bb7a46bede49e1d6715}{is\_complex\_s}}<T>::value,\ \textcolor{keywordtype}{bool}>\ \doxymbox{\hyperlink{namespacegko_a6f943e1343264921351afce70b33009a}{is\_nan}}(const\ T\&\ value)}
\DoxyCodeLine{01154\ \{}
\DoxyCodeLine{01155\ \ \ \ \ \textcolor{keyword}{using\ }std::isnan;}
\DoxyCodeLine{01156\ \ \ \ \ \textcolor{keywordflow}{return}\ isnan(value);}
\DoxyCodeLine{01157\ \}}
\DoxyCodeLine{01158\ }
\DoxyCodeLine{01159\ }
\DoxyCodeLine{01169\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01170\ GKO\_DEPRECATED(}
\DoxyCodeLine{01171\ \ \ \ \ \textcolor{stringliteral}{"{}is\_nan\ can't\ be\ used\ safely\ on\ the\ device\ (MSVC+CUDA),\ and\ will\ thus\ be\ "{}}}
\DoxyCodeLine{01172\ \ \ \ \ \textcolor{stringliteral}{"{}removed\ in\ a\ future\ release,\ without\ replacement"{}})}
\DoxyCodeLine{01173\ GKO\_INLINE\ GKO\_ATTRIBUTES\ \doxymbox{\hyperlink{namespacestd}{std}}::enable\_if\_t<\doxymbox{\hyperlink{namespacegko_a700d12db3a341bb7a46bede49e1d6715}{is\_complex\_s}}<T>::value,\ \textcolor{keywordtype}{bool}>\ \doxymbox{\hyperlink{namespacegko_a6f943e1343264921351afce70b33009a}{is\_nan}}(}
\DoxyCodeLine{01174\ \ \ \ \ const\ T\&\ value)}
\DoxyCodeLine{01175\ \{}
\DoxyCodeLine{01176\ \ \ \ \ \textcolor{keywordflow}{return}\ \doxymbox{\hyperlink{namespacegko_a6f943e1343264921351afce70b33009a}{is\_nan}}(value.real())\ ||\ \doxymbox{\hyperlink{namespacegko_a6f943e1343264921351afce70b33009a}{is\_nan}}(value.imag());}
\DoxyCodeLine{01177\ \}}
\DoxyCodeLine{01178\ }
\DoxyCodeLine{01179\ }
\DoxyCodeLine{01187\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01188\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<!is\_complex\_s<T>::value,\ T>\ \doxymbox{\hyperlink{namespacegko_a70bf9f2c62b689f4f7e074392be0f828}{nan}}()}
\DoxyCodeLine{01189\ \{}
\DoxyCodeLine{01190\ \ \ \ \ \textcolor{keywordflow}{return}\ std::numeric\_limits<T>::quiet\_NaN();}
\DoxyCodeLine{01191\ \}}
\DoxyCodeLine{01192\ }
\DoxyCodeLine{01193\ }
\DoxyCodeLine{01201\ \textcolor{keyword}{template}\ <\textcolor{keyword}{typename}\ T>}
\DoxyCodeLine{01202\ GKO\_INLINE\ \textcolor{keyword}{constexpr}\ std::enable\_if\_t<is\_complex\_s<T>::value,\ T>\ \doxymbox{\hyperlink{namespacegko_a70bf9f2c62b689f4f7e074392be0f828}{nan}}()}
\DoxyCodeLine{01203\ \{}
\DoxyCodeLine{01204\ \ \ \ \ \textcolor{keywordflow}{return}\ T\{\doxymbox{\hyperlink{namespacegko_a70bf9f2c62b689f4f7e074392be0f828}{nan<remove\_complex<T>}}>(),\ \doxymbox{\hyperlink{namespacegko_a70bf9f2c62b689f4f7e074392be0f828}{nan}}<\doxymbox{\hyperlink{namespacegko_a107302a750bfa82a2107c77293f791c9}{remove\_complex<T>}}>()\};}
\DoxyCodeLine{01205\ \}}
\DoxyCodeLine{01206\ }
\DoxyCodeLine{01207\ }
\DoxyCodeLine{01208\ \}\ \ \textcolor{comment}{//\ namespace\ gko}}
\DoxyCodeLine{01209\ }
\DoxyCodeLine{01210\ }
\DoxyCodeLine{01211\ \textcolor{preprocessor}{\#endif\ \ }\textcolor{comment}{//\ GKO\_PUBLIC\_CORE\_BASE\_MATH\_HPP\_}}

\end{DoxyCode}
