StrictlyUpperProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_UPPERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_UPPERPROXY_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 //*************************************************************************************************
99 template< typename MT > // Type of the adapted matrix
101  : public Proxy< StrictlyUpperProxy<MT>, ElementType_<MT> >
102 {
103  private:
104  //**Type definitions****************************************************************************
107  //**********************************************************************************************
108 
109  public:
110  //**Type definitions****************************************************************************
114  //**********************************************************************************************
115 
116  //**Constructors********************************************************************************
119  explicit inline StrictlyUpperProxy( MT& matrix, size_t row, size_t column );
120  inline StrictlyUpperProxy( const StrictlyUpperProxy& uup );
122  //**********************************************************************************************
123 
124  //**Destructor**********************************************************************************
125  // No explicitly declared destructor.
126  //**********************************************************************************************
127 
128  //**Assignment operators************************************************************************
131  inline const StrictlyUpperProxy& operator= ( const StrictlyUpperProxy& uup ) const;
132 
133  template< typename T >
134  inline const StrictlyUpperProxy& operator=( initializer_list<T> list ) const;
135 
136  template< typename T >
137  inline const StrictlyUpperProxy& operator=( initializer_list< initializer_list<T> > list ) const;
138 
139  template< typename T > inline const StrictlyUpperProxy& operator= ( const T& value ) const;
140  template< typename T > inline const StrictlyUpperProxy& operator+=( const T& value ) const;
141  template< typename T > inline const StrictlyUpperProxy& operator-=( const T& value ) const;
142  template< typename T > inline const StrictlyUpperProxy& operator*=( const T& value ) const;
143  template< typename T > inline const StrictlyUpperProxy& operator/=( const T& value ) const;
144  template< typename T > inline const StrictlyUpperProxy& operator%=( const T& value ) const;
146  //**********************************************************************************************
147 
148  //**Access operators****************************************************************************
151  inline const StrictlyUpperProxy* operator->() const noexcept;
153  //**********************************************************************************************
154 
155  //**Utility functions***************************************************************************
158  inline RawReference get() const noexcept;
159  inline bool isRestricted() const noexcept;
161  //**********************************************************************************************
162 
163  //**Conversion operator*************************************************************************
166  inline operator ConstReference() const noexcept;
168  //**********************************************************************************************
169 
170  private:
171  //**Member variables****************************************************************************
175  const bool restricted_;
176 
180  //**********************************************************************************************
181 
182  //**Compile time checks*************************************************************************
195  //**********************************************************************************************
196 };
197 //*************************************************************************************************
198 
199 
200 
201 
202 //=================================================================================================
203 //
204 // CONSTRUCTORS
205 //
206 //=================================================================================================
207 
208 //*************************************************************************************************
215 template< typename MT > // Type of the adapted matrix
216 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
217  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
218  , restricted_( column <= row ) // Access flag for the accessed matrix element
219 {}
220 //*************************************************************************************************
221 
222 
223 //*************************************************************************************************
228 template< typename MT > // Type of the adapted matrix
230  : value_ ( uup.value_ ) // Reference to the accessed matrix element
231  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
232 {}
233 //*************************************************************************************************
234 
235 
236 
237 
238 //=================================================================================================
239 //
240 // OPERATORS
241 //
242 //=================================================================================================
243 
244 //*************************************************************************************************
254 template< typename MT > // Type of the adapted matrix
256 {
257  if( restricted_ ) {
258  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
259  }
260 
261  value_ = uup.value_;
262 
263  return *this;
264 }
265 //*************************************************************************************************
266 
267 
268 //*************************************************************************************************
278 template< typename MT > // Type of the adapted matrix
279 template< typename T > // Type of the right-hand side value
280 inline const StrictlyUpperProxy<MT>&
282 {
283  if( restricted_ ) {
284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
285  }
286 
287  value_ = list;
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 StrictlyUpperProxy<MT>&
308 {
309  if( restricted_ ) {
310  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
311  }
312 
313  value_ = list;
314 
315  return *this;
316 }
317 //*************************************************************************************************
318 
319 
320 //*************************************************************************************************
330 template< typename MT > // Type of the adapted matrix
331 template< typename T > // Type of the right-hand side value
332 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
333 {
334  if( restricted_ ) {
335  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
336  }
337 
338  value_ = value;
339 
340  return *this;
341 }
342 //*************************************************************************************************
343 
344 
345 //*************************************************************************************************
355 template< typename MT > // Type of the adapted matrix
356 template< typename T > // Type of the right-hand side value
357 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
358 {
359  if( restricted_ ) {
360  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
361  }
362 
363  value_ += value;
364 
365  return *this;
366 }
367 //*************************************************************************************************
368 
369 
370 //*************************************************************************************************
380 template< typename MT > // Type of the adapted matrix
381 template< typename T > // Type of the right-hand side value
382 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
383 {
384  if( restricted_ ) {
385  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
386  }
387 
388  value_ -= value;
389 
390  return *this;
391 }
392 //*************************************************************************************************
393 
394 
395 //*************************************************************************************************
405 template< typename MT > // Type of the adapted matrix
406 template< typename T > // Type of the right-hand side value
407 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
408 {
409  if( restricted_ ) {
410  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
411  }
412 
413  value_ *= value;
414 
415  return *this;
416 }
417 //*************************************************************************************************
418 
419 
420 //*************************************************************************************************
430 template< typename MT > // Type of the adapted matrix
431 template< typename T > // Type of the right-hand side value
432 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
433 {
434  if( restricted_ ) {
435  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
436  }
437 
438  value_ /= value;
439 
440  return *this;
441 }
442 //*************************************************************************************************
443 
444 
445 //*************************************************************************************************
455 template< typename MT > // Type of the adapted matrix
456 template< typename T > // Type of the right-hand side value
457 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator%=( const T& value ) const
458 {
459  if( restricted_ ) {
460  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
461  }
462 
463  value_ %= value;
464 
465  return *this;
466 }
467 //*************************************************************************************************
468 
469 
470 
471 
472 //=================================================================================================
473 //
474 // ACCESS OPERATORS
475 //
476 //=================================================================================================
477 
478 //*************************************************************************************************
483 template< typename MT > // Type of the adapted matrix
485 {
486  return this;
487 }
488 //*************************************************************************************************
489 
490 
491 
492 
493 //=================================================================================================
494 //
495 // UTILITY FUNCTIONS
496 //
497 //=================================================================================================
498 
499 //*************************************************************************************************
504 template< typename MT > // Type of the adapted matrix
506 {
507  return value_;
508 }
509 //*************************************************************************************************
510 
511 
512 //*************************************************************************************************
517 template< typename MT > // Type of the adapted matrix
518 inline bool StrictlyUpperProxy<MT>::isRestricted() const noexcept
519 {
520  return restricted_;
521 }
522 //*************************************************************************************************
523 
524 
525 
526 
527 //=================================================================================================
528 //
529 // CONVERSION OPERATOR
530 //
531 //=================================================================================================
532 
533 //*************************************************************************************************
538 template< typename MT > // Type of the adapted matrix
540 {
541  return static_cast<ConstReference>( value_ );
542 }
543 //*************************************************************************************************
544 
545 
546 
547 
548 //=================================================================================================
549 //
550 // GLOBAL FUNCTIONS
551 //
552 //=================================================================================================
553 
554 //*************************************************************************************************
557 template< typename MT >
558 inline void reset( const StrictlyUpperProxy<MT>& proxy );
559 
560 template< typename MT >
561 inline void clear( const StrictlyUpperProxy<MT>& proxy );
562 
563 template< bool RF, typename MT >
564 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy );
565 
566 template< bool RF, typename MT >
567 inline bool isReal( const StrictlyUpperProxy<MT>& proxy );
568 
569 template< bool RF, typename MT >
570 inline bool isZero( const StrictlyUpperProxy<MT>& proxy );
571 
572 template< bool RF, typename MT >
573 inline bool isOne( const StrictlyUpperProxy<MT>& proxy );
574 
575 template< typename MT >
576 inline bool isnan( const StrictlyUpperProxy<MT>& proxy );
578 //*************************************************************************************************
579 
580 
581 //*************************************************************************************************
591 template< typename MT >
592 inline void reset( const StrictlyUpperProxy<MT>& proxy )
593 {
594  using blaze::reset;
595 
596  reset( proxy.get() );
597 }
598 //*************************************************************************************************
599 
600 
601 //*************************************************************************************************
611 template< typename MT >
612 inline void clear( const StrictlyUpperProxy<MT>& proxy )
613 {
614  using blaze::clear;
615 
616  clear( proxy.get() );
617 }
618 //*************************************************************************************************
619 
620 
621 //*************************************************************************************************
631 template< bool RF, typename MT >
632 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
633 {
634  using blaze::isDefault;
635 
636  return isDefault<RF>( proxy.get() );
637 }
638 //*************************************************************************************************
639 
640 
641 //*************************************************************************************************
653 template< bool RF, typename MT >
654 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
655 {
656  using blaze::isReal;
657 
658  return isReal<RF>( proxy.get() );
659 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
673 template< bool RF, typename MT >
674 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
675 {
676  using blaze::isZero;
677 
678  return isZero<RF>( proxy.get() );
679 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
693 template< bool RF, typename MT >
694 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
695 {
696  using blaze::isOne;
697 
698  return isOne<RF>( proxy.get() );
699 }
700 //*************************************************************************************************
701 
702 
703 //*************************************************************************************************
713 template< typename MT >
714 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
715 {
716  using blaze::isnan;
717 
718  return isnan( proxy.get() );
719 }
720 //*************************************************************************************************
721 
722 } // namespace blaze
723 
724 #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.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyUpperProxy.h:174
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
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
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:505
#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
Access proxy for strictly upper triangular matrices.The StrictlyUpperProxy provides controlled access...
Definition: StrictlyUpperProxy.h:100
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the Proxy class.
Constraint on the data type.
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
const StrictlyUpperProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyUpperProxy.h:484
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyUpperProxy.h:518
#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
StrictlyUpperProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:216
Constraint on the data type.
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyUpperProxy.h:111
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.
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
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyUpperProxy.h:175
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the isOne shim.
AddConst_< Reference_< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyUpperProxy.h:106
#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
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.
AddReference_< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyUpperProxy.h:112
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyUpperProxy.h:113
Initializer list type of the Blaze library.
const StrictlyUpperProxy & operator=(const StrictlyUpperProxy &uup) const
Copy assignment operator for StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:255
#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
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