UniLowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_UNILOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_UNILOWERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
51 #include <blaze/math/proxy/Proxy.h>
52 #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>
65 #include <blaze/util/InvalidType.h>
66 #include <blaze/util/mpl/If.h>
67 #include <blaze/util/Types.h>
69 
70 
71 namespace blaze {
72 
73 //=================================================================================================
74 //
75 // CLASS DEFINITION
76 //
77 //=================================================================================================
78 
79 //*************************************************************************************************
100 template< typename MT > // Type of the adapted matrix
102  : public Proxy< UniLowerProxy<MT> >
103 {
104  private:
105  //**Type definitions****************************************************************************
107  using ReferenceType = typename MT::Reference;
108  //**********************************************************************************************
109 
110  //**struct BuiltinType**************************************************************************
114  template< typename T >
115  struct BuiltinType { using Type = INVALID_TYPE; };
117  //**********************************************************************************************
118 
119  //**struct ComplexType**************************************************************************
123  template< typename T >
124  struct ComplexType { using Type = typename T::value_type; };
126  //**********************************************************************************************
127 
128  public:
129  //**Type definitions****************************************************************************
132 
135  , ComplexType<RepresentedType>
136  , BuiltinType<RepresentedType> >::Type;
137 
139  //**********************************************************************************************
140 
141  //**Constructors********************************************************************************
144  explicit inline UniLowerProxy( MT& matrix, size_t row, size_t column );
145  inline UniLowerProxy( const UniLowerProxy& ulp );
147  //**********************************************************************************************
148 
149  //**Destructor**********************************************************************************
152  ~UniLowerProxy() = default;
154  //**********************************************************************************************
155 
156  //**Assignment operators************************************************************************
159  inline const UniLowerProxy& operator= ( const UniLowerProxy& ulp ) const;
160  template< typename T > inline const UniLowerProxy& operator= ( const T& value ) const;
161  template< typename T > inline const UniLowerProxy& operator+=( const T& value ) const;
162  template< typename T > inline const UniLowerProxy& operator-=( const T& value ) const;
163  template< typename T > inline const UniLowerProxy& operator*=( const T& value ) const;
164  template< typename T > inline const UniLowerProxy& operator/=( const T& value ) const;
165  template< typename T > inline const UniLowerProxy& operator%=( const T& value ) const;
167  //**********************************************************************************************
168 
169  //**Access operators****************************************************************************
172  inline const UniLowerProxy* operator->() const noexcept;
174  //**********************************************************************************************
175 
176  //**Utility functions***************************************************************************
179  inline void reset () const;
180  inline void clear () const;
181  inline void invert() const;
182 
183  inline RepresentedType get() const noexcept;
184  inline bool isRestricted() const noexcept;
186  //**********************************************************************************************
187 
188  //**Conversion operator*************************************************************************
191  inline operator RepresentedType() const noexcept;
193  //**********************************************************************************************
194 
195  //**Complex data access functions***************************************************************
198  inline ValueType real() const;
199  inline void real( ValueType value ) const;
200  inline ValueType imag() const;
201  inline void imag( ValueType value ) const;
203  //**********************************************************************************************
204 
205  private:
206  //**Member variables****************************************************************************
210  size_t row_;
211  size_t column_;
212 
213  //**********************************************************************************************
214 
215  //**Compile time checks*************************************************************************
229  //**********************************************************************************************
230 };
231 //*************************************************************************************************
232 
233 
234 
235 
236 //=================================================================================================
237 //
238 // CONSTRUCTORS
239 //
240 //=================================================================================================
241 
242 //*************************************************************************************************
249 template< typename MT > // Type of the adapted matrix
250 inline UniLowerProxy<MT>::UniLowerProxy( MT& matrix, size_t row, size_t column )
251  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
252  , row_ ( row ) // Row index of the accessed matrix element
253  , column_( column ) // Column index of the accessed matrix element
254 {}
255 //*************************************************************************************************
256 
257 
258 //*************************************************************************************************
263 template< typename MT > // Type of the adapted matrix
265  : value_ ( ulp.value_ ) // Reference to the accessed matrix element
266  , row_ ( ulp.row_ ) // Row index of the accessed matrix element
267  , column_( ulp.column_ ) // Column index of the accessed matrix element
268 {}
269 //*************************************************************************************************
270 
271 
272 
273 
274 //=================================================================================================
275 //
276 // OPERATORS
277 //
278 //=================================================================================================
279 
280 //*************************************************************************************************
290 template< typename MT > // Type of the adapted matrix
292 {
293  if( isRestricted() ) {
294  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
295  }
296 
297  value_ = ulp.value_;
298 
299  return *this;
300 }
301 //*************************************************************************************************
302 
303 
304 //*************************************************************************************************
314 template< typename MT > // Type of the adapted matrix
315 template< typename T > // Type of the right-hand side value
316 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator=( const T& value ) const
317 {
318  if( isRestricted() ) {
319  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
320  }
321 
322  value_ = value;
323 
324  return *this;
325 }
326 //*************************************************************************************************
327 
328 
329 //*************************************************************************************************
339 template< typename MT > // Type of the adapted matrix
340 template< typename T > // Type of the right-hand side value
341 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator+=( const T& value ) const
342 {
343  if( isRestricted() ) {
344  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
345  }
346 
347  value_ += value;
348 
349  return *this;
350 }
351 //*************************************************************************************************
352 
353 
354 //*************************************************************************************************
364 template< typename MT > // Type of the adapted matrix
365 template< typename T > // Type of the right-hand side value
366 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator-=( const T& value ) const
367 {
368  if( isRestricted() ) {
369  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
370  }
371 
372  value_ -= value;
373 
374  return *this;
375 }
376 //*************************************************************************************************
377 
378 
379 //*************************************************************************************************
389 template< typename MT > // Type of the adapted matrix
390 template< typename T > // Type of the right-hand side value
391 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator*=( const T& value ) const
392 {
393  if( isRestricted() ) {
394  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
395  }
396 
397  value_ *= value;
398 
399  return *this;
400 }
401 //*************************************************************************************************
402 
403 
404 //*************************************************************************************************
414 template< typename MT > // Type of the adapted matrix
415 template< typename T > // Type of the right-hand side value
416 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator/=( const T& value ) const
417 {
418  if( isRestricted() ) {
419  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
420  }
421 
422  value_ /= value;
423 
424  return *this;
425 }
426 //*************************************************************************************************
427 
428 
429 //*************************************************************************************************
439 template< typename MT > // Type of the adapted matrix
440 template< typename T > // Type of the right-hand side value
441 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator%=( const T& value ) const
442 {
443  if( isRestricted() ) {
444  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
445  }
446 
447  value_ %= value;
448 
449  return *this;
450 }
451 //*************************************************************************************************
452 
453 
454 
455 
456 //=================================================================================================
457 //
458 // ACCESS OPERATORS
459 //
460 //=================================================================================================
461 
462 //*************************************************************************************************
467 template< typename MT > // Type of the adapted matrix
468 inline const UniLowerProxy<MT>* UniLowerProxy<MT>::operator->() const noexcept
469 {
470  return this;
471 }
472 //*************************************************************************************************
473 
474 
475 
476 
477 //=================================================================================================
478 //
479 // UTILITY FUNCTIONS
480 //
481 //=================================================================================================
482 
483 //*************************************************************************************************
490 template< typename MT > // Type of the adapted matrix
491 inline void UniLowerProxy<MT>::reset() const
492 {
493  using blaze::reset;
494 
495  if( column_ < row_ )
496  reset( value_ );
497 }
498 //*************************************************************************************************
499 
500 
501 //*************************************************************************************************
508 template< typename MT > // Type of the adapted matrix
509 inline void UniLowerProxy<MT>::clear() const
510 {
511  using blaze::clear;
512 
513  if( column_ < row_ )
514  clear( value_ );
515 }
516 //*************************************************************************************************
517 
518 
519 //*************************************************************************************************
527 template< typename MT > // Type of the adapted matrix
528 inline void UniLowerProxy<MT>::invert() const
529 {
530  using blaze::invert;
531 
532  if( row_ < column_ ) {
533  BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of upper matrix element" );
534  }
535 
536  if( column_ < row_ )
537  invert( value_ );
538 }
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
547 template< typename MT > // Type of the adapted matrix
549 {
550  return value_;
551 }
552 //*************************************************************************************************
553 
554 
555 //*************************************************************************************************
560 template< typename MT > // Type of the adapted matrix
561 inline bool UniLowerProxy<MT>::isRestricted() const noexcept
562 {
563  return row_ <= column_;
564 }
565 //*************************************************************************************************
566 
567 
568 
569 
570 //=================================================================================================
571 //
572 // CONVERSION OPERATOR
573 //
574 //=================================================================================================
575 
576 //*************************************************************************************************
581 template< typename MT > // Type of the adapted matrix
583 {
584  return get();
585 }
586 //*************************************************************************************************
587 
588 
589 
590 
591 //=================================================================================================
592 //
593 // COMPLEX DATA ACCESS FUNCTIONS
594 //
595 //=================================================================================================
596 
597 //*************************************************************************************************
605 template< typename MT > // Type of the adapted matrix
607 {
608  return value_.real();
609 }
610 //*************************************************************************************************
611 
612 
613 //*************************************************************************************************
624 template< typename MT > // Type of the adapted matrix
625 inline void UniLowerProxy<MT>::real( ValueType value ) const
626 {
627  if( isRestricted() ) {
628  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
629  }
630 
631  value_.real( value );
632 }
633 //*************************************************************************************************
634 
635 
636 //*************************************************************************************************
644 template< typename MT > // Type of the adapted matrix
646 {
647  return value_.imag();
648 }
649 //*************************************************************************************************
650 
651 
652 //*************************************************************************************************
663 template< typename MT > // Type of the adapted matrix
664 inline void UniLowerProxy<MT>::imag( ValueType value ) const
665 {
666  if( isRestricted() ) {
667  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
668  }
669 
670  value_.imag( value );
671 }
672 //*************************************************************************************************
673 
674 
675 
676 
677 //=================================================================================================
678 //
679 // GLOBAL FUNCTIONS
680 //
681 //=================================================================================================
682 
683 //*************************************************************************************************
686 template< typename MT >
687 void reset( const UniLowerProxy<MT>& proxy );
688 
689 template< typename MT >
690 void clear( const UniLowerProxy<MT>& proxy );
691 
692 template< typename MT >
693 void invert( const UniLowerProxy<MT>& proxy );
694 
695 template< bool RF, typename MT >
696 bool isDefault( const UniLowerProxy<MT>& proxy );
697 
698 template< bool RF, typename MT >
699 bool isReal( const UniLowerProxy<MT>& proxy );
700 
701 template< bool RF, typename MT >
702 bool isZero( const UniLowerProxy<MT>& proxy );
703 
704 template< bool RF, typename MT >
705 bool isOne( const UniLowerProxy<MT>& proxy );
706 
707 template< typename MT >
708 bool isnan( const UniLowerProxy<MT>& proxy );
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
723 template< typename MT >
724 inline void reset( const UniLowerProxy<MT>& proxy )
725 {
726  proxy.reset();
727 }
728 //*************************************************************************************************
729 
730 
731 //*************************************************************************************************
741 template< typename MT >
742 inline void clear( const UniLowerProxy<MT>& proxy )
743 {
744  proxy.clear();
745 }
746 //*************************************************************************************************
747 
748 
749 //*************************************************************************************************
756 template< typename MT >
757 inline void invert( const UniLowerProxy<MT>& proxy )
758 {
759  proxy.invert();
760 }
761 //*************************************************************************************************
762 
763 
764 //*************************************************************************************************
774 template< bool RF, typename MT >
775 inline bool isDefault( const UniLowerProxy<MT>& proxy )
776 {
777  using blaze::isDefault;
778 
779  return isDefault<RF>( proxy.get() );
780 }
781 //*************************************************************************************************
782 
783 
784 //*************************************************************************************************
796 template< bool RF, typename MT >
797 inline bool isReal( const UniLowerProxy<MT>& proxy )
798 {
799  using blaze::isReal;
800 
801  return isReal<RF>( proxy.get() );
802 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
816 template< bool RF, typename MT >
817 inline bool isZero( const UniLowerProxy<MT>& proxy )
818 {
819  using blaze::isZero;
820 
821  return isZero<RF>( proxy.get() );
822 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
836 template< bool RF, typename MT >
837 inline bool isOne( const UniLowerProxy<MT>& proxy )
838 {
839  using blaze::isOne;
840 
841  return isOne<RF>( proxy.get() );
842 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
856 template< typename MT >
857 inline bool isnan( const UniLowerProxy<MT>& proxy )
858 {
859  using blaze::isnan;
860 
861  return isnan( proxy.get() );
862 }
863 //*************************************************************************************************
864 
865 } // namespace blaze
866 
867 #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 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
Constraint on the data type.
const UniLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: UniLowerProxy.h:468
Header file for basic type definitions.
typename If_t< IsComplex_v< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type ValueType
Value type of the represented complex element.
Definition: UniLowerProxy.h:136
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: UniLowerProxy.h:561
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
Proxy base class.The Proxy class is a base class for all proxy classes within the Blaze library that ...
Definition: Forward.h:51
ReferenceType value_
Reference to the accessed matrix element.
Definition: UniLowerProxy.h:209
Header file for the isZero shim.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
#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 invert shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerProxy.h:138
Header file for the reset shim.
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
const UniLowerProxy & operator=(const UniLowerProxy &ulp) const
Copy assignment operator for UniLowerProxy.
Definition: UniLowerProxy.h:291
Constraint on the data type.
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerProxy.h:606
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
typename MT::Reference ReferenceType
Reference type of the underlying matrix type.
Definition: UniLowerProxy.h:107
#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.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerProxy.h:645
Constraint on the data type.
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
void invert() const
In-place inversion of the represented element.
Definition: UniLowerProxy.h:528
Header file for the isOne shim.
#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
RepresentedType get() const noexcept
Returning the value of the accessed matrix element.
Definition: UniLowerProxy.h:548
Utility type for generic codes.
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_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
#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.
size_t row_
Row index of the accessed matrix element.
Definition: UniLowerProxy.h:210
UniLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an UniLowerProxy.
Definition: UniLowerProxy.h:250
void reset() const
Reset the represented element to its default initial value.
Definition: UniLowerProxy.h:491
size_t column_
Column index of the accessed matrix element.
Definition: UniLowerProxy.h:211
#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
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerProxy.h:131
Header file for the IsComplex 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
Access proxy for lower unitriangular matrices.The UniLowerProxy provides controlled access to the ele...
Definition: UniLowerProxy.h:101
Header file for the isReal shim.
Header file for the clear shim.
void clear() const
Clearing the represented element.
Definition: UniLowerProxy.h:509