Blaze  3.6
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>
52 #include <blaze/math/Exception.h>
54 #include <blaze/math/proxy/Proxy.h>
55 #include <blaze/math/shims/Clear.h>
57 #include <blaze/math/shims/IsNaN.h>
58 #include <blaze/math/shims/IsOne.h>
61 #include <blaze/math/shims/Reset.h>
68 #include <blaze/util/Types.h>
69 
70 
71 namespace blaze {
72 
73 //=================================================================================================
74 //
75 // CLASS DEFINITION
76 //
77 //=================================================================================================
78 
79 //*************************************************************************************************
101 template< typename MT > // Type of the adapted matrix
103  : public Proxy< StrictlyUpperProxy<MT>, ElementType_t<MT> >
104 {
105  private:
106  //**Type definitions****************************************************************************
109  //**********************************************************************************************
110 
111  public:
112  //**Type definitions****************************************************************************
116  //**********************************************************************************************
117 
118  //**Constructors********************************************************************************
121  explicit inline StrictlyUpperProxy( MT& matrix, size_t row, size_t column );
122  inline StrictlyUpperProxy( const StrictlyUpperProxy& uup );
124  //**********************************************************************************************
125 
126  //**Destructor**********************************************************************************
129  ~StrictlyUpperProxy() = default;
131  //**********************************************************************************************
132 
133  //**Assignment operators************************************************************************
136  inline const StrictlyUpperProxy& operator= ( const StrictlyUpperProxy& uup ) const;
137 
138  template< typename T >
139  inline const StrictlyUpperProxy& operator=( initializer_list<T> list ) const;
140 
141  template< typename T >
142  inline const StrictlyUpperProxy& operator=( initializer_list< initializer_list<T> > list ) const;
143 
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;
148  template< typename T > inline const StrictlyUpperProxy& operator/=( const T& value ) const;
149  template< typename T > inline const StrictlyUpperProxy& operator%=( const T& value ) const;
151  //**********************************************************************************************
152 
153  //**Access operators****************************************************************************
156  inline const StrictlyUpperProxy* operator->() const noexcept;
158  //**********************************************************************************************
159 
160  //**Utility functions***************************************************************************
163  inline RawReference get() const noexcept;
164  inline bool isRestricted() const noexcept;
166  //**********************************************************************************************
167 
168  //**Conversion operator*************************************************************************
171  inline operator ConstReference() const noexcept;
173  //**********************************************************************************************
174 
175  private:
176  //**Member variables****************************************************************************
180  const bool restricted_;
181 
185  //**********************************************************************************************
186 
187  //**Compile time checks*************************************************************************
202  //**********************************************************************************************
203 };
204 //*************************************************************************************************
205 
206 
207 
208 
209 //=================================================================================================
210 //
211 // CONSTRUCTORS
212 //
213 //=================================================================================================
214 
215 //*************************************************************************************************
222 template< typename MT > // Type of the adapted matrix
223 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
224  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
225  , restricted_( column <= row ) // Access flag for the accessed matrix element
226 {}
227 //*************************************************************************************************
228 
229 
230 //*************************************************************************************************
235 template< typename MT > // Type of the adapted matrix
237  : value_ ( uup.value_ ) // Reference to the accessed matrix element
238  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
239 {}
240 //*************************************************************************************************
241 
242 
243 
244 
245 //=================================================================================================
246 //
247 // OPERATORS
248 //
249 //=================================================================================================
250 
251 //*************************************************************************************************
261 template< typename MT > // Type of the adapted matrix
263 {
264  if( restricted_ ) {
265  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
266  }
267 
268  value_ = uup.value_;
269 
270  return *this;
271 }
272 //*************************************************************************************************
273 
274 
275 //*************************************************************************************************
285 template< typename MT > // Type of the adapted matrix
286 template< typename T > // Type of the right-hand side value
287 inline const StrictlyUpperProxy<MT>&
289 {
290  if( restricted_ ) {
291  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
292  }
293 
294  value_ = list;
295 
296  return *this;
297 }
298 //*************************************************************************************************
299 
300 
301 //*************************************************************************************************
311 template< typename MT > // Type of the adapted matrix
312 template< typename T > // Type of the right-hand side value
313 inline const StrictlyUpperProxy<MT>&
315 {
316  if( restricted_ ) {
317  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
318  }
319 
320  value_ = list;
321 
322  return *this;
323 }
324 //*************************************************************************************************
325 
326 
327 //*************************************************************************************************
337 template< typename MT > // Type of the adapted matrix
338 template< typename T > // Type of the right-hand side value
339 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
340 {
341  if( restricted_ ) {
342  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
343  }
344 
345  value_ = value;
346 
347  return *this;
348 }
349 //*************************************************************************************************
350 
351 
352 //*************************************************************************************************
362 template< typename MT > // Type of the adapted matrix
363 template< typename T > // Type of the right-hand side value
364 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
365 {
366  if( restricted_ ) {
367  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
368  }
369 
370  value_ += value;
371 
372  return *this;
373 }
374 //*************************************************************************************************
375 
376 
377 //*************************************************************************************************
387 template< typename MT > // Type of the adapted matrix
388 template< typename T > // Type of the right-hand side value
389 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
390 {
391  if( restricted_ ) {
392  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
393  }
394 
395  value_ -= value;
396 
397  return *this;
398 }
399 //*************************************************************************************************
400 
401 
402 //*************************************************************************************************
412 template< typename MT > // Type of the adapted matrix
413 template< typename T > // Type of the right-hand side value
414 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
415 {
416  if( restricted_ ) {
417  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
418  }
419 
420  value_ *= value;
421 
422  return *this;
423 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
437 template< typename MT > // Type of the adapted matrix
438 template< typename T > // Type of the right-hand side value
439 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
440 {
441  if( restricted_ ) {
442  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
443  }
444 
445  value_ /= value;
446 
447  return *this;
448 }
449 //*************************************************************************************************
450 
451 
452 //*************************************************************************************************
462 template< typename MT > // Type of the adapted matrix
463 template< typename T > // Type of the right-hand side value
464 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator%=( const T& value ) const
465 {
466  if( restricted_ ) {
467  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
468  }
469 
470  value_ %= value;
471 
472  return *this;
473 }
474 //*************************************************************************************************
475 
476 
477 
478 
479 //=================================================================================================
480 //
481 // ACCESS OPERATORS
482 //
483 //=================================================================================================
484 
485 //*************************************************************************************************
490 template< typename MT > // Type of the adapted matrix
492 {
493  return this;
494 }
495 //*************************************************************************************************
496 
497 
498 
499 
500 //=================================================================================================
501 //
502 // UTILITY FUNCTIONS
503 //
504 //=================================================================================================
505 
506 //*************************************************************************************************
511 template< typename MT > // Type of the adapted matrix
513 {
514  return value_;
515 }
516 //*************************************************************************************************
517 
518 
519 //*************************************************************************************************
524 template< typename MT > // Type of the adapted matrix
525 inline bool StrictlyUpperProxy<MT>::isRestricted() const noexcept
526 {
527  return restricted_;
528 }
529 //*************************************************************************************************
530 
531 
532 
533 
534 //=================================================================================================
535 //
536 // CONVERSION OPERATOR
537 //
538 //=================================================================================================
539 
540 //*************************************************************************************************
545 template< typename MT > // Type of the adapted matrix
547 {
548  return static_cast<ConstReference>( value_ );
549 }
550 //*************************************************************************************************
551 
552 
553 
554 
555 //=================================================================================================
556 //
557 // GLOBAL FUNCTIONS
558 //
559 //=================================================================================================
560 
561 //*************************************************************************************************
564 template< typename MT >
565 void reset( const StrictlyUpperProxy<MT>& proxy );
566 
567 template< typename MT >
568 void clear( const StrictlyUpperProxy<MT>& proxy );
569 
570 template< bool RF, typename MT >
571 bool isDefault( const StrictlyUpperProxy<MT>& proxy );
572 
573 template< bool RF, typename MT >
574 bool isReal( const StrictlyUpperProxy<MT>& proxy );
575 
576 template< bool RF, typename MT >
577 bool isZero( const StrictlyUpperProxy<MT>& proxy );
578 
579 template< bool RF, typename MT >
580 bool isOne( const StrictlyUpperProxy<MT>& proxy );
581 
582 template< typename MT >
583 bool isnan( const StrictlyUpperProxy<MT>& proxy );
585 //*************************************************************************************************
586 
587 
588 //*************************************************************************************************
598 template< typename MT >
599 inline void reset( const StrictlyUpperProxy<MT>& proxy )
600 {
601  using blaze::reset;
602 
603  reset( proxy.get() );
604 }
605 //*************************************************************************************************
606 
607 
608 //*************************************************************************************************
618 template< typename MT >
619 inline void clear( const StrictlyUpperProxy<MT>& proxy )
620 {
621  using blaze::clear;
622 
623  clear( proxy.get() );
624 }
625 //*************************************************************************************************
626 
627 
628 //*************************************************************************************************
638 template< bool RF, typename MT >
639 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
640 {
641  using blaze::isDefault;
642 
643  return isDefault<RF>( proxy.get() );
644 }
645 //*************************************************************************************************
646 
647 
648 //*************************************************************************************************
660 template< bool RF, typename MT >
661 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
662 {
663  using blaze::isReal;
664 
665  return isReal<RF>( proxy.get() );
666 }
667 //*************************************************************************************************
668 
669 
670 //*************************************************************************************************
680 template< bool RF, typename MT >
681 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
682 {
683  using blaze::isZero;
684 
685  return isZero<RF>( proxy.get() );
686 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
700 template< bool RF, typename MT >
701 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
702 {
703  using blaze::isOne;
704 
705  return isOne<RF>( proxy.get() );
706 }
707 //*************************************************************************************************
708 
709 
710 //*************************************************************************************************
720 template< typename MT >
721 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
722 {
723  using blaze::isnan;
724 
725  return isnan( proxy.get() );
726 }
727 //*************************************************************************************************
728 
729 } // namespace blaze
730 
731 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:657
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
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,...
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
Constraint on the data type.
Header file for the AddConst type trait.
Header file for auxiliary alias declarations.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyUpperProxy.h:179
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Constraint on the data type.
Header file for basic type definitions.
AddConst_t< Reference_t< MT > > ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyUpperProxy.h:108
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.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
RawReference get() const noexcept
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:512
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
Access proxy for strictly upper triangular matrices.The StrictlyUpperProxy provides controlled access...
Definition: StrictlyUpperProxy.h:102
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:677
AddReference_t< ReferenceType > RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyUpperProxy.h:114
const StrictlyUpperProxy * operator->() const noexcept
Direct access to the accessed matrix element.
Definition: StrictlyUpperProxy.h:491
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:525
#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:223
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:717
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:180
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
Header file for the isOne shim.
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: StrictlyUpperProxy.h:113
#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,...
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,...
Definition: Reference.h:79
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:697
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyUpperProxy.h:115
Initializer list type of the Blaze library.
const StrictlyUpperProxy & operator=(const StrictlyUpperProxy &uup) const
Copy assignment operator for StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:262
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:635
#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,...
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
Constraint on the data type.
Header file for the isReal shim.
Header file for the clear shim.