Blaze  3.6
StrictlyLowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_STRICTLYLOWERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
52 #include <blaze/math/Exception.h>
54 #include <blaze/math/proxy/Proxy.h>
55 #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>
68 #include <blaze/util/Types.h>
69 
70 
71 namespace blaze {
72 
73 //=================================================================================================
74 //
75 // CLASS DEFINITION
76 //
77 //=================================================================================================
78 
79 //*************************************************************************************************
101 template< typename MT > // Type of the adapted matrix
103  : public Proxy< StrictlyLowerProxy<MT>, ElementType_t<MT> >
104 {
105  private:
106  //**Type definitions****************************************************************************
109  //**********************************************************************************************
110 
111  public:
112  //**Type definitions****************************************************************************
116  //**********************************************************************************************
117 
118  //**Constructors********************************************************************************
121  explicit inline StrictlyLowerProxy( MT& matrix, size_t row, size_t column );
122  inline StrictlyLowerProxy( const StrictlyLowerProxy& ulp );
124  //**********************************************************************************************
125 
126  //**Destructor**********************************************************************************
129  ~StrictlyLowerProxy() = default;
131  //**********************************************************************************************
132 
133  //**Assignment operators************************************************************************
136  inline const StrictlyLowerProxy& operator=( const StrictlyLowerProxy& ulp ) const;
137 
138  template< typename T >
139  inline const StrictlyLowerProxy& operator=( initializer_list<T> list ) const;
140 
141  template< typename T >
142  inline const StrictlyLowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
143 
144  template< typename T > inline const StrictlyLowerProxy& operator= ( const T& value ) const;
145  template< typename T > inline const StrictlyLowerProxy& operator+=( const T& value ) const;
146  template< typename T > inline const StrictlyLowerProxy& operator-=( const T& value ) const;
147  template< typename T > inline const StrictlyLowerProxy& operator*=( const T& value ) const;
148  template< typename T > inline const StrictlyLowerProxy& operator/=( const T& value ) const;
149  template< typename T > inline const StrictlyLowerProxy& operator%=( const T& value ) const;
151  //**********************************************************************************************
152 
153  //**Access operators****************************************************************************
156  inline const StrictlyLowerProxy* operator->() const noexcept;
158  //**********************************************************************************************
159 
160  //**Utility functions***************************************************************************
163  inline RawReference get() const noexcept;
164  inline bool isRestricted() const noexcept;
166  //**********************************************************************************************
167 
168  //**Conversion operator*************************************************************************
171  inline operator ConstReference() const noexcept;
173  //**********************************************************************************************
174 
175  private:
176  //**Member variables****************************************************************************
180  const bool restricted_;
181 
185  //**********************************************************************************************
186 
187  //**Compile time checks*************************************************************************
202  //**********************************************************************************************
203 };
204 //*************************************************************************************************
205 
206 
207 
208 
209 //=================================================================================================
210 //
211 // CONSTRUCTORS
212 //
213 //=================================================================================================
214 
215 //*************************************************************************************************
222 template< typename MT > // Type of the adapted matrix
223 inline StrictlyLowerProxy<MT>::StrictlyLowerProxy( MT& matrix, size_t row, size_t column )
224  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
225  , restricted_( row <= column ) // Access flag for the accessed matrix element
226 {}
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
235 template< typename MT > // Type of the adapted matrix
237  : value_ ( slp.value_ ) // Reference to the accessed matrix element
238  , restricted_( slp.restricted_ ) // Access flag for the accessed matrix element
239 {}
240 //*************************************************************************************************
241 
242 
243 
244 
245 //=================================================================================================
246 //
247 // OPERATORS
248 //
249 //=================================================================================================
250 
251 //*************************************************************************************************
261 template< typename MT > // Type of the adapted matrix
262 inline const StrictlyLowerProxy<MT>&
264 {
265  if( restricted_ ) {
266  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
267  }
268 
269  value_ = slp.value_;
270 
271  return *this;
272 }
273 //*************************************************************************************************
274 
275 
276 //*************************************************************************************************
286 template< typename MT > // Type of the adapted matrix
287 template< typename T > // Type of the right-hand side value
288 inline const StrictlyLowerProxy<MT>&
290 {
291  if( restricted_ ) {
292  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
293  }
294 
295  value_ = list;
296 
297  return *this;
298 }
299 //*************************************************************************************************
300 
301 
302 //*************************************************************************************************
312 template< typename MT > // Type of the adapted matrix
313 template< typename T > // Type of the right-hand side value
314 inline const StrictlyLowerProxy<MT>&
316 {
317  if( restricted_ ) {
318  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
319  }
320 
321  value_ = list;
322 
323  return *this;
324 }
325 //*************************************************************************************************
326 
327 
328 //*************************************************************************************************
338 template< typename MT > // Type of the adapted matrix
339 template< typename T > // Type of the right-hand side value
340 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator=( const T& value ) const
341 {
342  if( restricted_ ) {
343  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
344  }
345 
346  value_ = value;
347 
348  return *this;
349 }
350 //*************************************************************************************************
351 
352 
353 //*************************************************************************************************
363 template< typename MT > // Type of the adapted matrix
364 template< typename T > // Type of the right-hand side value
365 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator+=( const T& value ) const
366 {
367  if( restricted_ ) {
368  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
369  }
370 
371  value_ += value;
372 
373  return *this;
374 }
375 //*************************************************************************************************
376 
377 
378 //*************************************************************************************************
388 template< typename MT > // Type of the adapted matrix
389 template< typename T > // Type of the right-hand side value
390 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator-=( const T& value ) const
391 {
392  if( restricted_ ) {
393  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
394  }
395 
396  value_ -= value;
397 
398  return *this;
399 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
413 template< typename MT > // Type of the adapted matrix
414 template< typename T > // Type of the right-hand side value
415 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator*=( const T& value ) const
416 {
417  if( restricted_ ) {
418  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
419  }
420 
421  value_ *= value;
422 
423  return *this;
424 }
425 //*************************************************************************************************
426 
427 
428 //*************************************************************************************************
438 template< typename MT > // Type of the adapted matrix
439 template< typename T > // Type of the right-hand side value
440 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator/=( const T& value ) const
441 {
442  if( restricted_ ) {
443  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
444  }
445 
446  value_ /= value;
447 
448  return *this;
449 }
450 //*************************************************************************************************
451 
452 
453 //*************************************************************************************************
463 template< typename MT > // Type of the adapted matrix
464 template< typename T > // Type of the right-hand side value
465 inline const StrictlyLowerProxy<MT>& StrictlyLowerProxy<MT>::operator%=( const T& value ) const
466 {
467  if( restricted_ ) {
468  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or upper matrix element" );
469  }
470 
471  value_ %= value;
472 
473  return *this;
474 }
475 //*************************************************************************************************
476 
477 
478 
479 
480 //=================================================================================================
481 //
482 // ACCESS OPERATORS
483 //
484 //=================================================================================================
485 
486 //*************************************************************************************************
491 template< typename MT > // Type of the adapted matrix
493 {
494  return this;
495 }
496 //*************************************************************************************************
497 
498 
499 
500 
501 //=================================================================================================
502 //
503 // UTILITY FUNCTIONS
504 //
505 //=================================================================================================
506 
507 //*************************************************************************************************
512 template< typename MT > // Type of the adapted matrix
514 {
515  return value_;
516 }
517 //*************************************************************************************************
518 
519 
520 //*************************************************************************************************
525 template< typename MT > // Type of the adapted matrix
526 inline bool StrictlyLowerProxy<MT>::isRestricted() const noexcept
527 {
528  return restricted_;
529 }
530 //*************************************************************************************************
531 
532 
533 
534 
535 //=================================================================================================
536 //
537 // CONVERSION OPERATOR
538 //
539 //=================================================================================================
540 
541 //*************************************************************************************************
546 template< typename MT > // Type of the adapted matrix
548 {
549  return static_cast<ConstReference>( value_ );
550 }
551 //*************************************************************************************************
552 
553 
554 
555 
556 //=================================================================================================
557 //
558 // GLOBAL FUNCTIONS
559 //
560 //=================================================================================================
561 
562 //*************************************************************************************************
565 template< typename MT >
566 void reset( const StrictlyLowerProxy<MT>& proxy );
567 
568 template< typename MT >
569 void clear( const StrictlyLowerProxy<MT>& proxy );
570 
571 template< bool RF, typename MT >
572 bool isDefault( const StrictlyLowerProxy<MT>& proxy );
573 
574 template< bool RF, typename MT >
575 bool isReal( const StrictlyLowerProxy<MT>& proxy );
576 
577 template< bool RF, typename MT >
578 bool isZero( const StrictlyLowerProxy<MT>& proxy );
579 
580 template< bool RF, typename MT >
581 bool isOne( const StrictlyLowerProxy<MT>& proxy );
582 
583 template< typename MT >
584 bool isnan( const StrictlyLowerProxy<MT>& proxy );
586 //*************************************************************************************************
587 
588 
589 //*************************************************************************************************
599 template< typename MT >
600 inline void reset( const StrictlyLowerProxy<MT>& proxy )
601 {
602  using blaze::reset;
603 
604  reset( proxy.get() );
605 }
606 //*************************************************************************************************
607 
608 
609 //*************************************************************************************************
619 template< typename MT >
620 inline void clear( const StrictlyLowerProxy<MT>& proxy )
621 {
622  using blaze::clear;
623 
624  clear( proxy.get() );
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
639 template< bool RF, typename MT >
640 inline bool isDefault( const StrictlyLowerProxy<MT>& proxy )
641 {
642  using blaze::isDefault;
643 
644  return isDefault<RF>( proxy.get() );
645 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
661 template< bool RF, typename MT >
662 inline bool isReal( const StrictlyLowerProxy<MT>& proxy )
663 {
664  using blaze::isReal;
665 
666  return isReal<RF>( proxy.get() );
667 }
668 //*************************************************************************************************
669 
670 
671 //*************************************************************************************************
681 template< bool RF, typename MT >
682 inline bool isZero( const StrictlyLowerProxy<MT>& proxy )
683 {
684  using blaze::isZero;
685 
686  return isZero<RF>( proxy.get() );
687 }
688 //*************************************************************************************************
689 
690 
691 //*************************************************************************************************
701 template< bool RF, typename MT >
702 inline bool isOne( const StrictlyLowerProxy<MT>& proxy )
703 {
704  using blaze::isOne;
705 
706  return isOne<RF>( proxy.get() );
707 }
708 //*************************************************************************************************
709 
710 
711 //*************************************************************************************************
721 template< typename MT >
722 inline bool isnan( const StrictlyLowerProxy<MT>& proxy )
723 {
724  using blaze::isnan;
725 
726  return isnan( proxy.get() );
727 }
728 //*************************************************************************************************
729 
730 } // namespace blaze
731 
732 #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 the AddConst type trait.
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Constraint on the data type.
Header file for basic type definitions.
Proxy base class.The Proxy class is a base class for all proxy classes within the Blaze library that ...
Definition: Forward.h:51
Header file for the isZero shim.
#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
const StrictlyLowerProxy & operator=(const StrictlyLowerProxy &ulp) const
Copy assignment operator for StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:263
AddReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyLowerProxy.h:114
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 reset shim.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the Proxy class.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
Constraint on the data type.
Constraint on the data type.
typename AddReference< T >::Type AddReference_t
Auxiliary alias declaration for the AddReference type trait.The AddReference_t alias declaration prov...
Definition: AddReference.h:95
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyLowerProxy.h:513
const StrictlyLowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyLowerProxy.h:492
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyLowerProxy.h:115
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Constraint on the data type.
Access proxy for strictly lower triangular matrices.The StrictlyLowerProxy provides controlled access...
Definition: StrictlyLowerProxy.h:102
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyLowerProxy.h:180
Constraint on the data type.
typename AddConst< T >::Type AddConst_t
Auxiliary alias declaration for the AddConst type trait.The AddConst_t alias declaration provides a c...
Definition: AddConst.h:95
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h: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
Header file for the isOne shim.
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyLowerProxy.h:526
#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
Constraint on the data type.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type,...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type,...
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.
#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
AddConst_t< Reference_t< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyLowerProxy.h:108
Initializer list type of the Blaze library.
Header file for the AddReference type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h: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
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyLowerProxy.h:113
StrictlyLowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for an StrictlyLowerProxy.
Definition: StrictlyLowerProxy.h:223
Constraint on the data type.
Header file for the isReal shim.
Header file for the clear shim.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyLowerProxy.h:179