Blaze 3.9
LowerProxy.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_LOWERPROXY_H_
36#define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_LOWERPROXY_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
67#include <blaze/util/Types.h>
68
69
70namespace blaze {
71
72//=================================================================================================
73//
74// CLASS DEFINITION
75//
76//=================================================================================================
77
78//*************************************************************************************************
98template< typename MT > // Type of the adapted matrix
100 : public Proxy< LowerProxy<MT>, ElementType_t<MT> >
101{
102 private:
103 //**Type definitions****************************************************************************
106 //**********************************************************************************************
107
108 public:
109 //**Type definitions****************************************************************************
113 //**********************************************************************************************
114
115 //**Constructors********************************************************************************
118 inline LowerProxy( MT& matrix, size_t row, size_t column );
119
120 LowerProxy( const LowerProxy& ) = default;
122 //**********************************************************************************************
123
124 //**Destructor**********************************************************************************
127 ~LowerProxy() = default;
129 //**********************************************************************************************
130
131 //**Assignment operators************************************************************************
134 inline const LowerProxy& operator=( const LowerProxy& lp ) const;
135
136 template< typename T >
137 inline const LowerProxy& operator=( initializer_list<T> list ) const;
138
139 template< typename T >
140 inline const LowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
141
142 template< typename T > inline const LowerProxy& operator= ( const T& value ) const;
143 template< typename T > inline const LowerProxy& operator+=( const T& value ) const;
144 template< typename T > inline const LowerProxy& operator-=( const T& value ) const;
145 template< typename T > inline const LowerProxy& operator*=( const T& value ) const;
146 template< typename T > inline const LowerProxy& operator/=( const T& value ) const;
147 template< typename T > inline const LowerProxy& operator%=( const T& value ) const;
149 //**********************************************************************************************
150
151 //**Access operators****************************************************************************
154 inline const LowerProxy* operator->() const noexcept;
156 //**********************************************************************************************
157
158 //**Utility functions***************************************************************************
161 inline RawReference get() const noexcept;
162 inline bool isRestricted() const noexcept;
164 //**********************************************************************************************
165
166 //**Conversion operator*************************************************************************
169 inline operator ConstReference() const noexcept;
171 //**********************************************************************************************
172
173 private:
174 //**Member variables****************************************************************************
178 const bool restricted_;
183 //**********************************************************************************************
184
185 //**Compile time checks*************************************************************************
200 //**********************************************************************************************
201};
202//*************************************************************************************************
203
204
205
206
207//=================================================================================================
208//
209// CONSTRUCTORS
210//
211//=================================================================================================
212
213//*************************************************************************************************
220template< typename MT > // Type of the adapted matrix
221inline LowerProxy<MT>::LowerProxy( MT& matrix, size_t row, size_t column )
222 : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
223 , restricted_( row < column ) // Access flag for the accessed matrix element
224{}
225//*************************************************************************************************
226
227
228
229
230//=================================================================================================
231//
232// ASSIGNMENT OPERATORS
233//
234//=================================================================================================
235
236//*************************************************************************************************
246template< typename MT > // Type of the adapted matrix
248{
249 if( restricted_ ) {
250 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
251 }
252
253 value_ = lp.value_;
254
255 return *this;
256}
257//*************************************************************************************************
258
259
260//*************************************************************************************************
270template< typename MT > // Type of the adapted matrix
271template< typename T > // Type of the right-hand side value
272inline const LowerProxy<MT>& LowerProxy<MT>::operator=( initializer_list<T> list ) const
273{
274 if( restricted_ ) {
275 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
276 }
277
278 value_ = list;
279
280 return *this;
281}
282//*************************************************************************************************
283
284
285//*************************************************************************************************
295template< typename MT > // Type of the adapted matrix
296template< typename T > // Type of the right-hand side value
297inline const LowerProxy<MT>& LowerProxy<MT>::operator=( initializer_list< initializer_list<T> > list ) const
298{
299 if( restricted_ ) {
300 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
301 }
302
303 value_ = list;
304
305 return *this;
306}
307//*************************************************************************************************
308
309
310//*************************************************************************************************
320template< typename MT > // Type of the adapted matrix
321template< typename T > // Type of the right-hand side value
322inline const LowerProxy<MT>& LowerProxy<MT>::operator=( const T& value ) const
323{
324 if( restricted_ ) {
325 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
326 }
327
328 value_ = value;
329
330 return *this;
331}
332//*************************************************************************************************
333
334
335//*************************************************************************************************
345template< typename MT > // Type of the adapted matrix
346template< typename T > // Type of the right-hand side value
347inline const LowerProxy<MT>& LowerProxy<MT>::operator+=( const T& value ) const
348{
349 if( restricted_ ) {
350 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
351 }
352
353 value_ += value;
354
355 return *this;
356}
357//*************************************************************************************************
358
359
360//*************************************************************************************************
370template< typename MT > // Type of the adapted matrix
371template< typename T > // Type of the right-hand side value
372inline const LowerProxy<MT>& LowerProxy<MT>::operator-=( const T& value ) const
373{
374 if( restricted_ ) {
375 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
376 }
377
378 value_ -= value;
379
380 return *this;
381}
382//*************************************************************************************************
383
384
385//*************************************************************************************************
395template< typename MT > // Type of the adapted matrix
396template< typename T > // Type of the right-hand side value
397inline const LowerProxy<MT>& LowerProxy<MT>::operator*=( const T& value ) const
398{
399 if( restricted_ ) {
400 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
401 }
402
403 value_ *= value;
404
405 return *this;
406}
407//*************************************************************************************************
408
409
410//*************************************************************************************************
420template< typename MT > // Type of the adapted matrix
421template< typename T > // Type of the right-hand side value
422inline const LowerProxy<MT>& LowerProxy<MT>::operator/=( const T& value ) const
423{
424 if( restricted_ ) {
425 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
426 }
427
428 value_ /= value;
429
430 return *this;
431}
432//*************************************************************************************************
433
434
435//*************************************************************************************************
445template< typename MT > // Type of the adapted matrix
446template< typename T > // Type of the right-hand side value
447inline const LowerProxy<MT>& LowerProxy<MT>::operator%=( const T& value ) const
448{
449 if( restricted_ ) {
450 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
451 }
452
453 value_ %= value;
454
455 return *this;
456}
457//*************************************************************************************************
458
459
460
461
462//=================================================================================================
463//
464// ACCESS OPERATORS
465//
466//=================================================================================================
467
468//*************************************************************************************************
473template< typename MT > // Type of the adapted matrix
474inline const LowerProxy<MT>* LowerProxy<MT>::operator->() const noexcept
475{
476 return this;
477}
478//*************************************************************************************************
479
480
481
482
483//=================================================================================================
484//
485// UTILITY FUNCTIONS
486//
487//=================================================================================================
488
489//*************************************************************************************************
494template< typename MT > // Type of the adapted matrix
495inline typename LowerProxy<MT>::RawReference LowerProxy<MT>::get() const noexcept
496{
497 return value_;
498}
499//*************************************************************************************************
500
501
502//*************************************************************************************************
507template< typename MT > // Type of the adapted matrix
508inline bool LowerProxy<MT>::isRestricted() const noexcept
509{
510 return restricted_;
511}
512//*************************************************************************************************
513
514
515
516
517//=================================================================================================
518//
519// CONVERSION OPERATOR
520//
521//=================================================================================================
522
523//*************************************************************************************************
528template< typename MT > // Type of the adapted matrix
530{
531 return static_cast<ConstReference>( value_ );
532}
533//*************************************************************************************************
534
535} // namespace blaze
536
537#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 lower triangular matrices.
Definition: LowerProxy.h:101
AddLValueReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: LowerProxy.h:111
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: LowerProxy.h:110
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element.
Definition: LowerProxy.h:508
const LowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: LowerProxy.h:474
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: LowerProxy.h:112
LowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a LowerProxy.
Definition: LowerProxy.h:221
const bool restricted_
Access flag for the accessed matrix element.
Definition: LowerProxy.h:178
const LowerProxy & operator=(const LowerProxy &lp) const
Copy assignment operator for LowerProxy.
Definition: LowerProxy.h:247
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: LowerProxy.h:495
ReferenceType value_
Reference to the accessed matrix element.
Definition: LowerProxy.h:177
AddConst_t< Reference_t< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: LowerProxy.h:105
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 clear shim.
Header file for the isZero shim.
Header file for basic type definitions.