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 <stdexcept>
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  typedef typename CT::value_type value_type;
73  typedef value_type ValueType;
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  private:
87  //**Conversion operators************************************************************************
91  BLAZE_ALWAYS_INLINE const PT& operator~() const;
93  //**********************************************************************************************
94 
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  throw std::invalid_argument( "Invalid access to restricted element" );
142 
143  (~*this).get().real( value );
144 }
145 //*************************************************************************************************
146 
147 
148 //*************************************************************************************************
155 template< typename PT // Type of the proxy
156  , typename CT > // Type of the complex number
158 {
159  return (~*this).get().imag();
160 }
161 //*************************************************************************************************
162 
163 
164 //*************************************************************************************************
172 template< typename PT // Type of the proxy
173  , typename CT > // Type of the complex number
174 inline void ComplexProxy<PT,CT>::imag( ValueType value ) const
175 {
176  if( (~*this).isRestricted() )
177  throw std::invalid_argument( "Invalid access to restricted element" );
178 
179  (~*this).get().imag( value );
180 }
181 //*************************************************************************************************
182 
183 
184 
185 
186 //=================================================================================================
187 //
188 // CONVERSION OPERATORS
189 //
190 //=================================================================================================
191 
192 //*************************************************************************************************
199 template< typename PT // Type of the proxy
200  , typename CT > // Type of the complex number
202 {
203  return *static_cast<PT*>( this );
204 }
205 //*************************************************************************************************
206 
207 
208 //*************************************************************************************************
215 template< typename PT // Type of the proxy
216  , typename CT > // Type of the complex number
218 {
219  return *static_cast<const PT*>( this );
220 }
221 //*************************************************************************************************
222 
223 } // namespace blaze
224 
225 #endif
Constraint on the data type.
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
CT::value_type value_type
Value type of the represented complex element.
Definition: ComplexProxy.h:72
BLAZE_ALWAYS_INLINE PT & operator~()
Conversion operator for non-constant proxies.
Definition: ComplexProxy.h:201
ValueType real() const
Returns the real part of the represented complex number.
Definition: ComplexProxy.h:121
value_type ValueType
Value type of the represented complex element.
Definition: ComplexProxy.h:73
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:80
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: ComplexProxy.h:157
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.