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  //**Utility functions***************************************************************************
169  inline void reset () const;
170  inline void clear () const;
171  inline void invert() const;
172 
173  inline RepresentedType get() const noexcept;
174  inline bool isRestricted() const noexcept;
176  //**********************************************************************************************
177 
178  //**Conversion operator*************************************************************************
181  inline operator RepresentedType() const noexcept;
183  //**********************************************************************************************
184 
185  //**Complex data access functions***************************************************************
188  inline ValueType real() const;
189  inline void real( ValueType value ) const;
190  inline ValueType imag() const;
191  inline void imag( ValueType value ) const;
193  //**********************************************************************************************
194 
195  private:
196  //**Member variables****************************************************************************
200  size_t row_;
201  size_t column_;
202 
203  //**********************************************************************************************
204 
205  //**Compile time checks*************************************************************************
219  //**********************************************************************************************
220 };
221 //*************************************************************************************************
222 
223 
224 
225 
226 //=================================================================================================
227 //
228 // CONSTRUCTORS
229 //
230 //=================================================================================================
231 
232 //*************************************************************************************************
239 template< typename MT > // Type of the adapted matrix
240 inline UniLowerProxy<MT>::UniLowerProxy( MT& matrix, size_t row, size_t column )
241  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
242  , row_ ( row ) // Row index of the accessed matrix element
243  , column_( column ) // Column index of the accessed matrix element
244 {}
245 //*************************************************************************************************
246 
247 
248 //*************************************************************************************************
253 template< typename MT > // Type of the adapted matrix
255  : value_ ( ulp.value_ ) // Reference to the accessed matrix element
256  , row_ ( ulp.row_ ) // Row index of the accessed matrix element
257  , column_( ulp.column_ ) // Column index of the accessed matrix element
258 {}
259 //*************************************************************************************************
260 
261 
262 
263 
264 //=================================================================================================
265 //
266 // OPERATORS
267 //
268 //=================================================================================================
269 
270 //*************************************************************************************************
280 template< typename MT > // Type of the adapted matrix
282 {
283  if( isRestricted() ) {
284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
285  }
286 
287  value_ = ulp.value_;
288 
289  return *this;
290 }
291 //*************************************************************************************************
292 
293 
294 //*************************************************************************************************
304 template< typename MT > // Type of the adapted matrix
305 template< typename T > // Type of the right-hand side value
306 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator=( const T& value ) const
307 {
308  if( isRestricted() ) {
309  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
310  }
311 
312  value_ = value;
313 
314  return *this;
315 }
316 //*************************************************************************************************
317 
318 
319 //*************************************************************************************************
329 template< typename MT > // Type of the adapted matrix
330 template< typename T > // Type of the right-hand side value
331 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator+=( const T& value ) const
332 {
333  if( isRestricted() ) {
334  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
335  }
336 
337  value_ += value;
338 
339  return *this;
340 }
341 //*************************************************************************************************
342 
343 
344 //*************************************************************************************************
354 template< typename MT > // Type of the adapted matrix
355 template< typename T > // Type of the right-hand side value
356 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator-=( const T& value ) const
357 {
358  if( isRestricted() ) {
359  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
360  }
361 
362  value_ -= value;
363 
364  return *this;
365 }
366 //*************************************************************************************************
367 
368 
369 //*************************************************************************************************
379 template< typename MT > // Type of the adapted matrix
380 template< typename T > // Type of the right-hand side value
381 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator*=( const T& value ) const
382 {
383  if( isRestricted() ) {
384  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
385  }
386 
387  value_ *= value;
388 
389  return *this;
390 }
391 //*************************************************************************************************
392 
393 
394 //*************************************************************************************************
404 template< typename MT > // Type of the adapted matrix
405 template< typename T > // Type of the right-hand side value
406 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator/=( const T& value ) const
407 {
408  if( isRestricted() ) {
409  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
410  }
411 
412  value_ /= value;
413 
414  return *this;
415 }
416 //*************************************************************************************************
417 
418 
419 //*************************************************************************************************
429 template< typename MT > // Type of the adapted matrix
430 template< typename T > // Type of the right-hand side value
431 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator%=( const T& value ) const
432 {
433  if( isRestricted() ) {
434  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
435  }
436 
437  value_ %= value;
438 
439  return *this;
440 }
441 //*************************************************************************************************
442 
443 
444 
445 
446 //=================================================================================================
447 //
448 // UTILITY FUNCTIONS
449 //
450 //=================================================================================================
451 
452 //*************************************************************************************************
459 template< typename MT > // Type of the adapted matrix
460 inline void UniLowerProxy<MT>::reset() const
461 {
462  using blaze::reset;
463 
464  if( column_ < row_ )
465  reset( value_ );
466 }
467 //*************************************************************************************************
468 
469 
470 //*************************************************************************************************
477 template< typename MT > // Type of the adapted matrix
478 inline void UniLowerProxy<MT>::clear() const
479 {
480  using blaze::clear;
481 
482  if( column_ < row_ )
483  clear( value_ );
484 }
485 //*************************************************************************************************
486 
487 
488 //*************************************************************************************************
496 template< typename MT > // Type of the adapted matrix
497 inline void UniLowerProxy<MT>::invert() const
498 {
499  using blaze::invert;
500 
501  if( row_ < column_ ) {
502  BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of upper matrix element" );
503  }
504 
505  if( column_ < row_ )
506  invert( value_ );
507 }
508 //*************************************************************************************************
509 
510 
511 //*************************************************************************************************
516 template< typename MT > // Type of the adapted matrix
518 {
519  return value_;
520 }
521 //*************************************************************************************************
522 
523 
524 //*************************************************************************************************
529 template< typename MT > // Type of the adapted matrix
530 inline bool UniLowerProxy<MT>::isRestricted() const noexcept
531 {
532  return row_ <= column_;
533 }
534 //*************************************************************************************************
535 
536 
537 
538 
539 //=================================================================================================
540 //
541 // CONVERSION OPERATOR
542 //
543 //=================================================================================================
544 
545 //*************************************************************************************************
550 template< typename MT > // Type of the adapted matrix
552 {
553  return get();
554 }
555 //*************************************************************************************************
556 
557 
558 
559 
560 //=================================================================================================
561 //
562 // COMPLEX DATA ACCESS FUNCTIONS
563 //
564 //=================================================================================================
565 
566 //*************************************************************************************************
574 template< typename MT > // Type of the adapted matrix
576 {
577  return value_.real();
578 }
579 //*************************************************************************************************
580 
581 
582 //*************************************************************************************************
593 template< typename MT > // Type of the adapted matrix
594 inline void UniLowerProxy<MT>::real( ValueType value ) const
595 {
596  if( isRestricted() ) {
597  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
598  }
599 
600  value_.real( value );
601 }
602 //*************************************************************************************************
603 
604 
605 //*************************************************************************************************
613 template< typename MT > // Type of the adapted matrix
615 {
616  return value_.imag();
617 }
618 //*************************************************************************************************
619 
620 
621 //*************************************************************************************************
632 template< typename MT > // Type of the adapted matrix
633 inline void UniLowerProxy<MT>::imag( ValueType value ) const
634 {
635  if( isRestricted() ) {
636  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
637  }
638 
639  value_.imag( value );
640 }
641 //*************************************************************************************************
642 
643 
644 
645 
646 //=================================================================================================
647 //
648 // GLOBAL FUNCTIONS
649 //
650 //=================================================================================================
651 
652 //*************************************************************************************************
655 template< typename MT >
656 inline void reset( const UniLowerProxy<MT>& proxy );
657 
658 template< typename MT >
659 inline void clear( const UniLowerProxy<MT>& proxy );
660 
661 template< typename MT >
662 inline void invert( const UniLowerProxy<MT>& proxy );
663 
664 template< bool RF, typename MT >
665 inline bool isDefault( const UniLowerProxy<MT>& proxy );
666 
667 template< bool RF, typename MT >
668 inline bool isReal( const UniLowerProxy<MT>& proxy );
669 
670 template< bool RF, typename MT >
671 inline bool isZero( const UniLowerProxy<MT>& proxy );
672 
673 template< bool RF, typename MT >
674 inline bool isOne( const UniLowerProxy<MT>& proxy );
675 
676 template< typename MT >
677 inline bool isnan( const UniLowerProxy<MT>& proxy );
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
692 template< typename MT >
693 inline void reset( const UniLowerProxy<MT>& proxy )
694 {
695  proxy.reset();
696 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
710 template< typename MT >
711 inline void clear( const UniLowerProxy<MT>& proxy )
712 {
713  proxy.clear();
714 }
715 //*************************************************************************************************
716 
717 
718 //*************************************************************************************************
725 template< typename MT >
726 inline void invert( const UniLowerProxy<MT>& proxy )
727 {
728  proxy.invert();
729 }
730 //*************************************************************************************************
731 
732 
733 //*************************************************************************************************
743 template< bool RF, typename MT >
744 inline bool isDefault( const UniLowerProxy<MT>& proxy )
745 {
746  using blaze::isDefault;
747 
748  return isDefault<RF>( proxy.get() );
749 }
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
765 template< bool RF, typename MT >
766 inline bool isReal( const UniLowerProxy<MT>& proxy )
767 {
768  using blaze::isReal;
769 
770  return isReal<RF>( proxy.get() );
771 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
785 template< bool RF, typename MT >
786 inline bool isZero( const UniLowerProxy<MT>& proxy )
787 {
788  using blaze::isZero;
789 
790  return isZero<RF>( proxy.get() );
791 }
792 //*************************************************************************************************
793 
794 
795 //*************************************************************************************************
805 template< bool RF, typename MT >
806 inline bool isOne( const UniLowerProxy<MT>& proxy )
807 {
808  using blaze::isOne;
809 
810  return isOne<RF>( proxy.get() );
811 }
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
825 template< typename MT >
826 inline bool isnan( const UniLowerProxy<MT>& proxy )
827 {
828  using blaze::isnan;
829 
830  return isnan( proxy.get() );
831 }
832 //*************************************************************************************************
833 
834 } // namespace blaze
835 
836 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:622
Header file for the isnan shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Constraint on the data type.
Header file for basic type definitions.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: UniLowerProxy.h:530
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:199
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
Header file for the invert shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerProxy.h:138
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
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:281
Constraint on the data type.
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerProxy.h:575
Constraint on the data type.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:642
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:3084
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
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:614
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Constraint on the data type.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:682
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
void invert() const
In-place inversion of the represented element.
Definition: UniLowerProxy.h:497
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:517
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
#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:662
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:200
UniLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an UniLowerProxy.
Definition: UniLowerProxy.h:240
void reset() const
Reset the represented element to its default initial value.
Definition: UniLowerProxy.h:460
size_t column_
Column index of the accessed matrix element.
Definition: UniLowerProxy.h:201
#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:600
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
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
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:478