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_t<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**********************************************************************************
127  ~StrictlyLowerProxy() = default;
129  //**********************************************************************************************
130 
131  //**Assignment operators************************************************************************
134  inline const StrictlyLowerProxy& operator=( const StrictlyLowerProxy& ulp ) const;
135 
136  template< typename T >
137  inline const StrictlyLowerProxy& operator=( initializer_list<T> list ) const;
138 
139  template< typename T >
140  inline const StrictlyLowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
141 
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;
145  template< typename T > inline const StrictlyLowerProxy& operator*=( const T& value ) const;
146  template< typename T > inline const StrictlyLowerProxy& operator/=( const T& value ) const;
147  template< typename T > inline const StrictlyLowerProxy& operator%=( const T& value ) const;
149  //**********************************************************************************************
150 
151  //**Access operators****************************************************************************
154  inline const StrictlyLowerProxy* 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_;
179 
183  //**********************************************************************************************
184 
185  //**Compile time checks*************************************************************************
198  //**********************************************************************************************
199 };
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 // CONSTRUCTORS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
218 template< typename MT > // Type of the adapted matrix
219 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
220  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
221  , restricted_( row <= column ) // Access flag for the accessed matrix element
222 {}
223 //*************************************************************************************************
224 
225 
226 //*************************************************************************************************
231 template< typename MT > // Type of the adapted matrix
233  : value_ ( slp.value_ ) // Reference to the accessed matrix element
234  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
235 {}
236 //*************************************************************************************************
237 
238 
239 
240 
241 //=================================================================================================
242 //
243 // OPERATORS
244 //
245 //=================================================================================================
246 
247 //*************************************************************************************************
257 template< typename MT > // Type of the adapted matrix
258 inline const StrictlyLowerProxy<MT>&
260 {
261  if( restricted_ ) {
262  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
263  }
264 
265  value_ = slp.value_;
266 
267  return *this;
268 }
269 //*************************************************************************************************
270 
271 
272 //*************************************************************************************************
282 template< typename MT > // Type of the adapted matrix
283 template< typename T > // Type of the right-hand side value
284 inline const StrictlyLowerProxy<MT>&
286 {
287  if( restricted_ ) {
288  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
289  }
290 
291  value_ = list;
292 
293  return *this;
294 }
295 //*************************************************************************************************
296 
297 
298 //*************************************************************************************************
308 template< typename MT > // Type of the adapted matrix
309 template< typename T > // Type of the right-hand side value
310 inline const StrictlyLowerProxy<MT>&
312 {
313  if( restricted_ ) {
314  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
315  }
316 
317  value_ = list;
318 
319  return *this;
320 }
321 //*************************************************************************************************
322 
323 
324 //*************************************************************************************************
334 template< typename MT > // Type of the adapted matrix
335 template< typename T > // Type of the right-hand side value
336 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
337 {
338  if( restricted_ ) {
339  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
340  }
341 
342  value_ = value;
343 
344  return *this;
345 }
346 //*************************************************************************************************
347 
348 
349 //*************************************************************************************************
359 template< typename MT > // Type of the adapted matrix
360 template< typename T > // Type of the right-hand side value
361 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
362 {
363  if( restricted_ ) {
364  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
365  }
366 
367  value_ += value;
368 
369  return *this;
370 }
371 //*************************************************************************************************
372 
373 
374 //*************************************************************************************************
384 template< typename MT > // Type of the adapted matrix
385 template< typename T > // Type of the right-hand side value
386 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
387 {
388  if( restricted_ ) {
389  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
390  }
391 
392  value_ -= value;
393 
394  return *this;
395 }
396 //*************************************************************************************************
397 
398 
399 //*************************************************************************************************
409 template< typename MT > // Type of the adapted matrix
410 template< typename T > // Type of the right-hand side value
411 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
412 {
413  if( restricted_ ) {
414  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
415  }
416 
417  value_ *= value;
418 
419  return *this;
420 }
421 //*************************************************************************************************
422 
423 
424 //*************************************************************************************************
434 template< typename MT > // Type of the adapted matrix
435 template< typename T > // Type of the right-hand side value
436 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
437 {
438  if( restricted_ ) {
439  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
440  }
441 
442  value_ /= value;
443 
444  return *this;
445 }
446 //*************************************************************************************************
447 
448 
449 //*************************************************************************************************
459 template< typename MT > // Type of the adapted matrix
460 template< typename T > // Type of the right-hand side value
461 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator%=( const T& value ) const
462 {
463  if( restricted_ ) {
464  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
465  }
466 
467  value_ %= value;
468 
469  return *this;
470 }
471 //*************************************************************************************************
472 
473 
474 
475 
476 //=================================================================================================
477 //
478 // ACCESS OPERATORS
479 //
480 //=================================================================================================
481 
482 //*************************************************************************************************
487 template< typename MT > // Type of the adapted matrix
489 {
490  return this;
491 }
492 //*************************************************************************************************
493 
494 
495 
496 
497 //=================================================================================================
498 //
499 // UTILITY FUNCTIONS
500 //
501 //=================================================================================================
502 
503 //*************************************************************************************************
508 template< typename MT > // Type of the adapted matrix
510 {
511  return value_;
512 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
521 template< typename MT > // Type of the adapted matrix
522 inline bool StrictlyLowerProxy<MT>::isRestricted() const noexcept
523 {
524  return restricted_;
525 }
526 //*************************************************************************************************
527 
528 
529 
530 
531 //=================================================================================================
532 //
533 // CONVERSION OPERATOR
534 //
535 //=================================================================================================
536 
537 //*************************************************************************************************
542 template< typename MT > // Type of the adapted matrix
544 {
545  return static_cast<ConstReference>( value_ );
546 }
547 //*************************************************************************************************
548 
549 
550 
551 
552 //=================================================================================================
553 //
554 // GLOBAL FUNCTIONS
555 //
556 //=================================================================================================
557 
558 //*************************************************************************************************
561 template< typename MT >
562 void reset( const StrictlyLowerProxy<MT>& proxy );
563 
564 template< typename MT >
565 void clear( const StrictlyLowerProxy<MT>& proxy );
566 
567 template< bool RF, typename MT >
568 bool isDefault( const StrictlyLowerProxy<MT>& proxy );
569 
570 template< bool RF, typename MT >
571 bool isReal( const StrictlyLowerProxy<MT>& proxy );
572 
573 template< bool RF, typename MT >
574 bool isZero( const StrictlyLowerProxy<MT>& proxy );
575 
576 template< bool RF, typename MT >
577 bool isOne( const StrictlyLowerProxy<MT>& proxy );
578 
579 template< typename MT >
580 bool isnan( const StrictlyLowerProxy<MT>& proxy );
582 //*************************************************************************************************
583 
584 
585 //*************************************************************************************************
595 template< typename MT >
596 inline void reset( const StrictlyLowerProxy<MT>& proxy )
597 {
598  using blaze::reset;
599 
600  reset( proxy.get() );
601 }
602 //*************************************************************************************************
603 
604 
605 //*************************************************************************************************
615 template< typename MT >
616 inline void clear( const StrictlyLowerProxy<MT>& proxy )
617 {
618  using blaze::clear;
619 
620  clear( proxy.get() );
621 }
622 //*************************************************************************************************
623 
624 
625 //*************************************************************************************************
635 template< bool RF, typename MT >
636 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
637 {
638  using blaze::isDefault;
639 
640  return isDefault<RF>( proxy.get() );
641 }
642 //*************************************************************************************************
643 
644 
645 //*************************************************************************************************
657 template< bool RF, typename MT >
658 inline bool isReal( const StrictlyLowerProxy<MT>& proxy )
659 {
660  using blaze::isReal;
661 
662  return isReal<RF>( proxy.get() );
663 }
664 //*************************************************************************************************
665 
666 
667 //*************************************************************************************************
677 template< bool RF, typename MT >
678 inline bool isZero( const StrictlyLowerProxy<MT>& proxy )
679 {
680  using blaze::isZero;
681 
682  return isZero<RF>( proxy.get() );
683 }
684 //*************************************************************************************************
685 
686 
687 //*************************************************************************************************
697 template< bool RF, typename MT >
698 inline bool isOne( const StrictlyLowerProxy<MT>& proxy )
699 {
700  using blaze::isOne;
701 
702  return isOne<RF>( proxy.get() );
703 }
704 //*************************************************************************************************
705 
706 
707 //*************************************************************************************************
717 template< typename MT >
718 inline bool isnan( const StrictlyLowerProxy<MT>& proxy )
719 {
720  using blaze::isnan;
721 
722  return isnan( proxy.get() );
723 }
724 //*************************************************************************************************
725 
726 } // namespace blaze
727 
728 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:653
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:133
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
Header file for the isZero shim.
const StrictlyLowerProxy & operator=(const StrictlyLowerProxy &ulp) const
Copy assignment operator for StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:259
AddReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyLowerProxy.h:112
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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 reset shim.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the Proxy class.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the data type.
Constraint on the data type.
typename AddReference< T >::Type AddReference_t
Auxiliary alias declaration for the AddReference type trait.The AddReference_t alias declaration prov...
Definition: AddReference.h:95
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:509
const StrictlyLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyLowerProxy.h:488
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyLowerProxy.h:113
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
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyLowerProxy.h:178
Constraint on the data type.
typename AddConst< T >::Type AddConst_t
Auxiliary alias declaration for the AddConst type trait.The AddConst_t alias declaration provides a c...
Definition: AddConst.h:95
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:713
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:611
Header file for the isOne shim.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:522
#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:133
#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:693
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
AddConst_t< Reference_t< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyLowerProxy.h:106
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.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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_t< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyLowerProxy.h:111
StrictlyLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:219
Header file for the isReal shim.
Header file for the clear shim.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:177