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_t<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**********************************************************************************
127  ~StrictlyUpperProxy() = default;
129  //**********************************************************************************************
130 
131  //**Assignment operators************************************************************************
134  inline const StrictlyUpperProxy& operator= ( const StrictlyUpperProxy& uup ) const;
135 
136  template< typename T >
137  inline const StrictlyUpperProxy& operator=( initializer_list<T> list ) const;
138 
139  template< typename T >
140  inline const StrictlyUpperProxy& operator=( initializer_list< initializer_list<T> > list ) const;
141 
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;
145  template< typename T > inline const StrictlyUpperProxy& operator*=( const T& value ) const;
146  template< typename T > inline const StrictlyUpperProxy& operator/=( const T& value ) const;
147  template< typename T > inline const StrictlyUpperProxy& operator%=( const T& value ) const;
149  //**********************************************************************************************
150 
151  //**Access operators****************************************************************************
154  inline const StrictlyUpperProxy* operator->() const noexcept;
156  //**********************************************************************************************
157 
158  //**Utility functions***************************************************************************
161  inline RawReference get() const noexcept;
162  inline bool isRestricted() const noexcept;
164  //**********************************************************************************************
165 
166  //**Conversion operator*************************************************************************
169  inline operator ConstReference() const noexcept;
171  //**********************************************************************************************
172 
173  private:
174  //**Member variables****************************************************************************
178  const bool restricted_;
179 
183  //**********************************************************************************************
184 
185  //**Compile time checks*************************************************************************
198  //**********************************************************************************************
199 };
200 //*************************************************************************************************
201 
202 
203 
204 
205 //=================================================================================================
206 //
207 // CONSTRUCTORS
208 //
209 //=================================================================================================
210 
211 //*************************************************************************************************
218 template< typename MT > // Type of the adapted matrix
219 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
220  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
221  , restricted_( column <= row ) // Access flag for the accessed matrix element
222 {}
223 //*************************************************************************************************
224 
225 
226 //*************************************************************************************************
231 template< typename MT > // Type of the adapted matrix
233  : value_ ( uup.value_ ) // Reference to the accessed matrix element
234  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
235 {}
236 //*************************************************************************************************
237 
238 
239 
240 
241 //=================================================================================================
242 //
243 // OPERATORS
244 //
245 //=================================================================================================
246 
247 //*************************************************************************************************
257 template< typename MT > // Type of the adapted matrix
259 {
260  if( restricted_ ) {
261  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
262  }
263 
264  value_ = uup.value_;
265 
266  return *this;
267 }
268 //*************************************************************************************************
269 
270 
271 //*************************************************************************************************
281 template< typename MT > // Type of the adapted matrix
282 template< typename T > // Type of the right-hand side value
283 inline const StrictlyUpperProxy<MT>&
285 {
286  if( restricted_ ) {
287  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
288  }
289 
290  value_ = list;
291 
292  return *this;
293 }
294 //*************************************************************************************************
295 
296 
297 //*************************************************************************************************
307 template< typename MT > // Type of the adapted matrix
308 template< typename T > // Type of the right-hand side value
309 inline const StrictlyUpperProxy<MT>&
311 {
312  if( restricted_ ) {
313  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
314  }
315 
316  value_ = list;
317 
318  return *this;
319 }
320 //*************************************************************************************************
321 
322 
323 //*************************************************************************************************
333 template< typename MT > // Type of the adapted matrix
334 template< typename T > // Type of the right-hand side value
335 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
336 {
337  if( restricted_ ) {
338  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
339  }
340 
341  value_ = value;
342 
343  return *this;
344 }
345 //*************************************************************************************************
346 
347 
348 //*************************************************************************************************
358 template< typename MT > // Type of the adapted matrix
359 template< typename T > // Type of the right-hand side value
360 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
361 {
362  if( restricted_ ) {
363  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
364  }
365 
366  value_ += value;
367 
368  return *this;
369 }
370 //*************************************************************************************************
371 
372 
373 //*************************************************************************************************
383 template< typename MT > // Type of the adapted matrix
384 template< typename T > // Type of the right-hand side value
385 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
386 {
387  if( restricted_ ) {
388  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
389  }
390 
391  value_ -= value;
392 
393  return *this;
394 }
395 //*************************************************************************************************
396 
397 
398 //*************************************************************************************************
408 template< typename MT > // Type of the adapted matrix
409 template< typename T > // Type of the right-hand side value
410 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
411 {
412  if( restricted_ ) {
413  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
414  }
415 
416  value_ *= value;
417 
418  return *this;
419 }
420 //*************************************************************************************************
421 
422 
423 //*************************************************************************************************
433 template< typename MT > // Type of the adapted matrix
434 template< typename T > // Type of the right-hand side value
435 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
436 {
437  if( restricted_ ) {
438  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
439  }
440 
441  value_ /= value;
442 
443  return *this;
444 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
458 template< typename MT > // Type of the adapted matrix
459 template< typename T > // Type of the right-hand side value
460 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator%=( const T& value ) const
461 {
462  if( restricted_ ) {
463  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
464  }
465 
466  value_ %= value;
467 
468  return *this;
469 }
470 //*************************************************************************************************
471 
472 
473 
474 
475 //=================================================================================================
476 //
477 // ACCESS OPERATORS
478 //
479 //=================================================================================================
480 
481 //*************************************************************************************************
486 template< typename MT > // Type of the adapted matrix
488 {
489  return this;
490 }
491 //*************************************************************************************************
492 
493 
494 
495 
496 //=================================================================================================
497 //
498 // UTILITY FUNCTIONS
499 //
500 //=================================================================================================
501 
502 //*************************************************************************************************
507 template< typename MT > // Type of the adapted matrix
509 {
510  return value_;
511 }
512 //*************************************************************************************************
513 
514 
515 //*************************************************************************************************
520 template< typename MT > // Type of the adapted matrix
521 inline bool StrictlyUpperProxy<MT>::isRestricted() const noexcept
522 {
523  return restricted_;
524 }
525 //*************************************************************************************************
526 
527 
528 
529 
530 //=================================================================================================
531 //
532 // CONVERSION OPERATOR
533 //
534 //=================================================================================================
535 
536 //*************************************************************************************************
541 template< typename MT > // Type of the adapted matrix
543 {
544  return static_cast<ConstReference>( value_ );
545 }
546 //*************************************************************************************************
547 
548 
549 
550 
551 //=================================================================================================
552 //
553 // GLOBAL FUNCTIONS
554 //
555 //=================================================================================================
556 
557 //*************************************************************************************************
560 template< typename MT >
561 void reset( const StrictlyUpperProxy<MT>& proxy );
562 
563 template< typename MT >
564 void clear( const StrictlyUpperProxy<MT>& proxy );
565 
566 template< bool RF, typename MT >
567 bool isDefault( const StrictlyUpperProxy<MT>& proxy );
568 
569 template< bool RF, typename MT >
570 bool isReal( const StrictlyUpperProxy<MT>& proxy );
571 
572 template< bool RF, typename MT >
573 bool isZero( const StrictlyUpperProxy<MT>& proxy );
574 
575 template< bool RF, typename MT >
576 bool isOne( const StrictlyUpperProxy<MT>& proxy );
577 
578 template< typename MT >
579 bool isnan( const StrictlyUpperProxy<MT>& proxy );
581 //*************************************************************************************************
582 
583 
584 //*************************************************************************************************
594 template< typename MT >
595 inline void reset( const StrictlyUpperProxy<MT>& proxy )
596 {
597  using blaze::reset;
598 
599  reset( proxy.get() );
600 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
614 template< typename MT >
615 inline void clear( const StrictlyUpperProxy<MT>& proxy )
616 {
617  using blaze::clear;
618 
619  clear( proxy.get() );
620 }
621 //*************************************************************************************************
622 
623 
624 //*************************************************************************************************
634 template< bool RF, typename MT >
635 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
636 {
637  using blaze::isDefault;
638 
639  return isDefault<RF>( proxy.get() );
640 }
641 //*************************************************************************************************
642 
643 
644 //*************************************************************************************************
656 template< bool RF, typename MT >
657 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
658 {
659  using blaze::isReal;
660 
661  return isReal<RF>( proxy.get() );
662 }
663 //*************************************************************************************************
664 
665 
666 //*************************************************************************************************
676 template< bool RF, typename MT >
677 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
678 {
679  using blaze::isZero;
680 
681  return isZero<RF>( proxy.get() );
682 }
683 //*************************************************************************************************
684 
685 
686 //*************************************************************************************************
696 template< bool RF, typename MT >
697 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
698 {
699  using blaze::isOne;
700 
701  return isOne<RF>( proxy.get() );
702 }
703 //*************************************************************************************************
704 
705 
706 //*************************************************************************************************
716 template< typename MT >
717 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
718 {
719  using blaze::isnan;
720 
721  return isnan( proxy.get() );
722 }
723 //*************************************************************************************************
724 
725 } // namespace blaze
726 
727 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:653
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:177
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Header file for basic type definitions.
AddConst_t< Reference_t< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyUpperProxy.h:106
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.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:508
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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 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:673
AddReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyUpperProxy.h:112
const StrictlyUpperProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyUpperProxy.h:487
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:521
#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:219
Constraint on the data type.
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:713
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:178
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the isOne shim.
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyUpperProxy.h:111
#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: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, 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:693
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
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:258
#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:631
#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.
Header file for the clear shim.