LowerProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_LOWERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_LOWERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
52 #include <blaze/math/proxy/Proxy.h>
53 #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>
66 #include <blaze/util/Types.h>
67 
68 
69 namespace blaze {
70 
71 //=================================================================================================
72 //
73 // CLASS DEFINITION
74 //
75 //=================================================================================================
76 
77 //*************************************************************************************************
97 template< typename MT > // Type of the adapted matrix
99  : public Proxy< LowerProxy<MT>, ElementType_<MT> >
100 {
101  private:
102  //**Type definitions****************************************************************************
105  //**********************************************************************************************
106 
107  public:
108  //**Type definitions****************************************************************************
112  //**********************************************************************************************
113 
114  //**Constructors********************************************************************************
117  explicit inline LowerProxy( MT& matrix, size_t row, size_t column );
118  inline LowerProxy( const LowerProxy& lp );
120  //**********************************************************************************************
121 
122  //**Destructor**********************************************************************************
123  // No explicitly declared destructor.
124  //**********************************************************************************************
125 
126  //**Assignment operators************************************************************************
129  inline const LowerProxy& operator=( const LowerProxy& lp ) const;
130 
131  template< typename T >
132  inline const LowerProxy& operator=( initializer_list<T> list ) const;
133 
134  template< typename T >
135  inline const LowerProxy& operator=( initializer_list< initializer_list<T> > list ) const;
136 
137  template< typename T > inline const LowerProxy& operator= ( const T& value ) const;
138  template< typename T > inline const LowerProxy& operator+=( const T& value ) const;
139  template< typename T > inline const LowerProxy& operator-=( const T& value ) const;
140  template< typename T > inline const LowerProxy& operator*=( const T& value ) const;
141  template< typename T > inline const LowerProxy& operator/=( const T& value ) const;
142  template< typename T > inline const LowerProxy& operator%=( const T& value ) const;
144  //**********************************************************************************************
145 
146  //**Access operators****************************************************************************
149  inline const LowerProxy* operator->() const noexcept;
151  //**********************************************************************************************
152 
153  //**Utility functions***************************************************************************
156  inline RawReference get() const noexcept;
157  inline bool isRestricted() const noexcept;
159  //**********************************************************************************************
160 
161  //**Conversion operator*************************************************************************
164  inline operator ConstReference() const noexcept;
166  //**********************************************************************************************
167 
168  private:
169  //**Member variables****************************************************************************
173  const bool restricted_;
174 
178  //**********************************************************************************************
179 
180  //**Compile time checks*************************************************************************
193  //**********************************************************************************************
194 };
195 //*************************************************************************************************
196 
197 
198 
199 
200 //=================================================================================================
201 //
202 // CONSTRUCTORS
203 //
204 //=================================================================================================
205 
206 //*************************************************************************************************
213 template< typename MT > // Type of the adapted matrix
214 inline LowerProxy<MT>::LowerProxy( MT& matrix, size_t row, size_t column )
215  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
216  , restricted_( row < column ) // Access flag for the accessed matrix element
217 {}
218 //*************************************************************************************************
219 
220 
221 //*************************************************************************************************
226 template< typename MT > // Type of the adapted matrix
228  : value_ ( lp.value_ ) // Reference to the accessed matrix element
229  , restricted_( lp.restricted_ ) // Access flag for the accessed matrix element
230 {}
231 //*************************************************************************************************
232 
233 
234 
235 
236 //=================================================================================================
237 //
238 // ASSIGNMENT OPERATORS
239 //
240 //=================================================================================================
241 
242 //*************************************************************************************************
252 template< typename MT > // Type of the adapted matrix
253 inline const LowerProxy<MT>& LowerProxy<MT>::operator=( const LowerProxy& lp ) const
254 {
255  if( restricted_ ) {
256  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
257  }
258 
259  value_ = lp.value_;
260 
261  return *this;
262 }
263 //*************************************************************************************************
264 
265 
266 //*************************************************************************************************
276 template< typename MT > // Type of the adapted matrix
277 template< typename T > // Type of the right-hand side value
279 {
280  if( restricted_ ) {
281  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
282  }
283 
284  value_ = list;
285 
286  return *this;
287 }
288 //*************************************************************************************************
289 
290 
291 //*************************************************************************************************
301 template< typename MT > // Type of the adapted matrix
302 template< typename T > // Type of the right-hand side value
304 {
305  if( restricted_ ) {
306  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
307  }
308 
309  value_ = list;
310 
311  return *this;
312 }
313 //*************************************************************************************************
314 
315 
316 //*************************************************************************************************
326 template< typename MT > // Type of the adapted matrix
327 template< typename T > // Type of the right-hand side value
328 inline const LowerProxy<MT>& LowerProxy<MT>::operator=( const T& value ) const
329 {
330  if( restricted_ ) {
331  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
332  }
333 
334  value_ = value;
335 
336  return *this;
337 }
338 //*************************************************************************************************
339 
340 
341 //*************************************************************************************************
351 template< typename MT > // Type of the adapted matrix
352 template< typename T > // Type of the right-hand side value
353 inline const LowerProxy<MT>& LowerProxy<MT>::operator+=( const T& value ) const
354 {
355  if( restricted_ ) {
356  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
357  }
358 
359  value_ += value;
360 
361  return *this;
362 }
363 //*************************************************************************************************
364 
365 
366 //*************************************************************************************************
376 template< typename MT > // Type of the adapted matrix
377 template< typename T > // Type of the right-hand side value
378 inline const LowerProxy<MT>& LowerProxy<MT>::operator-=( const T& value ) const
379 {
380  if( restricted_ ) {
381  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
382  }
383 
384  value_ -= value;
385 
386  return *this;
387 }
388 //*************************************************************************************************
389 
390 
391 //*************************************************************************************************
401 template< typename MT > // Type of the adapted matrix
402 template< typename T > // Type of the right-hand side value
403 inline const LowerProxy<MT>& LowerProxy<MT>::operator*=( const T& value ) const
404 {
405  if( restricted_ ) {
406  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
407  }
408 
409  value_ *= value;
410 
411  return *this;
412 }
413 //*************************************************************************************************
414 
415 
416 //*************************************************************************************************
426 template< typename MT > // Type of the adapted matrix
427 template< typename T > // Type of the right-hand side value
428 inline const LowerProxy<MT>& LowerProxy<MT>::operator/=( const T& value ) const
429 {
430  if( restricted_ ) {
431  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
432  }
433 
434  value_ /= value;
435 
436  return *this;
437 }
438 //*************************************************************************************************
439 
440 
441 //*************************************************************************************************
451 template< typename MT > // Type of the adapted matrix
452 template< typename T > // Type of the right-hand side value
453 inline const LowerProxy<MT>& LowerProxy<MT>::operator%=( const T& value ) const
454 {
455  if( restricted_ ) {
456  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix element" );
457  }
458 
459  value_ %= value;
460 
461  return *this;
462 }
463 //*************************************************************************************************
464 
465 
466 
467 
468 //=================================================================================================
469 //
470 // ACCESS OPERATORS
471 //
472 //=================================================================================================
473 
474 //*************************************************************************************************
479 template< typename MT > // Type of the adapted matrix
480 inline const LowerProxy<MT>* LowerProxy<MT>::operator->() const noexcept
481 {
482  return this;
483 }
484 //*************************************************************************************************
485 
486 
487 
488 
489 //=================================================================================================
490 //
491 // UTILITY FUNCTIONS
492 //
493 //=================================================================================================
494 
495 //*************************************************************************************************
500 template< typename MT > // Type of the adapted matrix
501 inline typename LowerProxy<MT>::RawReference LowerProxy<MT>::get() const noexcept
502 {
503  return value_;
504 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
513 template< typename MT > // Type of the adapted matrix
514 inline bool LowerProxy<MT>::isRestricted() const noexcept
515 {
516  return restricted_;
517 }
518 //*************************************************************************************************
519 
520 
521 
522 
523 //=================================================================================================
524 //
525 // CONVERSION OPERATOR
526 //
527 //=================================================================================================
528 
529 //*************************************************************************************************
534 template< typename MT > // Type of the adapted matrix
536 {
537  return static_cast<ConstReference>( value_ );
538 }
539 //*************************************************************************************************
540 
541 
542 
543 
544 //=================================================================================================
545 //
546 // GLOBAL FUNCTIONS
547 //
548 //=================================================================================================
549 
550 //*************************************************************************************************
553 template< typename MT >
554 inline void reset( const LowerProxy<MT>& proxy );
555 
556 template< typename MT >
557 inline void clear( const LowerProxy<MT>& proxy );
558 
559 template< bool RF, typename MT >
560 inline bool isDefault( const LowerProxy<MT>& proxy );
561 
562 template< bool RF, typename MT >
563 inline bool isReal( const LowerProxy<MT>& proxy );
564 
565 template< bool RF, typename MT >
566 inline bool isZero( const LowerProxy<MT>& proxy );
567 
568 template< bool RF, typename MT >
569 inline bool isOne( const LowerProxy<MT>& proxy );
570 
571 template< typename MT >
572 inline bool isnan( const LowerProxy<MT>& proxy );
574 //*************************************************************************************************
575 
576 
577 //*************************************************************************************************
587 template< typename MT >
588 inline void reset( const LowerProxy<MT>& proxy )
589 {
590  using blaze::reset;
591 
592  reset( proxy.get() );
593 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
607 template< typename MT >
608 inline void clear( const LowerProxy<MT>& proxy )
609 {
610  using blaze::clear;
611 
612  clear( proxy.get() );
613 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
627 template< bool RF, typename MT >
628 inline bool isDefault( const LowerProxy<MT>& proxy )
629 {
630  using blaze::isDefault;
631 
632  return isDefault<RF>( proxy.get() );
633 }
634 //*************************************************************************************************
635 
636 
637 //*************************************************************************************************
649 template< bool RF, typename MT >
650 inline bool isReal( const LowerProxy<MT>& proxy )
651 {
652  using blaze::isReal;
653 
654  return isReal<RF>( proxy.get() );
655 }
656 //*************************************************************************************************
657 
658 
659 //*************************************************************************************************
669 template< bool RF, typename MT >
670 inline bool isZero( const LowerProxy<MT>& proxy )
671 {
672  using blaze::isZero;
673 
674  return isZero<RF>( proxy.get() );
675 }
676 //*************************************************************************************************
677 
678 
679 //*************************************************************************************************
689 template< bool RF, typename MT >
690 inline bool isOne( const LowerProxy<MT>& proxy )
691 {
692  using blaze::isOne;
693 
694  return isOne<RF>( proxy.get() );
695 }
696 //*************************************************************************************************
697 
698 
699 //*************************************************************************************************
709 template< typename MT >
710 inline bool isnan( const LowerProxy<MT>& proxy )
711 {
712  using blaze::isnan;
713 
714  return isnan( proxy.get() );
715 }
716 //*************************************************************************************************
717 
718 } // namespace blaze
719 
720 #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 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:131
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
AddConst_< Reference_< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: LowerProxy.h:104
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element.
Definition: LowerProxy.h:514
typename AddConst< T >::Type AddConst_
Auxiliary alias declaration for the AddConst type trait.The AddConst_ alias declaration provides a co...
Definition: AddConst.h:95
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: LowerProxy.h:109
#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
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: LowerProxy.h:111
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the Proxy class.
LowerProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a LowerProxy.
Definition: LowerProxy.h:214
Constraint on the data type.
Constraint on the data type.
const LowerProxy & operator=(const LowerProxy &lp) const
Copy assignment operator for LowerProxy.
Definition: LowerProxy.h:253
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: LowerProxy.h:501
AddReference_< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: LowerProxy.h:110
#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.
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.
ReferenceType value_
Reference to the accessed matrix element.
Definition: LowerProxy.h:172
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
Header file for the isOne shim.
const bool restricted_
Access flag for the accessed matrix element.
Definition: LowerProxy.h:173
#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
Access proxy for lower triangular matrices.The LowerProxy provides controlled access to the elements ...
Definition: LowerProxy.h:98
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:131
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
#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.
Initializer list type of the Blaze library.
#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 AddReference 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
#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
const LowerProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: LowerProxy.h:480
Header file for the isReal shim.
typename AddReference< T >::Type AddReference_
Auxiliary alias declaration for the AddReference type trait.The AddReference_ alias declaration provi...
Definition: AddReference.h:95