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  //**Access operators****************************************************************************
151  inline const StrictlyLowerProxy* operator->() const noexcept;
153  //**********************************************************************************************
154 
155  //**Utility functions***************************************************************************
158  inline RawReference get() const noexcept;
159  inline bool isRestricted() const noexcept;
161  //**********************************************************************************************
162 
163  //**Conversion operator*************************************************************************
166  inline operator ConstReference() const noexcept;
168  //**********************************************************************************************
169 
170  private:
171  //**Member variables****************************************************************************
175  const bool restricted_;
176 
180  //**********************************************************************************************
181 
182  //**Compile time checks*************************************************************************
195  //**********************************************************************************************
196 };
197 //*************************************************************************************************
198 
199 
200 
201 
202 //=================================================================================================
203 //
204 // CONSTRUCTORS
205 //
206 //=================================================================================================
207 
208 //*************************************************************************************************
215 template< typename MT > // Type of the adapted matrix
216 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
217  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
218  , restricted_( row <= column ) // Access flag for the accessed matrix element
219 {}
220 //*************************************************************************************************
221 
222 
223 //*************************************************************************************************
228 template< typename MT > // Type of the adapted matrix
230  : value_ ( slp.value_ ) // Reference to the accessed matrix element
231  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
232 {}
233 //*************************************************************************************************
234 
235 
236 
237 
238 //=================================================================================================
239 //
240 // OPERATORS
241 //
242 //=================================================================================================
243 
244 //*************************************************************************************************
254 template< typename MT > // Type of the adapted matrix
255 inline const StrictlyLowerProxy<MT>&
257 {
258  if( restricted_ ) {
259  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
260  }
261 
262  value_ = slp.value_;
263 
264  return *this;
265 }
266 //*************************************************************************************************
267 
268 
269 //*************************************************************************************************
279 template< typename MT > // Type of the adapted matrix
280 template< typename T > // Type of the right-hand side value
281 inline const StrictlyLowerProxy<MT>&
283 {
284  if( restricted_ ) {
285  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
286  }
287 
288  value_ = list;
289 
290  return *this;
291 }
292 //*************************************************************************************************
293 
294 
295 //*************************************************************************************************
305 template< typename MT > // Type of the adapted matrix
306 template< typename T > // Type of the right-hand side value
307 inline const StrictlyLowerProxy<MT>&
309 {
310  if( restricted_ ) {
311  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
312  }
313 
314  value_ = list;
315 
316  return *this;
317 }
318 //*************************************************************************************************
319 
320 
321 //*************************************************************************************************
331 template< typename MT > // Type of the adapted matrix
332 template< typename T > // Type of the right-hand side value
333 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
334 {
335  if( restricted_ ) {
336  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
337  }
338 
339  value_ = value;
340 
341  return *this;
342 }
343 //*************************************************************************************************
344 
345 
346 //*************************************************************************************************
356 template< typename MT > // Type of the adapted matrix
357 template< typename T > // Type of the right-hand side value
358 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
359 {
360  if( restricted_ ) {
361  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
362  }
363 
364  value_ += value;
365 
366  return *this;
367 }
368 //*************************************************************************************************
369 
370 
371 //*************************************************************************************************
381 template< typename MT > // Type of the adapted matrix
382 template< typename T > // Type of the right-hand side value
383 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
384 {
385  if( restricted_ ) {
386  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
387  }
388 
389  value_ -= value;
390 
391  return *this;
392 }
393 //*************************************************************************************************
394 
395 
396 //*************************************************************************************************
406 template< typename MT > // Type of the adapted matrix
407 template< typename T > // Type of the right-hand side value
408 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
409 {
410  if( restricted_ ) {
411  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
412  }
413 
414  value_ *= value;
415 
416  return *this;
417 }
418 //*************************************************************************************************
419 
420 
421 //*************************************************************************************************
431 template< typename MT > // Type of the adapted matrix
432 template< typename T > // Type of the right-hand side value
433 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
434 {
435  if( restricted_ ) {
436  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
437  }
438 
439  value_ /= value;
440 
441  return *this;
442 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
456 template< typename MT > // Type of the adapted matrix
457 template< typename T > // Type of the right-hand side value
458 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator%=( const T& value ) const
459 {
460  if( restricted_ ) {
461  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
462  }
463 
464  value_ %= value;
465 
466  return *this;
467 }
468 //*************************************************************************************************
469 
470 
471 
472 
473 //=================================================================================================
474 //
475 // ACCESS OPERATORS
476 //
477 //=================================================================================================
478 
479 //*************************************************************************************************
484 template< typename MT > // Type of the adapted matrix
486 {
487  return this;
488 }
489 //*************************************************************************************************
490 
491 
492 
493 
494 //=================================================================================================
495 //
496 // UTILITY FUNCTIONS
497 //
498 //=================================================================================================
499 
500 //*************************************************************************************************
505 template< typename MT > // Type of the adapted matrix
507 {
508  return value_;
509 }
510 //*************************************************************************************************
511 
512 
513 //*************************************************************************************************
518 template< typename MT > // Type of the adapted matrix
519 inline bool StrictlyLowerProxy<MT>::isRestricted() const noexcept
520 {
521  return restricted_;
522 }
523 //*************************************************************************************************
524 
525 
526 
527 
528 //=================================================================================================
529 //
530 // CONVERSION OPERATOR
531 //
532 //=================================================================================================
533 
534 //*************************************************************************************************
539 template< typename MT > // Type of the adapted matrix
541 {
542  return static_cast<ConstReference>( value_ );
543 }
544 //*************************************************************************************************
545 
546 
547 
548 
549 //=================================================================================================
550 //
551 // GLOBAL FUNCTIONS
552 //
553 //=================================================================================================
554 
555 //*************************************************************************************************
558 template< typename MT >
559 inline void reset( const StrictlyLowerProxy<MT>& proxy );
560 
561 template< typename MT >
562 inline void clear( const StrictlyLowerProxy<MT>& proxy );
563 
564 template< bool RF, typename MT >
565 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy );
566 
567 template< bool RF, typename MT >
568 inline bool isReal( const StrictlyLowerProxy<MT>& proxy );
569 
570 template< bool RF, typename MT >
571 inline bool isZero( const StrictlyLowerProxy<MT>& proxy );
572 
573 template< bool RF, typename MT >
574 inline bool isOne( const StrictlyLowerProxy<MT>& proxy );
575 
576 template< typename MT >
577 inline bool isnan( const StrictlyLowerProxy<MT>& proxy );
579 //*************************************************************************************************
580 
581 
582 //*************************************************************************************************
592 template< typename MT >
593 inline void reset( const StrictlyLowerProxy<MT>& proxy )
594 {
595  using blaze::reset;
596 
597  reset( proxy.get() );
598 }
599 //*************************************************************************************************
600 
601 
602 //*************************************************************************************************
612 template< typename MT >
613 inline void clear( const StrictlyLowerProxy<MT>& proxy )
614 {
615  using blaze::clear;
616 
617  clear( proxy.get() );
618 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
632 template< bool RF, typename MT >
633 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
634 {
635  using blaze::isDefault;
636 
637  return isDefault<RF>( proxy.get() );
638 }
639 //*************************************************************************************************
640 
641 
642 //*************************************************************************************************
654 template< bool RF, typename MT >
655 inline bool isReal( const StrictlyLowerProxy<MT>& proxy )
656 {
657  using blaze::isReal;
658 
659  return isReal<RF>( proxy.get() );
660 }
661 //*************************************************************************************************
662 
663 
664 //*************************************************************************************************
674 template< bool RF, typename MT >
675 inline bool isZero( const StrictlyLowerProxy<MT>& proxy )
676 {
677  using blaze::isZero;
678 
679  return isZero<RF>( proxy.get() );
680 }
681 //*************************************************************************************************
682 
683 
684 //*************************************************************************************************
694 template< bool RF, typename MT >
695 inline bool isOne( const StrictlyLowerProxy<MT>& proxy )
696 {
697  using blaze::isOne;
698 
699  return isOne<RF>( proxy.get() );
700 }
701 //*************************************************************************************************
702 
703 
704 //*************************************************************************************************
714 template< typename MT >
715 inline bool isnan( const StrictlyLowerProxy<MT>& proxy )
716 {
717  using blaze::isnan;
718 
719  return isnan( proxy.get() );
720 }
721 //*************************************************************************************************
722 
723 } // namespace blaze
724 
725 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:650
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.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
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:256
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:588
#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
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the Proxy class.
Constraint on the data type.
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:506
const StrictlyLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyLowerProxy.h:485
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:58
#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:175
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:710
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:608
Header file for the isOne shim.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:519
#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.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
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:690
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:628
#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:216
Header file for the isReal shim.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:174
typename AddReference< T >::Type AddReference_
Auxiliary alias declaration for the AddReference type trait.The AddReference_ alias declaration provi...
Definition: AddReference.h:95