StrictlyLowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
52 #include <blaze/math/proxy/Proxy.h>
53 #include <blaze/math/shims/Clear.h>
55 #include <blaze/math/shims/IsNaN.h>
56 #include <blaze/math/shims/IsOne.h>
59 #include <blaze/math/shims/Reset.h>
66 #include <blaze/util/Types.h>
67 
68 
69 namespace blaze {
70 
71 //=================================================================================================
72 //
73 // CLASS DEFINITION
74 //
75 //=================================================================================================
76 
77 //*************************************************************************************************
99 template< typename MT > // Type of the adapted matrix
100 class StrictlyLowerProxy : public Proxy< StrictlyLowerProxy<MT>, ElementType_<MT> >
101 {
102  private:
103  //**Type definitions****************************************************************************
106  //**********************************************************************************************
107 
108  public:
109  //**Type definitions****************************************************************************
112  typedef const RepresentedType& ConstReference;
113  //**********************************************************************************************
114 
115  //**Constructors********************************************************************************
118  explicit inline StrictlyLowerProxy( MT& matrix, size_t row, size_t column );
119  inline StrictlyLowerProxy( const StrictlyLowerProxy& ulp );
121  //**********************************************************************************************
122 
123  //**Destructor**********************************************************************************
124  // No explicitly declared destructor.
125  //**********************************************************************************************
126 
127  //**Assignment operators************************************************************************
130  inline const StrictlyLowerProxy& operator=( const StrictlyLowerProxy& ulp ) const;
131 
132  template< typename T >
133  inline const StrictlyLowerProxy& operator=( initializer_list<T> list ) const;
134 
135  template< typename T >
136  inline const StrictlyLowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
137 
138  template< typename T > inline const StrictlyLowerProxy& operator= ( const T& value ) const;
139  template< typename T > inline const StrictlyLowerProxy& operator+=( const T& value ) const;
140  template< typename T > inline const StrictlyLowerProxy& operator-=( const T& value ) const;
141  template< typename T > inline const StrictlyLowerProxy& operator*=( const T& value ) const;
142  template< typename T > inline const StrictlyLowerProxy& operator/=( const T& value ) const;
144  //**********************************************************************************************
145 
146  //**Utility functions***************************************************************************
149  inline RawReference get() const noexcept;
150  inline bool isRestricted() const noexcept;
152  //**********************************************************************************************
153 
154  //**Conversion operator*************************************************************************
157  inline operator ConstReference() const noexcept;
159  //**********************************************************************************************
160 
161  private:
162  //**Member variables****************************************************************************
165  ReferenceType value_;
166  const bool restricted_;
167 
171  //**********************************************************************************************
172 
173  //**Compile time checks*************************************************************************
186  //**********************************************************************************************
187 };
188 //*************************************************************************************************
189 
190 
191 
192 
193 //=================================================================================================
194 //
195 // CONSTRUCTORS
196 //
197 //=================================================================================================
198 
199 //*************************************************************************************************
206 template< typename MT > // Type of the adapted matrix
207 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
208  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
209  , restricted_( row <= column ) // Access flag for the accessed matrix element
210 {}
211 //*************************************************************************************************
212 
213 
214 //*************************************************************************************************
219 template< typename MT > // Type of the adapted matrix
221  : value_ ( slp.value_ ) // Reference to the accessed matrix element
222  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
223 {}
224 //*************************************************************************************************
225 
226 
227 
228 
229 //=================================================================================================
230 //
231 // OPERATORS
232 //
233 //=================================================================================================
234 
235 //*************************************************************************************************
245 template< typename MT > // Type of the adapted matrix
246 inline const StrictlyLowerProxy<MT>&
248 {
249  if( restricted_ ) {
250  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
251  }
252 
253  value_ = slp.value_;
254 
255  return *this;
256 }
257 //*************************************************************************************************
258 
259 
260 //*************************************************************************************************
270 template< typename MT > // Type of the adapted matrix
271 template< typename T > // Type of the right-hand side value
272 inline const StrictlyLowerProxy<MT>&
274 {
275  if( restricted_ ) {
276  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
277  }
278 
279  value_ = list;
280 
281  return *this;
282 }
283 //*************************************************************************************************
284 
285 
286 //*************************************************************************************************
296 template< typename MT > // Type of the adapted matrix
297 template< typename T > // Type of the right-hand side value
298 inline const StrictlyLowerProxy<MT>&
300 {
301  if( restricted_ ) {
302  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
303  }
304 
305  value_ = list;
306 
307  return *this;
308 }
309 //*************************************************************************************************
310 
311 
312 //*************************************************************************************************
322 template< typename MT > // Type of the adapted matrix
323 template< typename T > // Type of the right-hand side value
324 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
325 {
326  if( restricted_ ) {
327  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
328  }
329 
330  value_ = value;
331 
332  return *this;
333 }
334 //*************************************************************************************************
335 
336 
337 //*************************************************************************************************
347 template< typename MT > // Type of the adapted matrix
348 template< typename T > // Type of the right-hand side value
349 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
350 {
351  if( restricted_ ) {
352  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
353  }
354 
355  value_ += value;
356 
357  return *this;
358 }
359 //*************************************************************************************************
360 
361 
362 //*************************************************************************************************
372 template< typename MT > // Type of the adapted matrix
373 template< typename T > // Type of the right-hand side value
374 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
375 {
376  if( restricted_ ) {
377  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
378  }
379 
380  value_ -= value;
381 
382  return *this;
383 }
384 //*************************************************************************************************
385 
386 
387 //*************************************************************************************************
397 template< typename MT > // Type of the adapted matrix
398 template< typename T > // Type of the right-hand side value
399 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
400 {
401  if( restricted_ ) {
402  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
403  }
404 
405  value_ *= value;
406 
407  return *this;
408 }
409 //*************************************************************************************************
410 
411 
412 //*************************************************************************************************
422 template< typename MT > // Type of the adapted matrix
423 template< typename T > // Type of the right-hand side value
424 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
425 {
426  if( restricted_ ) {
427  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
428  }
429 
430  value_ /= value;
431 
432  return *this;
433 }
434 //*************************************************************************************************
435 
436 
437 
438 
439 //=================================================================================================
440 //
441 // UTILITY FUNCTIONS
442 //
443 //=================================================================================================
444 
445 //*************************************************************************************************
450 template< typename MT > // Type of the adapted matrix
452 {
453  return value_;
454 }
455 //*************************************************************************************************
456 
457 
458 //*************************************************************************************************
463 template< typename MT > // Type of the adapted matrix
464 inline bool StrictlyLowerProxy<MT>::isRestricted() const noexcept
465 {
466  return restricted_;
467 }
468 //*************************************************************************************************
469 
470 
471 
472 
473 //=================================================================================================
474 //
475 // CONVERSION OPERATOR
476 //
477 //=================================================================================================
478 
479 //*************************************************************************************************
484 template< typename MT > // Type of the adapted matrix
486 {
487  return static_cast<ConstReference>( value_ );
488 }
489 //*************************************************************************************************
490 
491 
492 
493 
494 //=================================================================================================
495 //
496 // GLOBAL FUNCTIONS
497 //
498 //=================================================================================================
499 
500 //*************************************************************************************************
503 template< typename MT >
504 inline void reset( const StrictlyLowerProxy<MT>& proxy );
505 
506 template< typename MT >
507 inline void clear( const StrictlyLowerProxy<MT>& proxy );
508 
509 template< typename MT >
510 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy );
511 
512 template< typename MT >
513 inline bool isReal( const StrictlyLowerProxy<MT>& proxy );
514 
515 template< typename MT >
516 inline bool isZero( const StrictlyLowerProxy<MT>& proxy );
517 
518 template< typename MT >
519 inline bool isOne( const StrictlyLowerProxy<MT>& proxy );
520 
521 template< typename MT >
522 inline bool isnan( const StrictlyLowerProxy<MT>& proxy );
524 //*************************************************************************************************
525 
526 
527 //*************************************************************************************************
537 template< typename MT >
538 inline void reset( const StrictlyLowerProxy<MT>& proxy )
539 {
540  using blaze::reset;
541 
542  reset( proxy.get() );
543 }
544 //*************************************************************************************************
545 
546 
547 //*************************************************************************************************
557 template< typename MT >
558 inline void clear( const StrictlyLowerProxy<MT>& proxy )
559 {
560  using blaze::clear;
561 
562  clear( proxy.get() );
563 }
564 //*************************************************************************************************
565 
566 
567 //*************************************************************************************************
577 template< typename MT >
578 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
579 {
580  using blaze::isDefault;
581 
582  return isDefault( proxy.get() );
583 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
599 template< typename MT >
600 inline bool isReal( const StrictlyLowerProxy<MT>& proxy )
601 {
602  using blaze::isReal;
603 
604  return isReal( proxy.get() );
605 }
606 //*************************************************************************************************
607 
608 
609 //*************************************************************************************************
619 template< typename MT >
620 inline bool isZero( const StrictlyLowerProxy<MT>& proxy )
621 {
622  using blaze::isZero;
623 
624  return isZero( proxy.get() );
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
639 template< typename MT >
640 inline bool isOne( const StrictlyLowerProxy<MT>& proxy )
641 {
642  using blaze::isOne;
643 
644  return isOne( proxy.get() );
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
659 template< typename MT >
660 inline bool isnan( const StrictlyLowerProxy<MT>& proxy )
661 {
662  using blaze::isnan;
663 
664  return isnan( proxy.get() );
665 }
666 //*************************************************************************************************
667 
668 } // namespace blaze
669 
670 #endif
Header file for the isnan shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#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
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:635
Header file for the AddConst type trait.
Header file for auxiliary alias declarations.
Header file for basic type definitions.
Proxy base class.The Proxy class is a base class for all proxy classes within the Blaze library that ...
Definition: Forward.h:51
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:595
typename AddConst< T >::Type AddConst_
Auxiliary alias declaration for the AddConst type trait.The AddConst_ alias declaration provides a co...
Definition: AddConst.h:95
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:464
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
Header file for the Proxy class.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
Header file for the std::initializer_list aliases.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Constraint on the data type.
Access proxy for strictly lower triangular matrices.The StrictlyLowerProxy provides controlled access...
Definition: StrictlyLowerProxy.h:100
Header file for the isZero shim.
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyLowerProxy.h:166
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Constraint on the data type.
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:451
AddReference_< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyLowerProxy.h:111
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:655
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the isOne shim.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Constraint on the data type.
Constraint on the data type.
Header file for the reset shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
const StrictlyLowerProxy & operator=(const StrictlyLowerProxy &ulp) const
Copy assignment operator for StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:247
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
Initializer list type of the Blaze library.
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyLowerProxy.h:112
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:615
Header file for the AddReference type trait.
AddConst_< Reference_< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyLowerProxy.h:105
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a N-dimensional matrix type...
Definition: Matrix.h:61
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyLowerProxy.h:110
StrictlyLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:207
Header file for the isReal shim.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:165
typename AddReference< T >::Type AddReference_
Auxiliary alias declaration for the AddReference type trait.The AddReference_ alias declaration provi...
Definition: AddReference.h:95