Conjugate.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SHIMS_CONJUGATE_H_
36 #define _BLAZE_MATH_SHIMS_CONJUGATE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <blaze/system/Inline.h>
45 #include <blaze/util/DisableIf.h>
46 #include <blaze/util/EnableIf.h>
49 
50 
51 namespace blaze {
52 
53 //=================================================================================================
54 //
55 // CONJ SHIM
56 //
57 //=================================================================================================
58 
59 //*************************************************************************************************
81 template< typename T >
82 BLAZE_ALWAYS_INLINE constexpr EnableIf_< IsBuiltin<T>, T > conj( T a ) noexcept
83 {
84  return a;
85 }
86 //*************************************************************************************************
87 
88 
89 
90 
91 //=================================================================================================
92 //
93 // CONJUGATE SHIM
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
119 template< typename T >
121 {
122  a = conj( a );
123 }
124 //*************************************************************************************************
125 
126 
127 
128 
129 //=================================================================================================
130 //
131 // CSWAP SHIM
132 //
133 //=================================================================================================
134 
135 //*************************************************************************************************
144 template< typename T >
145 BLAZE_ALWAYS_INLINE DisableIf_< IsNumeric<T> > cswap_backend( T& a, T& b )
146 {
147  using std::swap;
148 
149  swap( a, b );
150  conjugate( a );
151  conjugate( b );
152 }
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
166 template< typename T >
167 BLAZE_ALWAYS_INLINE EnableIf_< IsNumeric<T> > cswap_backend( T& a, T& b ) noexcept
168 {
169  const T tmp( a );
170  a = conj( b );
171  b = conj( tmp );
172 }
174 //*************************************************************************************************
175 
176 
177 //*************************************************************************************************
194 template< typename T >
195 BLAZE_ALWAYS_INLINE void cswap( T& a, T& b ) noexcept( IsNumeric<T>::value )
196 {
197  cswap_backend( a, b );
198 }
199 //*************************************************************************************************
200 
201 } // namespace blaze
202 
203 #endif
Compile time check for numeric types.This type trait tests whether or not the given template paramete...
Definition: IsNumeric.h:79
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric< T >::value)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE void cswap(T &a, T &b) noexcept(IsNumeric< T >::value)
Swapping two conjugated values/objects.
Definition: Conjugate.h:195
Header file for the IsBuiltin type trait.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
System settings for the inline keywords.