Blaze 3.9
DiagonalProxy.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_DIAGONALPROXY_H_
36#define _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_DIAGONALPROXY_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
66#include <blaze/util/Types.h>
67
68
69namespace blaze {
70
71//=================================================================================================
72//
73// CLASS DEFINITION
74//
75//=================================================================================================
76
77//*************************************************************************************************
97template< typename MT > // Type of the adapted matrix
99 : public Proxy< DiagonalProxy<MT>, ElementType_t<MT> >
100{
101 private:
102 //**Type definitions****************************************************************************
105 //**********************************************************************************************
106
107 public:
108 //**Type definitions****************************************************************************
112 //**********************************************************************************************
113
114 //**Constructors********************************************************************************
117 inline DiagonalProxy( MT& matrix, size_t row, size_t column );
118
119 DiagonalProxy( const DiagonalProxy& ) = default;
121 //**********************************************************************************************
122
123 //**Destructor**********************************************************************************
126 ~DiagonalProxy() = default;
128 //**********************************************************************************************
129
130 //**Assignment operators************************************************************************
133 inline DiagonalProxy& operator=( const DiagonalProxy& dp );
134
135 template< typename T >
136 inline DiagonalProxy& operator=( initializer_list<T> list );
137
138 template< typename T >
139 inline DiagonalProxy& operator=( initializer_list< initializer_list<T> > list );
140
141 template< typename T > inline DiagonalProxy& operator= ( const T& value );
142 template< typename T > inline DiagonalProxy& operator+=( const T& value );
143 template< typename T > inline DiagonalProxy& operator-=( const T& value );
144 template< typename T > inline DiagonalProxy& operator*=( const T& value );
145 template< typename T > inline DiagonalProxy& operator/=( const T& value );
146 template< typename T > inline DiagonalProxy& operator%=( const T& value );
148 //**********************************************************************************************
149
150 //**Access operators****************************************************************************
153 inline const DiagonalProxy* operator->() const noexcept;
155 //**********************************************************************************************
156
157 //**Utility functions***************************************************************************
160 inline RawReference get() const noexcept;
161 inline bool isRestricted() const noexcept;
163 //**********************************************************************************************
164
165 //**Conversion operator*************************************************************************
168 inline operator ConstReference() const noexcept;
170 //**********************************************************************************************
171
172 private:
173 //**Member variables****************************************************************************
177 const bool restricted_;
182 //**********************************************************************************************
183
184 //**Compile time checks*************************************************************************
199 //**********************************************************************************************
200};
201//*************************************************************************************************
202
203
204
205
206//=================================================================================================
207//
208// CONSTRUCTORS
209//
210//=================================================================================================
211
212//*************************************************************************************************
219template< typename MT > // Type of the adapted matrix
220inline DiagonalProxy<MT>::DiagonalProxy( MT& matrix, size_t row, size_t column )
221 : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
222 , restricted_( row != column ) // Access flag for the accessed matrix element
223{}
224//*************************************************************************************************
225
226
227
228
229//=================================================================================================
230//
231// OPERATORS
232//
233//=================================================================================================
234
235//*************************************************************************************************
245template< typename MT > // Type of the adapted matrix
247{
248 if( restricted_ ) {
249 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
250 }
251
252 value_ = dp.value_;
253
254 return *this;
255}
256//*************************************************************************************************
257
258
259//*************************************************************************************************
269template< typename MT > // Type of the adapted matrix
270template< typename T > // Type of the right-hand side value
271inline DiagonalProxy<MT>& DiagonalProxy<MT>::operator=( initializer_list<T> list )
272{
273 if( restricted_ ) {
274 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
275 }
276
277 value_ = list;
278
279 return *this;
280}
281//*************************************************************************************************
282
283
284//*************************************************************************************************
294template< typename MT > // Type of the adapted matrix
295template< typename T > // Type of the right-hand side value
296inline DiagonalProxy<MT>& DiagonalProxy<MT>::operator=( initializer_list< initializer_list<T> > list )
297{
298 if( restricted_ ) {
299 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
300 }
301
302 value_ = list;
303
304 return *this;
305}
306//*************************************************************************************************
307
308
309//*************************************************************************************************
319template< typename MT > // Type of the adapted matrix
320template< typename T > // Type of the right-hand side value
322{
323 if( restricted_ ) {
324 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
325 }
326
327 value_ = value;
328
329 return *this;
330}
331//*************************************************************************************************
332
333
334//*************************************************************************************************
344template< typename MT > // Type of the adapted matrix
345template< typename T > // Type of the right-hand side value
347{
348 if( restricted_ ) {
349 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
350 }
351
352 value_ += value;
353
354 return *this;
355}
356//*************************************************************************************************
357
358
359//*************************************************************************************************
369template< typename MT > // Type of the adapted matrix
370template< typename T > // Type of the right-hand side value
372{
373 if( restricted_ ) {
374 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
375 }
376
377 value_ -= value;
378
379 return *this;
380}
381//*************************************************************************************************
382
383
384//*************************************************************************************************
394template< typename MT > // Type of the adapted matrix
395template< typename T > // Type of the right-hand side value
397{
398 if( restricted_ ) {
399 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
400 }
401
402 value_ *= value;
403
404 return *this;
405}
406//*************************************************************************************************
407
408
409//*************************************************************************************************
419template< typename MT > // Type of the adapted matrix
420template< typename T > // Type of the right-hand side value
422{
423 if( restricted_ ) {
424 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
425 }
426
427 value_ /= value;
428
429 return *this;
430}
431//*************************************************************************************************
432
433
434//*************************************************************************************************
444template< typename MT > // Type of the adapted matrix
445template< typename T > // Type of the right-hand side value
447{
448 if( restricted_ ) {
449 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to non-diagonal matrix element" );
450 }
451
452 value_ %= value;
453
454 return *this;
455}
456//*************************************************************************************************
457
458
459
460
461//=================================================================================================
462//
463// ACCESS OPERATORS
464//
465//=================================================================================================
466
467//*************************************************************************************************
472template< typename MT > // Type of the adapted matrix
474{
475 return this;
476}
477//*************************************************************************************************
478
479
480
481
482//=================================================================================================
483//
484// UTILITY FUNCTIONS
485//
486//=================================================================================================
487
488//*************************************************************************************************
493template< typename MT > // Type of the adapted matrix
495{
496 return value_;
497}
498//*************************************************************************************************
499
500
501//*************************************************************************************************
506template< typename MT > // Type of the adapted matrix
507inline bool DiagonalProxy<MT>::isRestricted() const noexcept
508{
509 return restricted_;
510}
511//*************************************************************************************************
512
513
514
515
516//=================================================================================================
517//
518// CONVERSION OPERATOR
519//
520//=================================================================================================
521
522//*************************************************************************************************
527template< typename MT > // Type of the adapted matrix
529{
530 return static_cast<ConstReference>( value_ );
531}
532//*************************************************************************************************
533
534} // namespace blaze
535
536#endif
Header file for the AddConst type trait.
Header file for the AddLValueReference type trait.
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Constraint on the data type.
Constraint on the data type.
Header file for the isDefault shim.
Header file for the isOne shim.
Header file for the isReal shim.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Access proxy for diagonal matrices.
Definition: DiagonalProxy.h:100
const bool restricted_
Access flag for the accessed matrix element.
Definition: DiagonalProxy.h:177
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: DiagonalProxy.h:109
const DiagonalProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: DiagonalProxy.h:473
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: DiagonalProxy.h:507
DiagonalProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a DiagonalProxy.
Definition: DiagonalProxy.h:220
ReferenceType value_
Reference to the accessed matrix element.
Definition: DiagonalProxy.h:176
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: DiagonalProxy.h:494
AddConst_t< typename MT::Reference > ReferenceType
Reference type of the underlying matrix type.
Definition: DiagonalProxy.h:104
DiagonalProxy & operator=(const DiagonalProxy &dp)
Copy assignment operator for DiagonalProxy.
Definition: DiagonalProxy.h:246
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: DiagonalProxy.h:111
AddLValueReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: DiagonalProxy.h:110
Proxy base class.
Definition: Proxy.h:169
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Matrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.
Definition: View.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
typename AddConst< T >::Type AddConst_t
Auxiliary alias declaration for the AddConst type trait.
Definition: AddConst.h:95
typename AddLValueReference< T >::Type AddLValueReference_t
Auxiliary alias declaration for the AddLValueReference type trait.
Definition: AddLValueReference.h:97
#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 extended initializer_list functionality.
Header file for the Proxy class.
Header file for the isZero shim.
Header file for basic type definitions.