Blaze 3.9
Loading...
Searching...
No Matches
InvSqrt.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_SHIMS_INVSQRT_H_
36#define _BLAZE_MATH_SHIMS_INVSQRT_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
45#include <blaze/util/Assert.h>
46#include <blaze/util/Complex.h>
47#include <blaze/util/EnableIf.h>
49
50
51namespace blaze {
52
53//=================================================================================================
54//
55// INVSQRT SHIM
56//
57//=================================================================================================
58
59//*************************************************************************************************
69template< typename T, typename = EnableIf_t< IsBuiltin_v<T> > >
70inline auto invsqrt( T a ) noexcept -> decltype( inv( sqrt( a ) ) )
71{
72 BLAZE_USER_ASSERT( a > T(0), "Invalid built-in value detected" );
73
74 return inv( sqrt( a ) );
75}
76//*************************************************************************************************
77
78
79//*************************************************************************************************
89template< typename T, typename = EnableIf_t< IsBuiltin_v<T> > >
90inline auto invsqrt( const complex<T>& a ) noexcept -> decltype( inv( sqrt( a ) ) )
91{
92 BLAZE_USER_ASSERT( abs( a ) != T(0), "Invalid complex value detected" );
93
94 return inv( sqrt( a ) );
95}
96//*************************************************************************************************
97
98} // namespace blaze
99
100#endif
Header file for run time assertion macros.
Header file for the complex data type.
Header file for the EnableIf class template.
Header file for the invert shim.
Header file for the IsBuiltin type trait.
decltype(auto) invsqrt(const DenseMatrix< MT, SO > &dm)
Computes the inverse square root of each single element of the dense matrix dm.
Definition DMatMapExpr.h:1647
decltype(auto) abs(const DenseMatrix< MT, SO > &dm)
Applies the abs() function to each single element of the dense matrix dm.
Definition DMatMapExpr.h:1296
decltype(auto) inv(const DenseMatrix< MT, SO > &dm)
Calculation of the inverse of the given dense matrix.
Definition DMatInvExpr.h:405
decltype(auto) sqrt(const DenseMatrix< MT, SO > &dm)
Computes the square root of each single element of the dense matrix dm.
Definition DMatMapExpr.h:1616
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition Assert.h:117
Header file for the sqrt shim.