Commit 06da660a authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added missing unary functions for static vectors

parent 8b9a2151
Loading
Loading
Loading
Loading
+108 −67
Original line number Diff line number Diff line
@@ -382,43 +382,62 @@ max( const Containers::StaticVector< Size, Real1 >& a, const Containers::StaticV
}

////
// Abs
template< int Size, typename Real >
// Dot product - the same as scalar product, just for convenience
template< int Size, typename Real, typename ET,
          typename..., typename = std::enable_if_t< Containers::Expressions::IsNumericExpression<ET>::value > >
__cuda_callable__
auto
abs( const Containers::StaticVector< Size, Real >& a )
dot( const Containers::StaticVector< Size, Real >& a, const ET& b )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Abs >( a );
   return (a, b);
}

template< typename ET, int Size, typename Real,
          typename..., typename = std::enable_if_t< Containers::Expressions::IsNumericExpression<ET>::value > >
__cuda_callable__
auto
dot( const ET& a, const Containers::StaticVector< Size, Real >& b )
{
   return (a, b);
}

template< typename Real1, int Size, typename Real2 >
__cuda_callable__
auto
dot( const Containers::StaticVector< Size, Real1 >& a, const Containers::StaticVector< Size, Real2 >& b )
{
   return (a, b);
}


////
// Sine
// Abs
template< int Size, typename Real >
__cuda_callable__
auto
sin( const Containers::StaticVector< Size, Real >& a )
abs( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Sin >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Abs >( a );
}

////
// Cosine
template< int Size, typename Real >
// Power
template< int Size, typename Real, typename ExpType >
__cuda_callable__
auto
cos( const Containers::StaticVector< Size, Real >& a )
pow( const Containers::StaticVector< Size, Real >& a, const ExpType& exp )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Cos >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Pow, ExpType >( a, exp );
}

////
// Tangent
// Exp
template< int Size, typename Real >
__cuda_callable__
auto
tan( const Containers::StaticVector< Size, Real >& a )
exp( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Tan >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Exp >( a );
}

////
@@ -442,43 +461,63 @@ cbrt( const Containers::StaticVector< Size, Real >& a )
}

////
// Power
template< int Size, typename Real, typename ExpType >
// Log
template< int Size, typename Real >
__cuda_callable__
auto
pow( const Containers::StaticVector< Size, Real >& a, const ExpType& exp )
log( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Pow, ExpType >( a, exp );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log >( a );
}

////
// Floor
// Log10
template< int Size, typename Real >
__cuda_callable__
auto
floor( const Containers::StaticVector< Size, Real >& a )
log10( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Floor >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log10 >( a );
}

////
// Ceil
// Log2
template< int Size, typename Real >
__cuda_callable__
auto
ceil( const Containers::StaticVector< Size, Real >& a )
log2( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Ceil >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log2 >( a );
}

////
// Acos
// Sine
template< int Size, typename Real >
__cuda_callable__
auto
acos( const Containers::StaticVector< Size, Real >& a )
sin( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Acos >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Sin >( a );
}

////
// Cosine
template< int Size, typename Real >
__cuda_callable__
auto
cos( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Cos >( a );
}

////
// Tangent
template< int Size, typename Real >
__cuda_callable__
auto
tan( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Tan >( a );
}

////
@@ -491,6 +530,16 @@ asin( const Containers::StaticVector< Size, Real >& a )
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Asin >( a );
}

////
// Acos
template< int Size, typename Real >
__cuda_callable__
auto
acos( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Acos >( a );
}

////
// Atan
template< int Size, typename Real >
@@ -501,6 +550,16 @@ atan( const Containers::StaticVector< Size, Real >& a )
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Atan >( a );
}

////
// Sinh
template< int Size, typename Real >
__cuda_callable__
auto
sinh( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Sinh >( a );
}

////
// Cosh
template< int Size, typename Real >
@@ -522,43 +581,53 @@ tanh( const Containers::StaticVector< Size, Real >& a )
}

////
// Log
// Asinh
template< int Size, typename Real >
__cuda_callable__
auto
log( const Containers::StaticVector< Size, Real >& a )
asinh( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Asinh >( a );
}

////
// Log10
// Acosh
template< int Size, typename Real >
__cuda_callable__
auto
log10( const Containers::StaticVector< Size, Real >& a )
acosh( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log10 >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Acosh >( a );
}

////
// Log2
// Atanh
template< int Size, typename Real >
__cuda_callable__
auto
log2( const Containers::StaticVector< Size, Real >& a )
atanh( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Log2 >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Atanh >( a );
}

////
// Exp
// Floor
template< int Size, typename Real >
__cuda_callable__
auto
exp( const Containers::StaticVector< Size, Real >& a )
floor( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Exp >( a );
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Floor >( a );
}

////
// Ceil
template< int Size, typename Real >
__cuda_callable__
auto
ceil( const Containers::StaticVector< Size, Real >& a )
{
   return Containers::Expressions::StaticUnaryExpressionTemplate< Containers::StaticVector< Size, Real >, Containers::Expressions::Ceil >( a );
}

////
@@ -666,32 +735,4 @@ binaryAnd( const Containers::StaticVector< Size, Real >& a )
   return Containers::Expressions::StaticExpressionBinaryAnd( a );
}

////
// Dot product - the same as scalar product, just for convenience
template< int Size, typename Real, typename ET,
          typename..., typename = std::enable_if_t< Containers::Expressions::IsNumericExpression<ET>::value > >
__cuda_callable__
auto
dot( const Containers::StaticVector< Size, Real >& a, const ET& b )
{
   return TNL::sum( a * b );
}

template< typename ET, int Size, typename Real,
          typename..., typename = std::enable_if_t< Containers::Expressions::IsNumericExpression<ET>::value > >
__cuda_callable__
auto
dot( const ET& a, const Containers::StaticVector< Size, Real >& b )
{
   return TNL::sum( a * b );
}

template< typename Real1, int Size, typename Real2 >
__cuda_callable__
auto
dot( const Containers::StaticVector< Size, Real1 >& a, const Containers::StaticVector< Size, Real2 >& b )
{
   return TNL::sum( a * b );
}

} // namespace TNL