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**********************************************************************************
150  // No explicitly declared destructor.
151  //**********************************************************************************************
152 
153  //**Assignment operators************************************************************************
156  inline const UniLowerProxy& operator= ( const UniLowerProxy& ulp ) const;
157  template< typename T > inline const UniLowerProxy& operator= ( const T& value ) const;
158  template< typename T > inline const UniLowerProxy& operator+=( const T& value ) const;
159  template< typename T > inline const UniLowerProxy& operator-=( const T& value ) 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;
164  //**********************************************************************************************
165 
166  //**Access operators****************************************************************************
169  inline const UniLowerProxy* operator->() const noexcept;
171  //**********************************************************************************************
172 
173  //**Utility functions***************************************************************************
176  inline void reset () const;
177  inline void clear () const;
178  inline void invert() const;
179 
180  inline RepresentedType get() const noexcept;
181  inline bool isRestricted() const noexcept;
183  //**********************************************************************************************
184 
185  //**Conversion operator*************************************************************************
188  inline operator RepresentedType() const noexcept;
190  //**********************************************************************************************
191 
192  //**Complex data access functions***************************************************************
195  inline ValueType real() const;
196  inline void real( ValueType value ) const;
197  inline ValueType imag() const;
198  inline void imag( ValueType value ) const;
200  //**********************************************************************************************
201 
202  private:
203  //**Member variables****************************************************************************
207  size_t row_;
208  size_t column_;
209 
210  //**********************************************************************************************
211 
212  //**Compile time checks*************************************************************************
226  //**********************************************************************************************
227 };
228 //*************************************************************************************************
229 
230 
231 
232 
233 //=================================================================================================
234 //
235 // CONSTRUCTORS
236 //
237 //=================================================================================================
238 
239 //*************************************************************************************************
246 template< typename MT > // Type of the adapted matrix
247 inline UniLowerProxy<MT>::UniLowerProxy( MT& matrix, size_t row, size_t column )
248  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
249  , row_ ( row ) // Row index of the accessed matrix element
250  , column_( column ) // Column index of the accessed matrix element
251 {}
252 //*************************************************************************************************
253 
254 
255 //*************************************************************************************************
260 template< typename MT > // Type of the adapted matrix
262  : value_ ( ulp.value_ ) // Reference to the accessed matrix element
263  , row_ ( ulp.row_ ) // Row index of the accessed matrix element
264  , column_( ulp.column_ ) // Column index of the accessed matrix element
265 {}
266 //*************************************************************************************************
267 
268 
269 
270 
271 //=================================================================================================
272 //
273 // OPERATORS
274 //
275 //=================================================================================================
276 
277 //*************************************************************************************************
287 template< typename MT > // Type of the adapted matrix
289 {
290  if( isRestricted() ) {
291  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
292  }
293 
294  value_ = ulp.value_;
295 
296  return *this;
297 }
298 //*************************************************************************************************
299 
300 
301 //*************************************************************************************************
311 template< typename MT > // Type of the adapted matrix
312 template< typename T > // Type of the right-hand side value
313 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator=( const T& value ) const
314 {
315  if( isRestricted() ) {
316  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
317  }
318 
319  value_ = value;
320 
321  return *this;
322 }
323 //*************************************************************************************************
324 
325 
326 //*************************************************************************************************
336 template< typename MT > // Type of the adapted matrix
337 template< typename T > // Type of the right-hand side value
338 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator+=( const T& value ) const
339 {
340  if( isRestricted() ) {
341  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
342  }
343 
344  value_ += value;
345 
346  return *this;
347 }
348 //*************************************************************************************************
349 
350 
351 //*************************************************************************************************
361 template< typename MT > // Type of the adapted matrix
362 template< typename T > // Type of the right-hand side value
363 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator-=( const T& value ) const
364 {
365  if( isRestricted() ) {
366  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
367  }
368 
369  value_ -= value;
370 
371  return *this;
372 }
373 //*************************************************************************************************
374 
375 
376 //*************************************************************************************************
386 template< typename MT > // Type of the adapted matrix
387 template< typename T > // Type of the right-hand side value
388 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator*=( const T& value ) const
389 {
390  if( isRestricted() ) {
391  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
392  }
393 
394  value_ *= value;
395 
396  return *this;
397 }
398 //*************************************************************************************************
399 
400 
401 //*************************************************************************************************
411 template< typename MT > // Type of the adapted matrix
412 template< typename T > // Type of the right-hand side value
413 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator/=( const T& value ) const
414 {
415  if( isRestricted() ) {
416  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
417  }
418 
419  value_ /= value;
420 
421  return *this;
422 }
423 //*************************************************************************************************
424 
425 
426 //*************************************************************************************************
436 template< typename MT > // Type of the adapted matrix
437 template< typename T > // Type of the right-hand side value
438 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator%=( const T& value ) const
439 {
440  if( isRestricted() ) {
441  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
442  }
443 
444  value_ %= value;
445 
446  return *this;
447 }
448 //*************************************************************************************************
449 
450 
451 
452 
453 //=================================================================================================
454 //
455 // ACCESS OPERATORS
456 //
457 //=================================================================================================
458 
459 //*************************************************************************************************
464 template< typename MT > // Type of the adapted matrix
465 inline const UniLowerProxy<MT>* UniLowerProxy<MT>::operator->() const noexcept
466 {
467  return this;
468 }
469 //*************************************************************************************************
470 
471 
472 
473 
474 //=================================================================================================
475 //
476 // UTILITY FUNCTIONS
477 //
478 //=================================================================================================
479 
480 //*************************************************************************************************
487 template< typename MT > // Type of the adapted matrix
488 inline void UniLowerProxy<MT>::reset() const
489 {
490  using blaze::reset;
491 
492  if( column_ < row_ )
493  reset( value_ );
494 }
495 //*************************************************************************************************
496 
497 
498 //*************************************************************************************************
505 template< typename MT > // Type of the adapted matrix
506 inline void UniLowerProxy<MT>::clear() const
507 {
508  using blaze::clear;
509 
510  if( column_ < row_ )
511  clear( value_ );
512 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
524 template< typename MT > // Type of the adapted matrix
525 inline void UniLowerProxy<MT>::invert() const
526 {
527  using blaze::invert;
528 
529  if( row_ < column_ ) {
530  BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of upper matrix element" );
531  }
532 
533  if( column_ < row_ )
534  invert( value_ );
535 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
544 template< typename MT > // Type of the adapted matrix
546 {
547  return value_;
548 }
549 //*************************************************************************************************
550 
551 
552 //*************************************************************************************************
557 template< typename MT > // Type of the adapted matrix
558 inline bool UniLowerProxy<MT>::isRestricted() const noexcept
559 {
560  return row_ <= column_;
561 }
562 //*************************************************************************************************
563 
564 
565 
566 
567 //=================================================================================================
568 //
569 // CONVERSION OPERATOR
570 //
571 //=================================================================================================
572 
573 //*************************************************************************************************
578 template< typename MT > // Type of the adapted matrix
580 {
581  return get();
582 }
583 //*************************************************************************************************
584 
585 
586 
587 
588 //=================================================================================================
589 //
590 // COMPLEX DATA ACCESS FUNCTIONS
591 //
592 //=================================================================================================
593 
594 //*************************************************************************************************
602 template< typename MT > // Type of the adapted matrix
604 {
605  return value_.real();
606 }
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
621 template< typename MT > // Type of the adapted matrix
622 inline void UniLowerProxy<MT>::real( ValueType value ) const
623 {
624  if( isRestricted() ) {
625  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
626  }
627 
628  value_.real( value );
629 }
630 //*************************************************************************************************
631 
632 
633 //*************************************************************************************************
641 template< typename MT > // Type of the adapted matrix
643 {
644  return value_.imag();
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
660 template< typename MT > // Type of the adapted matrix
661 inline void UniLowerProxy<MT>::imag( ValueType value ) const
662 {
663  if( isRestricted() ) {
664  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
665  }
666 
667  value_.imag( value );
668 }
669 //*************************************************************************************************
670 
671 
672 
673 
674 //=================================================================================================
675 //
676 // GLOBAL FUNCTIONS
677 //
678 //=================================================================================================
679 
680 //*************************************************************************************************
683 template< typename MT >
684 inline void reset( const UniLowerProxy<MT>& proxy );
685 
686 template< typename MT >
687 inline void clear( const UniLowerProxy<MT>& proxy );
688 
689 template< typename MT >
690 inline void invert( const UniLowerProxy<MT>& proxy );
691 
692 template< bool RF, typename MT >
693 inline bool isDefault( const UniLowerProxy<MT>& proxy );
694 
695 template< bool RF, typename MT >
696 inline bool isReal( const UniLowerProxy<MT>& proxy );
697 
698 template< bool RF, typename MT >
699 inline bool isZero( const UniLowerProxy<MT>& proxy );
700 
701 template< bool RF, typename MT >
702 inline bool isOne( const UniLowerProxy<MT>& proxy );
703 
704 template< typename MT >
705 inline bool isnan( const UniLowerProxy<MT>& proxy );
707 //*************************************************************************************************
708 
709 
710 //*************************************************************************************************
720 template< typename MT >
721 inline void reset( const UniLowerProxy<MT>& proxy )
722 {
723  proxy.reset();
724 }
725 //*************************************************************************************************
726 
727 
728 //*************************************************************************************************
738 template< typename MT >
739 inline void clear( const UniLowerProxy<MT>& proxy )
740 {
741  proxy.clear();
742 }
743 //*************************************************************************************************
744 
745 
746 //*************************************************************************************************
753 template< typename MT >
754 inline void invert( const UniLowerProxy<MT>& proxy )
755 {
756  proxy.invert();
757 }
758 //*************************************************************************************************
759 
760 
761 //*************************************************************************************************
771 template< bool RF, typename MT >
772 inline bool isDefault( const UniLowerProxy<MT>& proxy )
773 {
774  using blaze::isDefault;
775 
776  return isDefault<RF>( proxy.get() );
777 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
793 template< bool RF, typename MT >
794 inline bool isReal( const UniLowerProxy<MT>& proxy )
795 {
796  using blaze::isReal;
797 
798  return isReal<RF>( proxy.get() );
799 }
800 //*************************************************************************************************
801 
802 
803 //*************************************************************************************************
813 template< bool RF, typename MT >
814 inline bool isZero( const UniLowerProxy<MT>& proxy )
815 {
816  using blaze::isZero;
817 
818  return isZero<RF>( proxy.get() );
819 }
820 //*************************************************************************************************
821 
822 
823 //*************************************************************************************************
833 template< bool RF, typename MT >
834 inline bool isOne( const UniLowerProxy<MT>& proxy )
835 {
836  using blaze::isOne;
837 
838  return isOne<RF>( proxy.get() );
839 }
840 //*************************************************************************************************
841 
842 
843 //*************************************************************************************************
853 template< typename MT >
854 inline bool isnan( const UniLowerProxy<MT>& proxy )
855 {
856  using blaze::isnan;
857 
858  return isnan( proxy.get() );
859 }
860 //*************************************************************************************************
861 
862 } // namespace blaze
863 
864 #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 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
Constraint on the data type.
const UniLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: UniLowerProxy.h:465
Header file for basic type definitions.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: UniLowerProxy.h:558
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:206
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 invert shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerProxy.h:138
Constraint on the data type.
typename If_< IsComplex< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type ValueType
Value type of the represented complex element.
Definition: UniLowerProxy.h:136
Header file for the Proxy class.
const UniLowerProxy & operator=(const UniLowerProxy &ulp) const
Copy assignment operator for UniLowerProxy.
Definition: UniLowerProxy.h:288
Constraint on the data type.
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerProxy.h:603
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:772
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
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.
Header file for the isZero shim.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerProxy.h:642
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
void invert() const
In-place inversion of the represented element.
Definition: UniLowerProxy.h:525
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:545
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Utility type for generic codes.
Constraint on the data type.
Constraint on the data type.
typename If< T1, T2, T3 >::Type If_
Auxiliary alias declaration for the If class template.The If_ alias declaration provides a convenient...
Definition: If.h:154
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
#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
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
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerProxy.h:131
#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.
size_t row_
Row index of the accessed matrix element.
Definition: UniLowerProxy.h:207
UniLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an UniLowerProxy.
Definition: UniLowerProxy.h:247
void reset() const
Reset the represented element to its default initial value.
Definition: UniLowerProxy.h:488
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
size_t column_
Column index of the accessed matrix element.
Definition: UniLowerProxy.h:208
#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 IsComplex type trait.
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
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
#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
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
Access proxy for lower unitriangular matrices.The UniLowerProxy provides controlled access to the ele...
Definition: UniLowerProxy.h:101
Header file for the isReal shim.
void clear() const
Clearing the represented element.
Definition: UniLowerProxy.h:506