Blaze  3.6
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>
52 #include <blaze/math/Exception.h>
53 #include <blaze/math/proxy/Proxy.h>
54 #include <blaze/math/shims/Clear.h>
57 #include <blaze/math/shims/IsNaN.h>
58 #include <blaze/math/shims/IsOne.h>
61 #include <blaze/math/shims/Reset.h>
67 #include <blaze/util/InvalidType.h>
68 #include <blaze/util/mpl/If.h>
69 #include <blaze/util/Types.h>
71 
72 
73 namespace blaze {
74 
75 //=================================================================================================
76 //
77 // CLASS DEFINITION
78 //
79 //=================================================================================================
80 
81 //*************************************************************************************************
102 template< typename MT > // Type of the adapted matrix
104  : public Proxy< UniLowerProxy<MT> >
105 {
106  private:
107  //**Type definitions****************************************************************************
109  using ReferenceType = typename MT::Reference;
110  //**********************************************************************************************
111 
112  //**struct BuiltinType**************************************************************************
116  template< typename T >
117  struct BuiltinType { using Type = INVALID_TYPE; };
119  //**********************************************************************************************
120 
121  //**struct ComplexType**************************************************************************
125  template< typename T >
126  struct ComplexType { using Type = typename T::value_type; };
128  //**********************************************************************************************
129 
130  public:
131  //**Type definitions****************************************************************************
134 
137  , ComplexType<RepresentedType>
138  , BuiltinType<RepresentedType> >::Type;
139 
141  //**********************************************************************************************
142 
143  //**Constructors********************************************************************************
146  explicit inline UniLowerProxy( MT& matrix, size_t row, size_t column );
147  inline UniLowerProxy( const UniLowerProxy& ulp );
149  //**********************************************************************************************
150 
151  //**Destructor**********************************************************************************
154  ~UniLowerProxy() = default;
156  //**********************************************************************************************
157 
158  //**Assignment operators************************************************************************
161  inline const UniLowerProxy& operator= ( const UniLowerProxy& ulp ) 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;
166  template< typename T > inline const UniLowerProxy& operator/=( const T& value ) const;
167  template< typename T > inline const UniLowerProxy& operator%=( const T& value ) const;
169  //**********************************************************************************************
170 
171  //**Access operators****************************************************************************
174  inline const UniLowerProxy* operator->() const noexcept;
176  //**********************************************************************************************
177 
178  //**Utility functions***************************************************************************
181  inline void reset () const;
182  inline void clear () const;
183  inline void invert() const;
184 
185  inline RepresentedType get() const noexcept;
186  inline bool isRestricted() const noexcept;
188  //**********************************************************************************************
189 
190  //**Conversion operator*************************************************************************
193  inline operator RepresentedType() const noexcept;
195  //**********************************************************************************************
196 
197  //**Complex data access functions***************************************************************
200  inline ValueType real() const;
201  inline void real( ValueType value ) const;
202  inline ValueType imag() const;
203  inline void imag( ValueType value ) const;
205  //**********************************************************************************************
206 
207  private:
208  //**Member variables****************************************************************************
212  size_t row_;
213  size_t column_;
214 
215  //**********************************************************************************************
216 
217  //**Compile time checks*************************************************************************
233  //**********************************************************************************************
234 };
235 //*************************************************************************************************
236 
237 
238 
239 
240 //=================================================================================================
241 //
242 // CONSTRUCTORS
243 //
244 //=================================================================================================
245 
246 //*************************************************************************************************
253 template< typename MT > // Type of the adapted matrix
254 inline UniLowerProxy<MT>::UniLowerProxy( MT& matrix, size_t row, size_t column )
255  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
256  , row_ ( row ) // Row index of the accessed matrix element
257  , column_( column ) // Column index of the accessed matrix element
258 {}
259 //*************************************************************************************************
260 
261 
262 //*************************************************************************************************
267 template< typename MT > // Type of the adapted matrix
269  : value_ ( ulp.value_ ) // Reference to the accessed matrix element
270  , row_ ( ulp.row_ ) // Row index of the accessed matrix element
271  , column_( ulp.column_ ) // Column index of the accessed matrix element
272 {}
273 //*************************************************************************************************
274 
275 
276 
277 
278 //=================================================================================================
279 //
280 // OPERATORS
281 //
282 //=================================================================================================
283 
284 //*************************************************************************************************
294 template< typename MT > // Type of the adapted matrix
296 {
297  if( isRestricted() ) {
298  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
299  }
300 
301  value_ = ulp.value_;
302 
303  return *this;
304 }
305 //*************************************************************************************************
306 
307 
308 //*************************************************************************************************
318 template< typename MT > // Type of the adapted matrix
319 template< typename T > // Type of the right-hand side value
320 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator=( const T& value ) const
321 {
322  if( isRestricted() ) {
323  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
324  }
325 
326  value_ = value;
327 
328  return *this;
329 }
330 //*************************************************************************************************
331 
332 
333 //*************************************************************************************************
343 template< typename MT > // Type of the adapted matrix
344 template< typename T > // Type of the right-hand side value
345 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator+=( const T& value ) const
346 {
347  if( isRestricted() ) {
348  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
349  }
350 
351  value_ += value;
352 
353  return *this;
354 }
355 //*************************************************************************************************
356 
357 
358 //*************************************************************************************************
368 template< typename MT > // Type of the adapted matrix
369 template< typename T > // Type of the right-hand side value
370 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator-=( const T& value ) const
371 {
372  if( isRestricted() ) {
373  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
374  }
375 
376  value_ -= value;
377 
378  return *this;
379 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
393 template< typename MT > // Type of the adapted matrix
394 template< typename T > // Type of the right-hand side value
395 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator*=( const T& value ) const
396 {
397  if( isRestricted() ) {
398  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
399  }
400 
401  value_ *= value;
402 
403  return *this;
404 }
405 //*************************************************************************************************
406 
407 
408 //*************************************************************************************************
418 template< typename MT > // Type of the adapted matrix
419 template< typename T > // Type of the right-hand side value
420 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator/=( const T& value ) const
421 {
422  if( isRestricted() ) {
423  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
424  }
425 
426  value_ /= value;
427 
428  return *this;
429 }
430 //*************************************************************************************************
431 
432 
433 //*************************************************************************************************
443 template< typename MT > // Type of the adapted matrix
444 template< typename T > // Type of the right-hand side value
445 inline const UniLowerProxy<MT>& UniLowerProxy<MT>::operator%=( const T& value ) const
446 {
447  if( isRestricted() ) {
448  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
449  }
450 
451  value_ %= value;
452 
453  return *this;
454 }
455 //*************************************************************************************************
456 
457 
458 
459 
460 //=================================================================================================
461 //
462 // ACCESS OPERATORS
463 //
464 //=================================================================================================
465 
466 //*************************************************************************************************
471 template< typename MT > // Type of the adapted matrix
472 inline const UniLowerProxy<MT>* UniLowerProxy<MT>::operator->() const noexcept
473 {
474  return this;
475 }
476 //*************************************************************************************************
477 
478 
479 
480 
481 //=================================================================================================
482 //
483 // UTILITY FUNCTIONS
484 //
485 //=================================================================================================
486 
487 //*************************************************************************************************
494 template< typename MT > // Type of the adapted matrix
495 inline void UniLowerProxy<MT>::reset() const
496 {
497  using blaze::reset;
498 
499  if( column_ < row_ )
500  reset( value_ );
501 }
502 //*************************************************************************************************
503 
504 
505 //*************************************************************************************************
512 template< typename MT > // Type of the adapted matrix
513 inline void UniLowerProxy<MT>::clear() const
514 {
515  using blaze::clear;
516 
517  if( column_ < row_ )
518  clear( value_ );
519 }
520 //*************************************************************************************************
521 
522 
523 //*************************************************************************************************
531 template< typename MT > // Type of the adapted matrix
532 inline void UniLowerProxy<MT>::invert() const
533 {
534  using blaze::invert;
535 
536  if( row_ < column_ ) {
537  BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of upper matrix element" );
538  }
539 
540  if( column_ < row_ )
541  invert( value_ );
542 }
543 //*************************************************************************************************
544 
545 
546 //*************************************************************************************************
551 template< typename MT > // Type of the adapted matrix
553 {
554  return value_;
555 }
556 //*************************************************************************************************
557 
558 
559 //*************************************************************************************************
564 template< typename MT > // Type of the adapted matrix
565 inline bool UniLowerProxy<MT>::isRestricted() const noexcept
566 {
567  return row_ <= column_;
568 }
569 //*************************************************************************************************
570 
571 
572 
573 
574 //=================================================================================================
575 //
576 // CONVERSION OPERATOR
577 //
578 //=================================================================================================
579 
580 //*************************************************************************************************
585 template< typename MT > // Type of the adapted matrix
587 {
588  return get();
589 }
590 //*************************************************************************************************
591 
592 
593 
594 
595 //=================================================================================================
596 //
597 // COMPLEX DATA ACCESS FUNCTIONS
598 //
599 //=================================================================================================
600 
601 //*************************************************************************************************
609 template< typename MT > // Type of the adapted matrix
611 {
612  return value_.real();
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
628 template< typename MT > // Type of the adapted matrix
629 inline void UniLowerProxy<MT>::real( ValueType value ) const
630 {
631  if( isRestricted() ) {
632  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
633  }
634 
635  value_.real( value );
636 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
648 template< typename MT > // Type of the adapted matrix
650 {
651  return value_.imag();
652 }
653 //*************************************************************************************************
654 
655 
656 //*************************************************************************************************
667 template< typename MT > // Type of the adapted matrix
668 inline void UniLowerProxy<MT>::imag( ValueType value ) const
669 {
670  if( isRestricted() ) {
671  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or upper matrix element" );
672  }
673 
674  value_.imag( value );
675 }
676 //*************************************************************************************************
677 
678 
679 
680 
681 //=================================================================================================
682 //
683 // GLOBAL FUNCTIONS
684 //
685 //=================================================================================================
686 
687 //*************************************************************************************************
690 template< typename MT >
691 void reset( const UniLowerProxy<MT>& proxy );
692 
693 template< typename MT >
694 void clear( const UniLowerProxy<MT>& proxy );
695 
696 template< typename MT >
697 void invert( const UniLowerProxy<MT>& proxy );
698 
699 template< bool RF, typename MT >
700 bool isDefault( const UniLowerProxy<MT>& proxy );
701 
702 template< bool RF, typename MT >
703 bool isReal( const UniLowerProxy<MT>& proxy );
704 
705 template< bool RF, typename MT >
706 bool isZero( const UniLowerProxy<MT>& proxy );
707 
708 template< bool RF, typename MT >
709 bool isOne( const UniLowerProxy<MT>& proxy );
710 
711 template< typename MT >
712 bool isnan( const UniLowerProxy<MT>& proxy );
714 //*************************************************************************************************
715 
716 
717 //*************************************************************************************************
727 template< typename MT >
728 inline void reset( const UniLowerProxy<MT>& proxy )
729 {
730  proxy.reset();
731 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
745 template< typename MT >
746 inline void clear( const UniLowerProxy<MT>& proxy )
747 {
748  proxy.clear();
749 }
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
760 template< typename MT >
761 inline void invert( const UniLowerProxy<MT>& proxy )
762 {
763  proxy.invert();
764 }
765 //*************************************************************************************************
766 
767 
768 //*************************************************************************************************
778 template< bool RF, typename MT >
779 inline bool isDefault( const UniLowerProxy<MT>& proxy )
780 {
781  using blaze::isDefault;
782 
783  return isDefault<RF>( proxy.get() );
784 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
800 template< bool RF, typename MT >
801 inline bool isReal( const UniLowerProxy<MT>& proxy )
802 {
803  using blaze::isReal;
804 
805  return isReal<RF>( proxy.get() );
806 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
820 template< bool RF, typename MT >
821 inline bool isZero( const UniLowerProxy<MT>& proxy )
822 {
823  using blaze::isZero;
824 
825  return isZero<RF>( proxy.get() );
826 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
840 template< bool RF, typename MT >
841 inline bool isOne( const UniLowerProxy<MT>& proxy )
842 {
843  using blaze::isOne;
844 
845  return isOne<RF>( proxy.get() );
846 }
847 //*************************************************************************************************
848 
849 
850 //*************************************************************************************************
860 template< typename MT >
861 inline bool isnan( const UniLowerProxy<MT>& proxy )
862 {
863  using blaze::isnan;
864 
865  return isnan( proxy.get() );
866 }
867 //*************************************************************************************************
868 
869 } // namespace blaze
870 
871 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:657
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
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,...
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
Constraint on the data type.
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.
Constraint on the data type.
const UniLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: UniLowerProxy.h:472
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:138
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: UniLowerProxy.h:565
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
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:211
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
Header file for the invert shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerProxy.h:140
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:295
Constraint on the data type.
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerProxy.h:610
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:779
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:109
#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:649
Constraint on the data type.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:717
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:615
void invert() const
In-place inversion of the represented element.
Definition: UniLowerProxy.h:532
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,...
Definition: Symmetric.h:79
RepresentedType get() const noexcept
Returning the value of the accessed matrix element.
Definition: UniLowerProxy.h:552
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,...
Definition: Reference.h:79
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:697
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:212
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
UniLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an UniLowerProxy.
Definition: UniLowerProxy.h:254
void reset() const
Reset the represented element to its default initial value.
Definition: UniLowerProxy.h:495
size_t column_
Column index of the accessed matrix element.
Definition: UniLowerProxy.h:213
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerProxy.h:133
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:635
#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,...
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:103
Constraint on the data type.
Header file for the isReal shim.
Header file for the clear shim.
void clear() const
Clearing the represented element.
Definition: UniLowerProxy.h:513
constexpr Type & get(StaticVector< Type, N, TF > &v) noexcept
Tuple-like index-based access the contents of a static vector.
Definition: StaticVector.h:2704