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
101  : public Proxy< StrictlyLowerProxy<MT>, ElementType_<MT> >
102 {
103  private:
104  //**Type definitions****************************************************************************
107  //**********************************************************************************************
108 
109  public:
110  //**Type definitions****************************************************************************
114  //**********************************************************************************************
115 
116  //**Constructors********************************************************************************
119  explicit inline StrictlyLowerProxy( MT& matrix, size_t row, size_t column );
120  inline StrictlyLowerProxy( const StrictlyLowerProxy& ulp );
122  //**********************************************************************************************
123 
124  //**Destructor**********************************************************************************
125  // No explicitly declared destructor.
126  //**********************************************************************************************
127 
128  //**Assignment operators************************************************************************
131  inline const StrictlyLowerProxy& operator=( const StrictlyLowerProxy& ulp ) const;
132 
133  template< typename T >
134  inline const StrictlyLowerProxy& operator=( initializer_list<T> list ) const;
135 
136  template< typename T >
137  inline const StrictlyLowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
138 
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;
143  template< typename T > inline const StrictlyLowerProxy& operator/=( const T& value ) const;
144  template< typename T > inline const StrictlyLowerProxy& operator%=( const T& value ) const;
146  //**********************************************************************************************
147 
148  //**Utility functions***************************************************************************
151  inline RawReference get() const noexcept;
152  inline bool isRestricted() const noexcept;
154  //**********************************************************************************************
155 
156  //**Conversion operator*************************************************************************
159  inline operator ConstReference() const noexcept;
161  //**********************************************************************************************
162 
163  private:
164  //**Member variables****************************************************************************
168  const bool restricted_;
169 
173  //**********************************************************************************************
174 
175  //**Compile time checks*************************************************************************
188  //**********************************************************************************************
189 };
190 //*************************************************************************************************
191 
192 
193 
194 
195 //=================================================================================================
196 //
197 // CONSTRUCTORS
198 //
199 //=================================================================================================
200 
201 //*************************************************************************************************
208 template< typename MT > // Type of the adapted matrix
209 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
210  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
211  , restricted_( row <= column ) // Access flag for the accessed matrix element
212 {}
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
221 template< typename MT > // Type of the adapted matrix
223  : value_ ( slp.value_ ) // Reference to the accessed matrix element
224  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
225 {}
226 //*************************************************************************************************
227 
228 
229 
230 
231 //=================================================================================================
232 //
233 // OPERATORS
234 //
235 //=================================================================================================
236 
237 //*************************************************************************************************
247 template< typename MT > // Type of the adapted matrix
248 inline const StrictlyLowerProxy<MT>&
250 {
251  if( restricted_ ) {
252  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
253  }
254 
255  value_ = slp.value_;
256 
257  return *this;
258 }
259 //*************************************************************************************************
260 
261 
262 //*************************************************************************************************
272 template< typename MT > // Type of the adapted matrix
273 template< typename T > // Type of the right-hand side value
274 inline const StrictlyLowerProxy<MT>&
276 {
277  if( restricted_ ) {
278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
279  }
280 
281  value_ = list;
282 
283  return *this;
284 }
285 //*************************************************************************************************
286 
287 
288 //*************************************************************************************************
298 template< typename MT > // Type of the adapted matrix
299 template< typename T > // Type of the right-hand side value
300 inline const StrictlyLowerProxy<MT>&
302 {
303  if( restricted_ ) {
304  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
305  }
306 
307  value_ = list;
308 
309  return *this;
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
324 template< typename MT > // Type of the adapted matrix
325 template< typename T > // Type of the right-hand side value
326 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
327 {
328  if( restricted_ ) {
329  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
330  }
331 
332  value_ = value;
333 
334  return *this;
335 }
336 //*************************************************************************************************
337 
338 
339 //*************************************************************************************************
349 template< typename MT > // Type of the adapted matrix
350 template< typename T > // Type of the right-hand side value
351 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
352 {
353  if( restricted_ ) {
354  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
355  }
356 
357  value_ += value;
358 
359  return *this;
360 }
361 //*************************************************************************************************
362 
363 
364 //*************************************************************************************************
374 template< typename MT > // Type of the adapted matrix
375 template< typename T > // Type of the right-hand side value
376 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
377 {
378  if( restricted_ ) {
379  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
380  }
381 
382  value_ -= value;
383 
384  return *this;
385 }
386 //*************************************************************************************************
387 
388 
389 //*************************************************************************************************
399 template< typename MT > // Type of the adapted matrix
400 template< typename T > // Type of the right-hand side value
401 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
402 {
403  if( restricted_ ) {
404  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
405  }
406 
407  value_ *= value;
408 
409  return *this;
410 }
411 //*************************************************************************************************
412 
413 
414 //*************************************************************************************************
424 template< typename MT > // Type of the adapted matrix
425 template< typename T > // Type of the right-hand side value
426 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
427 {
428  if( restricted_ ) {
429  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
430  }
431 
432  value_ /= value;
433 
434  return *this;
435 }
436 //*************************************************************************************************
437 
438 
439 //*************************************************************************************************
449 template< typename MT > // Type of the adapted matrix
450 template< typename T > // Type of the right-hand side value
451 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator%=( const T& value ) const
452 {
453  if( restricted_ ) {
454  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
455  }
456 
457  value_ %= value;
458 
459  return *this;
460 }
461 //*************************************************************************************************
462 
463 
464 
465 
466 //=================================================================================================
467 //
468 // UTILITY FUNCTIONS
469 //
470 //=================================================================================================
471 
472 //*************************************************************************************************
477 template< typename MT > // Type of the adapted matrix
479 {
480  return value_;
481 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
490 template< typename MT > // Type of the adapted matrix
491 inline bool StrictlyLowerProxy<MT>::isRestricted() const noexcept
492 {
493  return restricted_;
494 }
495 //*************************************************************************************************
496 
497 
498 
499 
500 //=================================================================================================
501 //
502 // CONVERSION OPERATOR
503 //
504 //=================================================================================================
505 
506 //*************************************************************************************************
511 template< typename MT > // Type of the adapted matrix
513 {
514  return static_cast<ConstReference>( value_ );
515 }
516 //*************************************************************************************************
517 
518 
519 
520 
521 //=================================================================================================
522 //
523 // GLOBAL FUNCTIONS
524 //
525 //=================================================================================================
526 
527 //*************************************************************************************************
530 template< typename MT >
531 inline void reset( const StrictlyLowerProxy<MT>& proxy );
532 
533 template< typename MT >
534 inline void clear( const StrictlyLowerProxy<MT>& proxy );
535 
536 template< bool RF, typename MT >
537 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy );
538 
539 template< bool RF, typename MT >
540 inline bool isReal( const StrictlyLowerProxy<MT>& proxy );
541 
542 template< bool RF, typename MT >
543 inline bool isZero( const StrictlyLowerProxy<MT>& proxy );
544 
545 template< bool RF, typename MT >
546 inline bool isOne( const StrictlyLowerProxy<MT>& proxy );
547 
548 template< typename MT >
549 inline bool isnan( const StrictlyLowerProxy<MT>& proxy );
551 //*************************************************************************************************
552 
553 
554 //*************************************************************************************************
564 template< typename MT >
565 inline void reset( const StrictlyLowerProxy<MT>& proxy )
566 {
567  using blaze::reset;
568 
569  reset( proxy.get() );
570 }
571 //*************************************************************************************************
572 
573 
574 //*************************************************************************************************
584 template< typename MT >
585 inline void clear( const StrictlyLowerProxy<MT>& proxy )
586 {
587  using blaze::clear;
588 
589  clear( proxy.get() );
590 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
604 template< bool RF, typename MT >
605 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
606 {
607  using blaze::isDefault;
608 
609  return isDefault<RF>( proxy.get() );
610 }
611 //*************************************************************************************************
612 
613 
614 //*************************************************************************************************
626 template< bool RF, typename MT >
627 inline bool isReal( const StrictlyLowerProxy<MT>& proxy )
628 {
629  using blaze::isReal;
630 
631  return isReal<RF>( proxy.get() );
632 }
633 //*************************************************************************************************
634 
635 
636 //*************************************************************************************************
646 template< bool RF, typename MT >
647 inline bool isZero( const StrictlyLowerProxy<MT>& proxy )
648 {
649  using blaze::isZero;
650 
651  return isZero<RF>( proxy.get() );
652 }
653 //*************************************************************************************************
654 
655 
656 //*************************************************************************************************
666 template< bool RF, typename MT >
667 inline bool isOne( const StrictlyLowerProxy<MT>& proxy )
668 {
669  using blaze::isOne;
670 
671  return isOne<RF>( proxy.get() );
672 }
673 //*************************************************************************************************
674 
675 
676 //*************************************************************************************************
686 template< typename MT >
687 inline bool isnan( const StrictlyLowerProxy<MT>& proxy )
688 {
689  using blaze::isnan;
690 
691  return isnan( proxy.get() );
692 }
693 //*************************************************************************************************
694 
695 } // namespace blaze
696 
697 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:622
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
Header file for the AddConst type trait.
Header file for auxiliary alias declarations.
Header file for basic type definitions.
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyLowerProxy.h:111
Proxy base class.The Proxy class is a base class for all proxy classes within the Blaze library that ...
Definition: Forward.h:51
const StrictlyLowerProxy & operator=(const StrictlyLowerProxy &ulp) const
Copy assignment operator for StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:249
typename AddConst< T >::Type AddConst_
Auxiliary alias declaration for the AddConst type trait.The AddConst_ alias declaration provides a co...
Definition: AddConst.h:95
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
#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
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
Constraint on the data type.
Header file for the Proxy class.
Constraint on the data type.
Constraint on the data type.
Header file for the std::initializer_list aliases.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:642
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:478
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyLowerProxy.h:113
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:168
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.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:682
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
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
Header file for the isOne shim.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:491
#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
#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
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:662
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
AddReference_< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyLowerProxy.h:112
Initializer list type of the Blaze library.
#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
Header file for the AddReference type trait.
AddConst_< Reference_< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyLowerProxy.h:106
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#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
StrictlyLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:209
Header file for the isReal shim.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:167
typename AddReference< T >::Type AddReference_
Auxiliary alias declaration for the AddReference type trait.The AddReference_ alias declaration provi...
Definition: AddReference.h:95