Blaze 3.9
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
46#include <blaze/system/Inline.h>
48
49
50namespace blaze {
51
52//=================================================================================================
53//
54// CLASS DEFINITION
55//
56//=================================================================================================
57
58//*************************************************************************************************
66template< 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************************************************************************
89 [[deprecated]] BLAZE_ALWAYS_INLINE PT& operator~() noexcept;
90 [[deprecated]] BLAZE_ALWAYS_INLINE const PT& operator~() const noexcept;
91
92 BLAZE_ALWAYS_INLINE PT& operator*() noexcept;
93 BLAZE_ALWAYS_INLINE const PT& operator*() const noexcept;
95 //**********************************************************************************************
96
97 protected:
98 //**Special member functions********************************************************************
101 ComplexProxy() = default;
102 ComplexProxy( const ComplexProxy& ) = default;
103 ComplexProxy( ComplexProxy&& ) = default;
104 ~ComplexProxy() = default;
105 ComplexProxy& operator=( const ComplexProxy& ) = default;
106 ComplexProxy& operator=( ComplexProxy&& ) = default;
108 //**********************************************************************************************
109
110 private:
111 //**Compile time checks*************************************************************************
115 //**********************************************************************************************
116};
117//*************************************************************************************************
118
119
120
121
122//=================================================================================================
123//
124// DATA ACCESS FUNCTIONS
125//
126//=================================================================================================
127
128//*************************************************************************************************
135template< typename PT // Type of the proxy
136 , typename CT > // Type of the complex number
137inline typename ComplexProxy<PT,CT>::ValueType ComplexProxy<PT,CT>::real() const
138{
139 return (**this).get().real();
140}
141//*************************************************************************************************
142
143
144//*************************************************************************************************
152template< typename PT // Type of the proxy
153 , typename CT > // Type of the complex number
154inline void ComplexProxy<PT,CT>::real( ValueType value ) const
155{
156 if( (**this).isRestricted() ) {
157 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to restricted element" );
158 }
159
160 (**this).get().real( value );
161}
162//*************************************************************************************************
163
164
165//*************************************************************************************************
172template< typename PT // Type of the proxy
173 , typename CT > // Type of the complex number
175{
176 return (**this).get().imag();
177}
178//*************************************************************************************************
179
180
181//*************************************************************************************************
189template< typename PT // Type of the proxy
190 , typename CT > // Type of the complex number
191inline void ComplexProxy<PT,CT>::imag( ValueType value ) const
192{
193 if( (**this).isRestricted() ) {
194 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to restricted element" );
195 }
196
197 (**this).get().imag( value );
198}
199//*************************************************************************************************
200
201
202
203
204//=================================================================================================
205//
206// CONVERSION OPERATORS
207//
208//=================================================================================================
209
210//*************************************************************************************************
218template< typename PT // Type of the proxy
219 , typename CT > // Type of the complex number
221{
222 return static_cast<PT&>( *this );
223}
224//*************************************************************************************************
225
226
227//*************************************************************************************************
235template< typename PT // Type of the proxy
236 , typename CT > // Type of the complex number
237[[deprecated]] BLAZE_ALWAYS_INLINE const PT& ComplexProxy<PT,CT>::operator~() const noexcept
238{
239 return static_cast<const PT&>( *this );
240}
241//*************************************************************************************************
242
243
244//*************************************************************************************************
252template< typename PT // Type of the proxy
253 , typename CT > // Type of the complex number
255{
256 return static_cast<PT&>( *this );
257}
258//*************************************************************************************************
259
260
261//*************************************************************************************************
269template< typename PT // Type of the proxy
270 , typename CT > // Type of the complex number
272{
273 return static_cast<const PT&>( *this );
274}
275//*************************************************************************************************
276
277
278
279
280//=================================================================================================
281//
282// GLOBAL FUNCTIONS
283//
284//=================================================================================================
285
286//*************************************************************************************************
289template< typename PT, typename CT >
290PT& crtp_cast( ComplexProxy<PT,CT>& proxy );
291
292template< typename PT, typename CT >
293const PT& crtp_cast( const ComplexProxy<PT,CT>& proxy );
295//*************************************************************************************************
296
297
298//*************************************************************************************************
307template< typename PT // Type of the proxy
308 , typename CT > // Type of the complex number
310{
311 return *proxy;
312}
313//*************************************************************************************************
314
315
316//*************************************************************************************************
325template< typename PT // Type of the proxy
326 , typename CT > // Type of the complex number
328{
329 return *proxy;
330}
331//*************************************************************************************************
332
333} // namespace blaze
334
335#endif
Proxy backend for complex types.
Definition: ComplexProxy.h:69
typename CT::value_type value_type
Value type of the represented complex element.
Definition: ComplexProxy.h:72
value_type ValueType
Value type of the represented complex element.
Definition: ComplexProxy.h:73
ValueType real() const
Returns the real part of the represented complex number.
Definition: ComplexProxy.h:137
BLAZE_ALWAYS_INLINE PT & operator*() noexcept
Conversion operator for non-constant proxies.
Definition: ComplexProxy.h:254
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: ComplexProxy.h:174
BLAZE_ALWAYS_INLINE PT & operator~() noexcept
Conversion operator for non-constant proxies.
Definition: ComplexProxy.h:220
Constraint on the data type.
MT & crtp_cast(Matrix< MT, SO > &matrix)
CRTP-based conversion operation for non-constant matrices.
Definition: Matrix.h:479
#define BLAZE_CONSTRAINT_MUST_BE_COMPLEX_TYPE(T)
Constraint on the data type.
Definition: Complex.h:62
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the clear shim.
Header file for the reset shim.
System settings for the inline keywords.