ComplexProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_PROXY_COMPLEXPROXY_H_
36 #define _BLAZE_MATH_PROXY_COMPLEXPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Exception.h>
44 #include <blaze/math/shims/Clear.h>
45 #include <blaze/math/shims/Reset.h>
46 #include <blaze/system/Inline.h>
48 
49 
50 namespace blaze {
51 
52 //=================================================================================================
53 //
54 // CLASS DEFINITION
55 //
56 //=================================================================================================
57 
58 //*************************************************************************************************
66 template< typename PT // Type of the proxy
67  , typename CT > // Type of the complex number
69 {
70  public:
71  //**Type definitions****************************************************************************
72  using value_type = typename CT::value_type;
74  //**********************************************************************************************
75 
76  //**Data access functions***********************************************************************
79  inline ValueType real() const;
80  inline void real( ValueType value ) const;
81  inline ValueType imag() const;
82  inline void imag( ValueType value ) const;
84  //**********************************************************************************************
85 
86  //**Conversion operators************************************************************************
90  BLAZE_ALWAYS_INLINE const PT& operator~() const;
92  //**********************************************************************************************
93 
94  private:
95  //**Compile time checks*************************************************************************
99  //**********************************************************************************************
100 };
101 //*************************************************************************************************
102 
103 
104 
105 
106 //=================================================================================================
107 //
108 // DATA ACCESS FUNCTIONS
109 //
110 //=================================================================================================
111 
112 //*************************************************************************************************
119 template< typename PT // Type of the proxy
120  , typename CT > // Type of the complex number
122 {
123  return (~*this).get().real();
124 }
125 //*************************************************************************************************
126 
127 
128 //*************************************************************************************************
136 template< typename PT // Type of the proxy
137  , typename CT > // Type of the complex number
138 inline void ComplexProxy<PT,CT>::real( ValueType value ) const
139 {
140  if( (~*this).isRestricted() ) {
141  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to restricted element" );
142  }
143 
144  (~*this).get().real( value );
145 }
146 //*************************************************************************************************
147 
148 
149 //*************************************************************************************************
156 template< typename PT // Type of the proxy
157  , typename CT > // Type of the complex number
159 {
160  return (~*this).get().imag();
161 }
162 //*************************************************************************************************
163 
164 
165 //*************************************************************************************************
173 template< typename PT // Type of the proxy
174  , typename CT > // Type of the complex number
175 inline void ComplexProxy<PT,CT>::imag( ValueType value ) const
176 {
177  if( (~*this).isRestricted() ) {
178  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to restricted element" );
179  }
180 
181  (~*this).get().imag( value );
182 }
183 //*************************************************************************************************
184 
185 
186 
187 
188 //=================================================================================================
189 //
190 // CONVERSION OPERATORS
191 //
192 //=================================================================================================
193 
194 //*************************************************************************************************
201 template< typename PT // Type of the proxy
202  , typename CT > // Type of the complex number
204 {
205  return *static_cast<PT*>( this );
206 }
207 //*************************************************************************************************
208 
209 
210 //*************************************************************************************************
217 template< typename PT // Type of the proxy
218  , typename CT > // Type of the complex number
220 {
221  return *static_cast<const PT*>( this );
222 }
223 //*************************************************************************************************
224 
225 } // namespace blaze
226 
227 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: ComplexProxy.h:158
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE PT & operator~()
Conversion operator for non-constant proxies.
Definition: ComplexProxy.h:203
Header file for the exception macros of the math module.
value_type ValueType
Value type of the represented complex element.
Definition: ComplexProxy.h:73
typename CT::value_type value_type
Value type of the represented complex element.
Definition: ComplexProxy.h:72
ValueType real() const
Returns the real part of the represented complex number.
Definition: ComplexProxy.h:121
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_BE_COMPLEX_TYPE(T)
Constraint on the data type.This compile time constraint checks that the given data type T is a compl...
Definition: Complex.h:62
Proxy backend for complex types.The ComplexProxy class serves as a backend for the Proxy class...
Definition: ComplexProxy.h:68
System settings for the inline keywords.