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
100 class StrictlyUpperProxy : public Proxy< StrictlyUpperProxy<MT>, ElementType_<MT> >
101 {
102  private:
103  //**Type definitions****************************************************************************
106  //**********************************************************************************************
107 
108  public:
109  //**Type definitions****************************************************************************
112  typedef const RepresentedType& ConstReference;
113  //**********************************************************************************************
114 
115  //**Constructors********************************************************************************
118  explicit inline StrictlyUpperProxy( MT& matrix, size_t row, size_t column );
119  inline StrictlyUpperProxy( const StrictlyUpperProxy& uup );
121  //**********************************************************************************************
122 
123  //**Destructor**********************************************************************************
124  // No explicitly declared destructor.
125  //**********************************************************************************************
126 
127  //**Assignment operators************************************************************************
130  inline const StrictlyUpperProxy& operator= ( const StrictlyUpperProxy& uup ) const;
131 
132  template< typename T >
133  inline const StrictlyUpperProxy& operator=( initializer_list<T> list ) const;
134 
135  template< typename T >
136  inline const StrictlyUpperProxy& operator=( initializer_list< initializer_list<T> > list ) const;
137 
138  template< typename T > inline const StrictlyUpperProxy& operator= ( const T& value ) const;
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;
144  //**********************************************************************************************
145 
146  //**Utility functions***************************************************************************
149  inline RawReference get() const noexcept;
150  inline bool isRestricted() const noexcept;
152  //**********************************************************************************************
153 
154  //**Conversion operator*************************************************************************
157  inline operator ConstReference() const noexcept;
159  //**********************************************************************************************
160 
161  private:
162  //**Member variables****************************************************************************
165  ReferenceType value_;
166  const bool restricted_;
167 
171  //**********************************************************************************************
172 
173  //**Compile time checks*************************************************************************
186  //**********************************************************************************************
187 };
188 //*************************************************************************************************
189 
190 
191 
192 
193 //=================================================================================================
194 //
195 // CONSTRUCTORS
196 //
197 //=================================================================================================
198 
199 //*************************************************************************************************
206 template< typename MT > // Type of the adapted matrix
207 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
208  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
209  , restricted_( column <= row ) // Access flag for the accessed matrix element
210 {}
211 //*************************************************************************************************
212 
213 
214 //*************************************************************************************************
219 template< typename MT > // Type of the adapted matrix
221  : value_ ( uup.value_ ) // Reference to the accessed matrix element
222  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
223 {}
224 //*************************************************************************************************
225 
226 
227 
228 
229 //=================================================================================================
230 //
231 // OPERATORS
232 //
233 //=================================================================================================
234 
235 //*************************************************************************************************
245 template< typename MT > // Type of the adapted matrix
247 {
248  if( restricted_ ) {
249  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
250  }
251 
252  value_ = uup.value_;
253 
254  return *this;
255 }
256 //*************************************************************************************************
257 
258 
259 //*************************************************************************************************
269 template< typename MT > // Type of the adapted matrix
270 template< typename T > // Type of the right-hand side value
271 inline const StrictlyUpperProxy<MT>&
273 {
274  if( restricted_ ) {
275  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
276  }
277 
278  value_ = list;
279 
280  return *this;
281 }
282 //*************************************************************************************************
283 
284 
285 //*************************************************************************************************
295 template< typename MT > // Type of the adapted matrix
296 template< typename T > // Type of the right-hand side value
297 inline const StrictlyUpperProxy<MT>&
299 {
300  if( restricted_ ) {
301  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
302  }
303 
304  value_ = list;
305 
306  return *this;
307 }
308 //*************************************************************************************************
309 
310 
311 //*************************************************************************************************
321 template< typename MT > // Type of the adapted matrix
322 template< typename T > // Type of the right-hand side value
323 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
324 {
325  if( restricted_ ) {
326  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
327  }
328 
329  value_ = value;
330 
331  return *this;
332 }
333 //*************************************************************************************************
334 
335 
336 //*************************************************************************************************
346 template< typename MT > // Type of the adapted matrix
347 template< typename T > // Type of the right-hand side value
348 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
349 {
350  if( restricted_ ) {
351  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
352  }
353 
354  value_ += value;
355 
356  return *this;
357 }
358 //*************************************************************************************************
359 
360 
361 //*************************************************************************************************
371 template< typename MT > // Type of the adapted matrix
372 template< typename T > // Type of the right-hand side value
373 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
374 {
375  if( restricted_ ) {
376  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
377  }
378 
379  value_ -= value;
380 
381  return *this;
382 }
383 //*************************************************************************************************
384 
385 
386 //*************************************************************************************************
396 template< typename MT > // Type of the adapted matrix
397 template< typename T > // Type of the right-hand side value
398 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
399 {
400  if( restricted_ ) {
401  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
402  }
403 
404  value_ *= value;
405 
406  return *this;
407 }
408 //*************************************************************************************************
409 
410 
411 //*************************************************************************************************
421 template< typename MT > // Type of the adapted matrix
422 template< typename T > // Type of the right-hand side value
423 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
424 {
425  if( restricted_ ) {
426  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
427  }
428 
429  value_ /= value;
430 
431  return *this;
432 }
433 //*************************************************************************************************
434 
435 
436 
437 
438 //=================================================================================================
439 //
440 // UTILITY FUNCTIONS
441 //
442 //=================================================================================================
443 
444 //*************************************************************************************************
449 template< typename MT > // Type of the adapted matrix
451 {
452  return value_;
453 }
454 //*************************************************************************************************
455 
456 
457 //*************************************************************************************************
462 template< typename MT > // Type of the adapted matrix
463 inline bool StrictlyUpperProxy<MT>::isRestricted() const noexcept
464 {
465  return restricted_;
466 }
467 //*************************************************************************************************
468 
469 
470 
471 
472 //=================================================================================================
473 //
474 // CONVERSION OPERATOR
475 //
476 //=================================================================================================
477 
478 //*************************************************************************************************
483 template< typename MT > // Type of the adapted matrix
485 {
486  return static_cast<ConstReference>( value_ );
487 }
488 //*************************************************************************************************
489 
490 
491 
492 
493 //=================================================================================================
494 //
495 // GLOBAL FUNCTIONS
496 //
497 //=================================================================================================
498 
499 //*************************************************************************************************
502 template< typename MT >
503 inline void reset( const StrictlyUpperProxy<MT>& proxy );
504 
505 template< typename MT >
506 inline void clear( const StrictlyUpperProxy<MT>& proxy );
507 
508 template< typename MT >
509 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy );
510 
511 template< typename MT >
512 inline bool isReal( const StrictlyUpperProxy<MT>& proxy );
513 
514 template< typename MT >
515 inline bool isZero( const StrictlyUpperProxy<MT>& proxy );
516 
517 template< typename MT >
518 inline bool isOne( const StrictlyUpperProxy<MT>& proxy );
519 
520 template< typename MT >
521 inline bool isnan( const StrictlyUpperProxy<MT>& proxy );
523 //*************************************************************************************************
524 
525 
526 //*************************************************************************************************
536 template< typename MT >
537 inline void reset( const StrictlyUpperProxy<MT>& proxy )
538 {
539  using blaze::reset;
540 
541  reset( proxy.get() );
542 }
543 //*************************************************************************************************
544 
545 
546 //*************************************************************************************************
556 template< typename MT >
557 inline void clear( const StrictlyUpperProxy<MT>& proxy )
558 {
559  using blaze::clear;
560 
561  clear( proxy.get() );
562 }
563 //*************************************************************************************************
564 
565 
566 //*************************************************************************************************
576 template< typename MT >
577 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
578 {
579  using blaze::isDefault;
580 
581  return isDefault( proxy.get() );
582 }
583 //*************************************************************************************************
584 
585 
586 //*************************************************************************************************
598 template< typename MT >
599 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
600 {
601  using blaze::isReal;
602 
603  return isReal( proxy.get() );
604 }
605 //*************************************************************************************************
606 
607 
608 //*************************************************************************************************
618 template< typename MT >
619 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
620 {
621  using blaze::isZero;
622 
623  return isZero( proxy.get() );
624 }
625 //*************************************************************************************************
626 
627 
628 //*************************************************************************************************
638 template< typename MT >
639 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
640 {
641  using blaze::isOne;
642 
643  return isOne( proxy.get() );
644 }
645 //*************************************************************************************************
646 
647 
648 //*************************************************************************************************
658 template< typename MT >
659 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
660 {
661  using blaze::isnan;
662 
663  return isnan( proxy.get() );
664 }
665 //*************************************************************************************************
666 
667 } // namespace blaze
668 
669 #endif
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
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:635
Header file for the AddConst type trait.
Header file for auxiliary alias declarations.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyUpperProxy.h:165
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
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:595
const StrictlyUpperProxy & operator=(const StrictlyUpperProxy &uup) const
Copy assignment operator for StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:246
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:533
#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
ElementType_< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyUpperProxy.h:110
Constraint on the data type.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
Header file for the Proxy class.
AddReference_< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyUpperProxy.h:111
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
Header file for the std::initializer_list aliases.
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:450
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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:207
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.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:655
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:166
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the isOne shim.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#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
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyUpperProxy.h:463
Constraint on the data type.
Constraint on the data type.
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
Header file for the isDefault shim.
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyUpperProxy.h:112
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
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:615
Header file for the AddReference type trait.
#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.
AddConst_< Reference_< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyUpperProxy.h:105
typename AddReference< T >::Type AddReference_
Auxiliary alias declaration for the AddReference type trait.The AddReference_ alias declaration provi...
Definition: AddReference.h:95