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  //**Utility functions***************************************************************************
151  inline RawReference get() const noexcept;
152  inline bool isRestricted() const noexcept;
154  //**********************************************************************************************
155 
156  //**Conversion operator*************************************************************************
159  inline operator ConstReference() const noexcept;
161  //**********************************************************************************************
162 
163  private:
164  //**Member variables****************************************************************************
168  const bool restricted_;
169 
173  //**********************************************************************************************
174 
175  //**Compile time checks*************************************************************************
188  //**********************************************************************************************
189 };
190 //*************************************************************************************************
191 
192 
193 
194 
195 //=================================================================================================
196 //
197 // CONSTRUCTORS
198 //
199 //=================================================================================================
200 
201 //*************************************************************************************************
208 template< typename MT > // Type of the adapted matrix
209 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
210  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
211  , restricted_( column <= row ) // Access flag for the accessed matrix element
212 {}
213 //*************************************************************************************************
214 
215 
216 //*************************************************************************************************
221 template< typename MT > // Type of the adapted matrix
223  : value_ ( uup.value_ ) // Reference to the accessed matrix element
224  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
225 {}
226 //*************************************************************************************************
227 
228 
229 
230 
231 //=================================================================================================
232 //
233 // OPERATORS
234 //
235 //=================================================================================================
236 
237 //*************************************************************************************************
247 template< typename MT > // Type of the adapted matrix
249 {
250  if( restricted_ ) {
251  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
252  }
253 
254  value_ = uup.value_;
255 
256  return *this;
257 }
258 //*************************************************************************************************
259 
260 
261 //*************************************************************************************************
271 template< typename MT > // Type of the adapted matrix
272 template< typename T > // Type of the right-hand side value
273 inline const StrictlyUpperProxy<MT>&
275 {
276  if( restricted_ ) {
277  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
278  }
279 
280  value_ = list;
281 
282  return *this;
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
297 template< typename MT > // Type of the adapted matrix
298 template< typename T > // Type of the right-hand side value
299 inline const StrictlyUpperProxy<MT>&
301 {
302  if( restricted_ ) {
303  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
304  }
305 
306  value_ = list;
307 
308  return *this;
309 }
310 //*************************************************************************************************
311 
312 
313 //*************************************************************************************************
323 template< typename MT > // Type of the adapted matrix
324 template< typename T > // Type of the right-hand side value
325 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
326 {
327  if( restricted_ ) {
328  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
329  }
330 
331  value_ = value;
332 
333  return *this;
334 }
335 //*************************************************************************************************
336 
337 
338 //*************************************************************************************************
348 template< typename MT > // Type of the adapted matrix
349 template< typename T > // Type of the right-hand side value
350 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
351 {
352  if( restricted_ ) {
353  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
354  }
355 
356  value_ += value;
357 
358  return *this;
359 }
360 //*************************************************************************************************
361 
362 
363 //*************************************************************************************************
373 template< typename MT > // Type of the adapted matrix
374 template< typename T > // Type of the right-hand side value
375 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
376 {
377  if( restricted_ ) {
378  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
379  }
380 
381  value_ -= value;
382 
383  return *this;
384 }
385 //*************************************************************************************************
386 
387 
388 //*************************************************************************************************
398 template< typename MT > // Type of the adapted matrix
399 template< typename T > // Type of the right-hand side value
400 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
401 {
402  if( restricted_ ) {
403  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
404  }
405 
406  value_ *= value;
407 
408  return *this;
409 }
410 //*************************************************************************************************
411 
412 
413 //*************************************************************************************************
423 template< typename MT > // Type of the adapted matrix
424 template< typename T > // Type of the right-hand side value
425 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
426 {
427  if( restricted_ ) {
428  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
429  }
430 
431  value_ /= value;
432 
433  return *this;
434 }
435 //*************************************************************************************************
436 
437 
438 //*************************************************************************************************
448 template< typename MT > // Type of the adapted matrix
449 template< typename T > // Type of the right-hand side value
450 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator%=( const T& value ) const
451 {
452  if( restricted_ ) {
453  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
454  }
455 
456  value_ %= value;
457 
458  return *this;
459 }
460 //*************************************************************************************************
461 
462 
463 
464 
465 //=================================================================================================
466 //
467 // UTILITY FUNCTIONS
468 //
469 //=================================================================================================
470 
471 //*************************************************************************************************
476 template< typename MT > // Type of the adapted matrix
478 {
479  return value_;
480 }
481 //*************************************************************************************************
482 
483 
484 //*************************************************************************************************
489 template< typename MT > // Type of the adapted matrix
490 inline bool StrictlyUpperProxy<MT>::isRestricted() const noexcept
491 {
492  return restricted_;
493 }
494 //*************************************************************************************************
495 
496 
497 
498 
499 //=================================================================================================
500 //
501 // CONVERSION OPERATOR
502 //
503 //=================================================================================================
504 
505 //*************************************************************************************************
510 template< typename MT > // Type of the adapted matrix
512 {
513  return static_cast<ConstReference>( value_ );
514 }
515 //*************************************************************************************************
516 
517 
518 
519 
520 //=================================================================================================
521 //
522 // GLOBAL FUNCTIONS
523 //
524 //=================================================================================================
525 
526 //*************************************************************************************************
529 template< typename MT >
530 inline void reset( const StrictlyUpperProxy<MT>& proxy );
531 
532 template< typename MT >
533 inline void clear( const StrictlyUpperProxy<MT>& proxy );
534 
535 template< bool RF, typename MT >
536 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy );
537 
538 template< bool RF, typename MT >
539 inline bool isReal( const StrictlyUpperProxy<MT>& proxy );
540 
541 template< bool RF, typename MT >
542 inline bool isZero( const StrictlyUpperProxy<MT>& proxy );
543 
544 template< bool RF, typename MT >
545 inline bool isOne( const StrictlyUpperProxy<MT>& proxy );
546 
547 template< typename MT >
548 inline bool isnan( const StrictlyUpperProxy<MT>& proxy );
550 //*************************************************************************************************
551 
552 
553 //*************************************************************************************************
563 template< typename MT >
564 inline void reset( const StrictlyUpperProxy<MT>& proxy )
565 {
566  using blaze::reset;
567 
568  reset( proxy.get() );
569 }
570 //*************************************************************************************************
571 
572 
573 //*************************************************************************************************
583 template< typename MT >
584 inline void clear( const StrictlyUpperProxy<MT>& proxy )
585 {
586  using blaze::clear;
587 
588  clear( proxy.get() );
589 }
590 //*************************************************************************************************
591 
592 
593 //*************************************************************************************************
603 template< bool RF, typename MT >
604 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
605 {
606  using blaze::isDefault;
607 
608  return isDefault<RF>( proxy.get() );
609 }
610 //*************************************************************************************************
611 
612 
613 //*************************************************************************************************
625 template< bool RF, typename MT >
626 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
627 {
628  using blaze::isReal;
629 
630  return isReal<RF>( proxy.get() );
631 }
632 //*************************************************************************************************
633 
634 
635 //*************************************************************************************************
645 template< bool RF, typename MT >
646 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
647 {
648  using blaze::isZero;
649 
650  return isZero<RF>( proxy.get() );
651 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
665 template< bool RF, typename MT >
666 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
667 {
668  using blaze::isOne;
669 
670  return isOne<RF>( proxy.get() );
671 }
672 //*************************************************************************************************
673 
674 
675 //*************************************************************************************************
685 template< typename MT >
686 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
687 {
688  using blaze::isnan;
689 
690  return isnan( proxy.get() );
691 }
692 //*************************************************************************************************
693 
694 } // namespace blaze
695 
696 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:622
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:167
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:560
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:477
#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
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
Constraint on the data type.
Header file for the Proxy class.
Constraint on the data type.
Constraint on the data type.
Header file for the std::initializer_list aliases.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:642
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
bool isRestricted() const noexcept
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyUpperProxy.h:490
#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:209
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:682
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:168
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
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.
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:662
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:248
#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:600
#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