Loading src/TNL/Containers/Expressions/ExpressionTemplatesOperations.h +70 −40 Original line number Diff line number Diff line Loading @@ -97,93 +97,103 @@ struct Abs }; template< typename T1 > struct Sin struct Pow { template< typename Real > __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::sin( a ) ) static auto evaluate( const T1& a, const Real& exp ) -> decltype( TNL::pow( a, exp ) ) { return TNL::sin( a ); return TNL::pow( a, exp ); } }; template< typename T1 > struct Cos struct Exp { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::cos( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::exp( a ) ) { return TNL::cos( a ); return TNL::exp( a ); } }; template< typename T1 > struct Tan struct Sqrt { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::tan( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::sqrt( a ) ) { return TNL::tan( a ); return TNL::sqrt( a ); } }; template< typename T1 > struct Sqrt struct Cbrt { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::sqrt( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::cbrt( a ) ) { return TNL::sqrt( a ); return TNL::cbrt( a ); } }; template< typename T1 > struct Cbrt struct Log { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::cbrt( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log( a ) ) { return TNL::cbrt( a ); return TNL::log( a ); } }; template< typename T1 > struct Pow struct Log10 { template< typename Real > __cuda_callable__ static auto evaluate( const T1& a, const Real& exp ) -> decltype( TNL::pow( a, exp ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log10( a ) ) { return TNL::pow( a, exp ); return TNL::log10( a ); } }; template< typename T1 > struct Floor struct Log2 { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::floor( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log2( a ) ) { return TNL::floor( a ); return TNL::log2( a ); } }; template< typename T1 > struct Ceil struct Sin { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::ceil( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::sin( a ) ) { return TNL::ceil( a ); return TNL::sin( a ); } }; template< typename T1 > struct Acos struct Cos { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::acos( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::cos( a ) ) { return TNL::acos( a ); return TNL::cos( a ); } }; template< typename T1 > struct Tan { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::tan( a ) ) { return TNL::tan( a ); } }; Loading @@ -197,6 +207,16 @@ struct Asin } }; template< typename T1 > struct Acos { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::acos( a ) ) { return TNL::acos( a ); } }; template< typename T1 > struct Atan { Loading Loading @@ -238,42 +258,52 @@ struct Tanh }; template< typename T1 > struct Log struct Asinh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::asinh( a ) ) { return TNL::log( a ); return TNL::asinh( a ); } }; template< typename T1 > struct Log10 struct Acosh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log10( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::acosh( a ) ) { return TNL::log10( a ); return TNL::acosh( a ); } }; template< typename T1 > struct Log2 struct Atanh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log2( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::atanh( a ) ) { return TNL::log2( a ); return TNL::atanh( a ); } }; template< typename T1 > struct Exp struct Floor { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::exp( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::floor( a ) ) { return TNL::exp( a ); return TNL::floor( a ); } }; template< typename T1 > struct Ceil { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::ceil( a ) ) { return TNL::ceil( a ); } }; Loading src/TNL/Containers/VectorExpressions.h +80 −40 Original line number Diff line number Diff line Loading @@ -699,93 +699,103 @@ abs( const Containers::Vector< Real, Device, Index, Allocator >& a ) } //// // Sine // Power template< typename Real, typename Device, typename Index, typename Allocator, typename ExpType > auto pow( const Containers::Vector< Real, Device, Index, Allocator >& a, const ExpType& exp ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Pow, ExpType >( a.getConstView(), exp ); } //// // Exp template< typename Real, typename Device, typename Index, typename Allocator > auto sin( const Containers::Vector< Real, Device, Index, Allocator >& a ) exp( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sin >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Exp >( a.getConstView() ); } //// // Cosine // Sqrt template< typename Real, typename Device, typename Index, typename Allocator > auto cos( const Containers::Vector< Real, Device, Index, Allocator >& a ) sqrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cos >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sqrt >( a.getConstView() ); } //// // Tangent // Cbrt template< typename Real, typename Device, typename Index, typename Allocator > auto tan( const Containers::Vector< Real, Device, Index, Allocator >& a ) cbrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Tan >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cbrt >( a.getConstView() ); } //// // Sqrt // Log template< typename Real, typename Device, typename Index, typename Allocator > auto sqrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) log( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sqrt >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log >( a.getConstView() ); } //// // Cbrt // Log10 template< typename Real, typename Device, typename Index, typename Allocator > auto cbrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) log10( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cbrt >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log10 >( a.getConstView() ); } //// // Power template< typename Real, typename Device, typename Index, typename Allocator, typename ExpType > // Log2 template< typename Real, typename Device, typename Index, typename Allocator > auto pow( const Containers::Vector< Real, Device, Index, Allocator >& a, const ExpType& exp ) log2( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Pow, ExpType >( a.getConstView(), exp ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log2 >( a.getConstView() ); } //// // Floor // Sine template< typename Real, typename Device, typename Index, typename Allocator > auto floor( const Containers::Vector< Real, Device, Index, Allocator >& a ) sin( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Floor >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sin >( a.getConstView() ); } //// // Ceil // Cosine template< typename Real, typename Device, typename Index, typename Allocator > auto ceil( const Containers::Vector< Real, Device, Index, Allocator >& a ) cos( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Ceil >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cos >( a.getConstView() ); } //// // Acos // Tangent template< typename Real, typename Device, typename Index, typename Allocator > auto acos( const Containers::Vector< Real, Device, Index, Allocator >& a ) tan( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acos >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Tan >( a.getConstView() ); } //// Loading @@ -798,6 +808,16 @@ asin( const Containers::Vector< Real, Device, Index, Allocator >& a ) return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Asin >( a.getConstView() ); } //// // Acos template< typename Real, typename Device, typename Index, typename Allocator > auto acos( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acos >( a.getConstView() ); } //// // Atan template< typename Real, typename Device, typename Index, typename Allocator > Loading @@ -808,6 +828,16 @@ atan( const Containers::Vector< Real, Device, Index, Allocator >& a ) return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Atan >( a.getConstView() ); } //// // Sinh template< typename Real, typename Device, typename Index, typename Allocator > auto sinh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sinh >( a.getConstView() ); } //// // Cosh template< typename Real, typename Device, typename Index, typename Allocator > Loading @@ -829,43 +859,53 @@ tanh( const Containers::Vector< Real, Device, Index, Allocator >& a ) } //// // Log // Asinh template< typename Real, typename Device, typename Index, typename Allocator > auto log( const Containers::Vector< Real, Device, Index, Allocator >& a ) asinh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Asinh >( a.getConstView() ); } //// // Log10 // Acosh template< typename Real, typename Device, typename Index, typename Allocator > auto log10( const Containers::Vector< Real, Device, Index, Allocator >& a ) acosh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log10 >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acosh >( a.getConstView() ); } //// // Log2 // Atanh template< typename Real, typename Device, typename Index, typename Allocator > auto log2( const Containers::Vector< Real, Device, Index, Allocator >& a ) atanh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log2 >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Atanh >( a.getConstView() ); } //// // Exp // Floor template< typename Real, typename Device, typename Index, typename Allocator > auto exp( const Containers::Vector< Real, Device, Index, Allocator >& a ) floor( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Exp >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Floor >( a.getConstView() ); } //// // Ceil template< typename Real, typename Device, typename Index, typename Allocator > auto ceil( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Ceil >( a.getConstView() ); } //// Loading src/TNL/Containers/VectorViewExpressions.h +76 −40 Original line number Diff line number Diff line Loading @@ -377,84 +377,93 @@ abs( const Containers::VectorView< Real, Device, Index >& a ) } //// // Sine // Power template< typename Real, typename Device, typename Index, typename ExpType > auto pow( const Containers::VectorView< Real, Device, Index >& a, const ExpType& exp ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Pow, ExpType >( a, exp ); } //// // Exp template< typename Real, typename Device, typename Index > auto sin( const Containers::VectorView< Real, Device, Index >& a ) exp( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sin >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Exp >( a ); } //// // Cosine // Sqrt template< typename Real, typename Device, typename Index > auto cos( const Containers::VectorView< Real, Device, Index >& a ) sqrt( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cos >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sqrt >( a ); } //// // Tangent // Cbrt template< typename Real, typename Device, typename Index > auto tan( const Containers::VectorView< Real, Device, Index >& a ) cbrt( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Tan >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cbrt >( a ); } //// // Sqrt // Log template< typename Real, typename Device, typename Index > auto sqrt( const Containers::VectorView< Real, Device, Index >& a ) log( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sqrt >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log >( a ); } //// // Cbrt // Log10 template< typename Real, typename Device, typename Index > auto cbrt( const Containers::VectorView< Real, Device, Index >& a ) log10( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cbrt >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log10 >( a ); } //// // Power template< typename Real, typename Device, typename Index, typename ExpType > // Log2 template< typename Real, typename Device, typename Index > auto pow( const Containers::VectorView< Real, Device, Index >& a, const ExpType& exp ) log2( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Pow, ExpType >( a, exp ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log2 >( a ); } //// // Floor // Sine template< typename Real, typename Device, typename Index > auto floor( const Containers::VectorView< Real, Device, Index >& a ) sin( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Floor >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sin >( a ); } //// // Ceil // Cosine template< typename Real, typename Device, typename Index > auto ceil( const Containers::VectorView< Real, Device, Index >& a ) cos( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Ceil >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cos >( a ); } //// // Acos // Tangent template< typename Real, typename Device, typename Index > auto acos( const Containers::VectorView< Real, Device, Index >& a ) tan( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acos >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Tan >( a ); } //// Loading @@ -466,6 +475,15 @@ asin( const Containers::VectorView< Real, Device, Index >& a ) return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Asin >( a ); } //// // Acos template< typename Real, typename Device, typename Index > auto acos( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acos >( a ); } //// // Atan template< typename Real, typename Device, typename Index > Loading @@ -475,6 +493,15 @@ atan( const Containers::VectorView< Real, Device, Index >& a ) return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Atan >( a ); } //// // Sinh template< typename Real, typename Device, typename Index > auto sinh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sinh >( a ); } //// // Cosh template< typename Real, typename Device, typename Index > Loading @@ -494,39 +521,48 @@ tanh( const Containers::VectorView< Real, Device, Index >& a ) } //// // Log // Asinh template< typename Real, typename Device, typename Index > auto log( const Containers::VectorView< Real, Device, Index >& a ) asinh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Asinh >( a ); } //// // Log10 // Acosh template< typename Real, typename Device, typename Index > auto log10( const Containers::VectorView< Real, Device, Index >& a ) acosh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log10 >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acosh >( a ); } //// // Log2 // Atanh template< typename Real, typename Device, typename Index > auto log2( const Containers::VectorView< Real, Device, Index >& a ) atanh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log2 >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Atanh >( a ); } //// // Exp // Floor template< typename Real, typename Device, typename Index > auto exp( const Containers::VectorView< Real, Device, Index >& a ) floor( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Exp >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Floor >( a ); } //// // Ceil template< typename Real, typename Device, typename Index > auto ceil( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Ceil >( a ); } //// Loading src/TNL/Math.h +89 −42 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
src/TNL/Containers/Expressions/ExpressionTemplatesOperations.h +70 −40 Original line number Diff line number Diff line Loading @@ -97,93 +97,103 @@ struct Abs }; template< typename T1 > struct Sin struct Pow { template< typename Real > __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::sin( a ) ) static auto evaluate( const T1& a, const Real& exp ) -> decltype( TNL::pow( a, exp ) ) { return TNL::sin( a ); return TNL::pow( a, exp ); } }; template< typename T1 > struct Cos struct Exp { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::cos( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::exp( a ) ) { return TNL::cos( a ); return TNL::exp( a ); } }; template< typename T1 > struct Tan struct Sqrt { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::tan( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::sqrt( a ) ) { return TNL::tan( a ); return TNL::sqrt( a ); } }; template< typename T1 > struct Sqrt struct Cbrt { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::sqrt( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::cbrt( a ) ) { return TNL::sqrt( a ); return TNL::cbrt( a ); } }; template< typename T1 > struct Cbrt struct Log { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::cbrt( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log( a ) ) { return TNL::cbrt( a ); return TNL::log( a ); } }; template< typename T1 > struct Pow struct Log10 { template< typename Real > __cuda_callable__ static auto evaluate( const T1& a, const Real& exp ) -> decltype( TNL::pow( a, exp ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log10( a ) ) { return TNL::pow( a, exp ); return TNL::log10( a ); } }; template< typename T1 > struct Floor struct Log2 { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::floor( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::log2( a ) ) { return TNL::floor( a ); return TNL::log2( a ); } }; template< typename T1 > struct Ceil struct Sin { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::ceil( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::sin( a ) ) { return TNL::ceil( a ); return TNL::sin( a ); } }; template< typename T1 > struct Acos struct Cos { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::acos( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::cos( a ) ) { return TNL::acos( a ); return TNL::cos( a ); } }; template< typename T1 > struct Tan { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::tan( a ) ) { return TNL::tan( a ); } }; Loading @@ -197,6 +207,16 @@ struct Asin } }; template< typename T1 > struct Acos { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::acos( a ) ) { return TNL::acos( a ); } }; template< typename T1 > struct Atan { Loading Loading @@ -238,42 +258,52 @@ struct Tanh }; template< typename T1 > struct Log struct Asinh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::asinh( a ) ) { return TNL::log( a ); return TNL::asinh( a ); } }; template< typename T1 > struct Log10 struct Acosh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log10( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::acosh( a ) ) { return TNL::log10( a ); return TNL::acosh( a ); } }; template< typename T1 > struct Log2 struct Atanh { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::log2( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::atanh( a ) ) { return TNL::log2( a ); return TNL::atanh( a ); } }; template< typename T1 > struct Exp struct Floor { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::exp( a ) ) static auto evaluate( const T1& a ) -> decltype( TNL::floor( a ) ) { return TNL::exp( a ); return TNL::floor( a ); } }; template< typename T1 > struct Ceil { __cuda_callable__ static auto evaluate( const T1& a ) -> decltype( TNL::ceil( a ) ) { return TNL::ceil( a ); } }; Loading
src/TNL/Containers/VectorExpressions.h +80 −40 Original line number Diff line number Diff line Loading @@ -699,93 +699,103 @@ abs( const Containers::Vector< Real, Device, Index, Allocator >& a ) } //// // Sine // Power template< typename Real, typename Device, typename Index, typename Allocator, typename ExpType > auto pow( const Containers::Vector< Real, Device, Index, Allocator >& a, const ExpType& exp ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Pow, ExpType >( a.getConstView(), exp ); } //// // Exp template< typename Real, typename Device, typename Index, typename Allocator > auto sin( const Containers::Vector< Real, Device, Index, Allocator >& a ) exp( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sin >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Exp >( a.getConstView() ); } //// // Cosine // Sqrt template< typename Real, typename Device, typename Index, typename Allocator > auto cos( const Containers::Vector< Real, Device, Index, Allocator >& a ) sqrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cos >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sqrt >( a.getConstView() ); } //// // Tangent // Cbrt template< typename Real, typename Device, typename Index, typename Allocator > auto tan( const Containers::Vector< Real, Device, Index, Allocator >& a ) cbrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Tan >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cbrt >( a.getConstView() ); } //// // Sqrt // Log template< typename Real, typename Device, typename Index, typename Allocator > auto sqrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) log( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sqrt >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log >( a.getConstView() ); } //// // Cbrt // Log10 template< typename Real, typename Device, typename Index, typename Allocator > auto cbrt( const Containers::Vector< Real, Device, Index, Allocator >& a ) log10( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cbrt >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log10 >( a.getConstView() ); } //// // Power template< typename Real, typename Device, typename Index, typename Allocator, typename ExpType > // Log2 template< typename Real, typename Device, typename Index, typename Allocator > auto pow( const Containers::Vector< Real, Device, Index, Allocator >& a, const ExpType& exp ) log2( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Pow, ExpType >( a.getConstView(), exp ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log2 >( a.getConstView() ); } //// // Floor // Sine template< typename Real, typename Device, typename Index, typename Allocator > auto floor( const Containers::Vector< Real, Device, Index, Allocator >& a ) sin( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Floor >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sin >( a.getConstView() ); } //// // Ceil // Cosine template< typename Real, typename Device, typename Index, typename Allocator > auto ceil( const Containers::Vector< Real, Device, Index, Allocator >& a ) cos( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Ceil >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Cos >( a.getConstView() ); } //// // Acos // Tangent template< typename Real, typename Device, typename Index, typename Allocator > auto acos( const Containers::Vector< Real, Device, Index, Allocator >& a ) tan( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acos >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Tan >( a.getConstView() ); } //// Loading @@ -798,6 +808,16 @@ asin( const Containers::Vector< Real, Device, Index, Allocator >& a ) return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Asin >( a.getConstView() ); } //// // Acos template< typename Real, typename Device, typename Index, typename Allocator > auto acos( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acos >( a.getConstView() ); } //// // Atan template< typename Real, typename Device, typename Index, typename Allocator > Loading @@ -808,6 +828,16 @@ atan( const Containers::Vector< Real, Device, Index, Allocator >& a ) return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Atan >( a.getConstView() ); } //// // Sinh template< typename Real, typename Device, typename Index, typename Allocator > auto sinh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Sinh >( a.getConstView() ); } //// // Cosh template< typename Real, typename Device, typename Index, typename Allocator > Loading @@ -829,43 +859,53 @@ tanh( const Containers::Vector< Real, Device, Index, Allocator >& a ) } //// // Log // Asinh template< typename Real, typename Device, typename Index, typename Allocator > auto log( const Containers::Vector< Real, Device, Index, Allocator >& a ) asinh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Asinh >( a.getConstView() ); } //// // Log10 // Acosh template< typename Real, typename Device, typename Index, typename Allocator > auto log10( const Containers::Vector< Real, Device, Index, Allocator >& a ) acosh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log10 >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Acosh >( a.getConstView() ); } //// // Log2 // Atanh template< typename Real, typename Device, typename Index, typename Allocator > auto log2( const Containers::Vector< Real, Device, Index, Allocator >& a ) atanh( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Log2 >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Atanh >( a.getConstView() ); } //// // Exp // Floor template< typename Real, typename Device, typename Index, typename Allocator > auto exp( const Containers::Vector< Real, Device, Index, Allocator >& a ) floor( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Exp >( a.getConstView() ); return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Floor >( a.getConstView() ); } //// // Ceil template< typename Real, typename Device, typename Index, typename Allocator > auto ceil( const Containers::Vector< Real, Device, Index, Allocator >& a ) { using ConstView = typename Containers::Vector< Real, Device, Index, Allocator >::ConstViewType; return Containers::Expressions::UnaryExpressionTemplate< ConstView, Containers::Expressions::Ceil >( a.getConstView() ); } //// Loading
src/TNL/Containers/VectorViewExpressions.h +76 −40 Original line number Diff line number Diff line Loading @@ -377,84 +377,93 @@ abs( const Containers::VectorView< Real, Device, Index >& a ) } //// // Sine // Power template< typename Real, typename Device, typename Index, typename ExpType > auto pow( const Containers::VectorView< Real, Device, Index >& a, const ExpType& exp ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Pow, ExpType >( a, exp ); } //// // Exp template< typename Real, typename Device, typename Index > auto sin( const Containers::VectorView< Real, Device, Index >& a ) exp( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sin >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Exp >( a ); } //// // Cosine // Sqrt template< typename Real, typename Device, typename Index > auto cos( const Containers::VectorView< Real, Device, Index >& a ) sqrt( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cos >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sqrt >( a ); } //// // Tangent // Cbrt template< typename Real, typename Device, typename Index > auto tan( const Containers::VectorView< Real, Device, Index >& a ) cbrt( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Tan >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cbrt >( a ); } //// // Sqrt // Log template< typename Real, typename Device, typename Index > auto sqrt( const Containers::VectorView< Real, Device, Index >& a ) log( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sqrt >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log >( a ); } //// // Cbrt // Log10 template< typename Real, typename Device, typename Index > auto cbrt( const Containers::VectorView< Real, Device, Index >& a ) log10( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cbrt >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log10 >( a ); } //// // Power template< typename Real, typename Device, typename Index, typename ExpType > // Log2 template< typename Real, typename Device, typename Index > auto pow( const Containers::VectorView< Real, Device, Index >& a, const ExpType& exp ) log2( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Pow, ExpType >( a, exp ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log2 >( a ); } //// // Floor // Sine template< typename Real, typename Device, typename Index > auto floor( const Containers::VectorView< Real, Device, Index >& a ) sin( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Floor >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sin >( a ); } //// // Ceil // Cosine template< typename Real, typename Device, typename Index > auto ceil( const Containers::VectorView< Real, Device, Index >& a ) cos( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Ceil >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Cos >( a ); } //// // Acos // Tangent template< typename Real, typename Device, typename Index > auto acos( const Containers::VectorView< Real, Device, Index >& a ) tan( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acos >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Tan >( a ); } //// Loading @@ -466,6 +475,15 @@ asin( const Containers::VectorView< Real, Device, Index >& a ) return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Asin >( a ); } //// // Acos template< typename Real, typename Device, typename Index > auto acos( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acos >( a ); } //// // Atan template< typename Real, typename Device, typename Index > Loading @@ -475,6 +493,15 @@ atan( const Containers::VectorView< Real, Device, Index >& a ) return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Atan >( a ); } //// // Sinh template< typename Real, typename Device, typename Index > auto sinh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Sinh >( a ); } //// // Cosh template< typename Real, typename Device, typename Index > Loading @@ -494,39 +521,48 @@ tanh( const Containers::VectorView< Real, Device, Index >& a ) } //// // Log // Asinh template< typename Real, typename Device, typename Index > auto log( const Containers::VectorView< Real, Device, Index >& a ) asinh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Asinh >( a ); } //// // Log10 // Acosh template< typename Real, typename Device, typename Index > auto log10( const Containers::VectorView< Real, Device, Index >& a ) acosh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log10 >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Acosh >( a ); } //// // Log2 // Atanh template< typename Real, typename Device, typename Index > auto log2( const Containers::VectorView< Real, Device, Index >& a ) atanh( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Log2 >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Atanh >( a ); } //// // Exp // Floor template< typename Real, typename Device, typename Index > auto exp( const Containers::VectorView< Real, Device, Index >& a ) floor( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Exp >( a ); return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Floor >( a ); } //// // Ceil template< typename Real, typename Device, typename Index > auto ceil( const Containers::VectorView< Real, Device, Index >& a ) { return Containers::Expressions::UnaryExpressionTemplate< Containers::VectorView< Real, Device, Index >, Containers::Expressions::Ceil >( a ); } //// Loading