UniUpperProxy.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UPPERPROXY_H_
36 #define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_UPPERPROXY_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
49 #include <blaze/math/proxy/Proxy.h>
50 #include <blaze/math/shims/Clear.h>
54 #include <blaze/math/shims/IsNaN.h>
55 #include <blaze/math/shims/IsOne.h>
58 #include <blaze/math/shims/Reset.h>
65 #include <blaze/util/Exception.h>
66 #include <blaze/util/InvalidType.h>
67 #include <blaze/util/mpl/If.h>
68 #include <blaze/util/Types.h>
70 
71 
72 namespace blaze {
73 
74 //=================================================================================================
75 //
76 // CLASS DEFINITION
77 //
78 //=================================================================================================
79 
80 //*************************************************************************************************
101 template< typename MT > // Type of the adapted matrix
102 class UniUpperProxy : public Proxy< UniUpperProxy<MT> >
103 {
104  private:
105  //**Type definitions****************************************************************************
107  typedef typename MT::Reference ReferenceType;
108  //**********************************************************************************************
109 
110  //**struct BuiltinType**************************************************************************
114  template< typename T >
115  struct BuiltinType { typedef INVALID_TYPE Type; };
117  //**********************************************************************************************
118 
119  //**struct ComplexType**************************************************************************
123  template< typename T >
124  struct ComplexType { typedef typename T::value_type Type; };
126  //**********************************************************************************************
127 
128  public:
129  //**Type definitions****************************************************************************
132 
134  typedef typename If< IsComplex<RepresentedType>
135  , ComplexType<RepresentedType>
136  , BuiltinType<RepresentedType> >::Type::Type ValueType;
137 
138  typedef ValueType value_type;
139  //**********************************************************************************************
140 
141  //**Constructors********************************************************************************
144  explicit inline UniUpperProxy( MT& matrix, size_t row, size_t column );
145  inline UniUpperProxy( const UniUpperProxy& uup );
147  //**********************************************************************************************
148 
149  //**Destructor**********************************************************************************
150  // No explicitly declared destructor.
151  //**********************************************************************************************
152 
153  //**Assignment operators************************************************************************
156  inline const UniUpperProxy& operator= ( const UniUpperProxy& uup ) const;
157  template< typename T > inline const UniUpperProxy& operator= ( const T& value ) const;
158  template< typename T > inline const UniUpperProxy& operator+=( const T& value ) const;
159  template< typename T > inline const UniUpperProxy& operator-=( const T& value ) const;
160  template< typename T > inline const UniUpperProxy& operator*=( const T& value ) const;
161  template< typename T > inline const UniUpperProxy& operator/=( const T& value ) const;
163  //**********************************************************************************************
164 
165  //**Utility functions***************************************************************************
168  inline void reset () const;
169  inline void clear () const;
170  inline void invert() const;
171 
172  inline RepresentedType get() const;
173  inline bool isRestricted() const;
175  //**********************************************************************************************
176 
177  //**Conversion operator*************************************************************************
180  inline operator RepresentedType() const;
182  //**********************************************************************************************
183 
184  //**Complex data access functions***************************************************************
187  inline ValueType real() const;
188  inline void real( ValueType value ) const;
189  inline ValueType imag() const;
190  inline void imag( ValueType value ) const;
192  //**********************************************************************************************
193 
194  private:
195  //**Member variables****************************************************************************
198  ReferenceType value_;
199  size_t row_;
200  size_t column_;
201 
202  //**********************************************************************************************
203 
204  //**Compile time checks*************************************************************************
216  BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE( RepresentedType );
218  //**********************************************************************************************
219 };
220 //*************************************************************************************************
221 
222 
223 
224 
225 //=================================================================================================
226 //
227 // CONSTRUCTORS
228 //
229 //=================================================================================================
230 
231 //*************************************************************************************************
238 template< typename MT > // Type of the adapted matrix
239 inline UniUpperProxy<MT>::UniUpperProxy( MT& matrix, size_t row, size_t column )
240  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
241  , row_ ( row ) // Row index of the accessed matrix element
242  , column_( column ) // Column index of the accessed matrix element
243 {}
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
252 template< typename MT > // Type of the adapted matrix
254  : value_ ( uup.value_ ) // Reference to the accessed matrix element
255  , row_ ( uup.row_ ) // Row index of the accessed matrix element
256  , column_( uup.column_ ) // Column index of the accessed matrix element
257 {}
258 //*************************************************************************************************
259 
260 
261 
262 
263 //=================================================================================================
264 //
265 // OPERATORS
266 //
267 //=================================================================================================
268 
269 //*************************************************************************************************
279 template< typename MT > // Type of the adapted matrix
281 {
282  if( isRestricted() ) {
283  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
284  }
285 
286  value_ = uup.value_;
287 
288  return *this;
289 }
290 //*************************************************************************************************
291 
292 
293 //*************************************************************************************************
303 template< typename MT > // Type of the adapted matrix
304 template< typename T > // Type of the right-hand side value
305 inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator=( const T& value ) const
306 {
307  if( isRestricted() ) {
308  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
309  }
310 
311  value_ = value;
312 
313  return *this;
314 }
315 //*************************************************************************************************
316 
317 
318 //*************************************************************************************************
328 template< typename MT > // Type of the adapted matrix
329 template< typename T > // Type of the right-hand side value
330 inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator+=( const T& value ) const
331 {
332  if( isRestricted() ) {
333  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
334  }
335 
336  value_ += value;
337 
338  return *this;
339 }
340 //*************************************************************************************************
341 
342 
343 //*************************************************************************************************
353 template< typename MT > // Type of the adapted matrix
354 template< typename T > // Type of the right-hand side value
355 inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator-=( const T& value ) const
356 {
357  if( isRestricted() ) {
358  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
359  }
360 
361  value_ -= value;
362 
363  return *this;
364 }
365 //*************************************************************************************************
366 
367 
368 //*************************************************************************************************
378 template< typename MT > // Type of the adapted matrix
379 template< typename T > // Type of the right-hand side value
380 inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator*=( const T& value ) const
381 {
382  if( isRestricted() ) {
383  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
384  }
385 
386  value_ *= value;
387 
388  return *this;
389 }
390 //*************************************************************************************************
391 
392 
393 //*************************************************************************************************
403 template< typename MT > // Type of the adapted matrix
404 template< typename T > // Type of the right-hand side value
405 inline const UniUpperProxy<MT>& UniUpperProxy<MT>::operator/=( const T& value ) const
406 {
407  if( isRestricted() ) {
408  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
409  }
410 
411  value_ /= value;
412 
413  return *this;
414 }
415 //*************************************************************************************************
416 
417 
418 
419 
420 //=================================================================================================
421 //
422 // UTILITY FUNCTIONS
423 //
424 //=================================================================================================
425 
426 //*************************************************************************************************
433 template< typename MT > // Type of the adapted matrix
434 inline void UniUpperProxy<MT>::reset() const
435 {
436  using blaze::reset;
437 
438  if( row_ < column_ )
439  reset( value_ );
440 }
441 //*************************************************************************************************
442 
443 
444 //*************************************************************************************************
451 template< typename MT > // Type of the adapted matrix
452 inline void UniUpperProxy<MT>::clear() const
453 {
454  using blaze::clear;
455 
456  if( row_ < column_ )
457  clear( value_ );
458 }
459 //*************************************************************************************************
460 
461 
462 //*************************************************************************************************
470 template< typename MT > // Type of the adapted matrix
471 inline void UniUpperProxy<MT>::invert() const
472 {
473  using blaze::invert;
474 
475  if( column_ < row_ ) {
476  BLAZE_THROW_INVALID_ARGUMENT( "Invalid inversion of lower matrix element" );
477  }
478 
479  if( row_ < column_ )
480  invert( value_ );
481 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
490 template< typename MT > // Type of the adapted matrix
492 {
493  return value_;
494 }
495 //*************************************************************************************************
496 
497 
498 //*************************************************************************************************
503 template< typename MT > // Type of the adapted matrix
505 {
506  return column_ <= row_;
507 }
508 //*************************************************************************************************
509 
510 
511 
512 
513 //=================================================================================================
514 //
515 // CONVERSION OPERATOR
516 //
517 //=================================================================================================
518 
519 //*************************************************************************************************
524 template< typename MT > // Type of the adapted matrix
526 {
527  return get();
528 }
529 //*************************************************************************************************
530 
531 
532 
533 
534 //=================================================================================================
535 //
536 // COMPLEX DATA ACCESS FUNCTIONS
537 //
538 //=================================================================================================
539 
540 //*************************************************************************************************
548 template< typename MT > // Type of the adapted matrix
550 {
551  return value_.real();
552 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
567 template< typename MT > // Type of the adapted matrix
568 inline void UniUpperProxy<MT>::real( ValueType value ) const
569 {
570  if( isRestricted() ) {
571  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or lower matrix element" );
572  }
573 
574  value_.real( value );
575 }
576 //*************************************************************************************************
577 
578 
579 //*************************************************************************************************
587 template< typename MT > // Type of the adapted matrix
589 {
590  return value_.imag();
591 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
606 template< typename MT > // Type of the adapted matrix
607 inline void UniUpperProxy<MT>::imag( ValueType value ) const
608 {
609  if( isRestricted() ) {
610  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal or lower matrix element" );
611  }
612 
613  value_.imag( value );
614 }
615 //*************************************************************************************************
616 
617 
618 
619 
620 //=================================================================================================
621 //
622 // GLOBAL FUNCTIONS
623 //
624 //=================================================================================================
625 
626 //*************************************************************************************************
629 template< typename MT >
631  conj( const UniUpperProxy<MT>& proxy );
632 
633 template< typename MT >
634 inline void reset( const UniUpperProxy<MT>& proxy );
635 
636 template< typename MT >
637 inline void clear( const UniUpperProxy<MT>& proxy );
638 
639 template< typename MT >
640 inline void invert( const UniUpperProxy<MT>& proxy );
641 
642 template< typename MT >
643 inline bool isDefault( const UniUpperProxy<MT>& proxy );
644 
645 template< typename MT >
646 inline bool isReal( const UniUpperProxy<MT>& proxy );
647 
648 template< typename MT >
649 inline bool isZero( const UniUpperProxy<MT>& proxy );
650 
651 template< typename MT >
652 inline bool isOne( const UniUpperProxy<MT>& proxy );
653 
654 template< typename MT >
655 inline bool isnan( const UniUpperProxy<MT>& proxy );
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
671 template< typename MT >
673  conj( const UniUpperProxy<MT>& proxy )
674 {
675  using blaze::conj;
676 
677  return conj( (~proxy).get() );
678 }
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
692 template< typename MT >
693 inline void reset( const UniUpperProxy<MT>& proxy )
694 {
695  proxy.reset();
696 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
710 template< typename MT >
711 inline void clear( const UniUpperProxy<MT>& proxy )
712 {
713  proxy.clear();
714 }
715 //*************************************************************************************************
716 
717 
718 //*************************************************************************************************
725 template< typename MT >
726 inline void invert( const UniUpperProxy<MT>& proxy )
727 {
728  proxy.invert();
729 }
730 //*************************************************************************************************
731 
732 
733 //*************************************************************************************************
743 template< typename MT >
744 inline bool isDefault( const UniUpperProxy<MT>& proxy )
745 {
746  using blaze::isDefault;
747 
748  return isDefault( proxy.get() );
749 }
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
765 template< typename MT >
766 inline bool isReal( const UniUpperProxy<MT>& proxy )
767 {
768  using blaze::isReal;
769 
770  return isReal( proxy.get() );
771 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
785 template< typename MT >
786 inline bool isZero( const UniUpperProxy<MT>& proxy )
787 {
788  using blaze::isZero;
789 
790  return isZero( proxy.get() );
791 }
792 //*************************************************************************************************
793 
794 
795 //*************************************************************************************************
805 template< typename MT >
806 inline bool isOne( const UniUpperProxy<MT>& proxy )
807 {
808  using blaze::isOne;
809 
810  return isOne( proxy.get() );
811 }
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
825 template< typename MT >
826 inline bool isnan( const UniUpperProxy<MT>& proxy )
827 {
828  using blaze::isnan;
829 
830  return isnan( proxy.get() );
831 }
832 //*************************************************************************************************
833 
834 } // namespace blaze
835 
836 #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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
size_t row_
Row index of the accessed matrix element.
Definition: UniUpperProxy.h:199
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:609
Access proxy for upper unitriangular matrices.The UniUpperProxy provides controlled access to the ele...
Definition: UniUpperProxy.h:102
Constraint on the data type.
MT::ElementType RepresentedType
Type of the represented matrix element.
Definition: UniUpperProxy.h:131
MT::Reference ReferenceType
Reference type of the underlying matrix type.
Definition: UniUpperProxy.h:107
Compile time type selection.The If class template selects one of the two given types T2 and T3 depend...
Definition: If.h:112
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:569
Constraint on the data type.
size_t column_
Column index of the accessed matrix element.
Definition: UniUpperProxy.h:200
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
#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:116
Header file for the invert shim.
Constraint on the data type.
Header file for the Proxy class.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Constraint on the data type.
ConjExprTrait< typename DiagonalProxy< MT >::RepresentedType >::Type conj(const DiagonalProxy< MT > &proxy)
Computing the complex conjugate of the represented element.
Definition: DiagonalProxy.h:487
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:767
ReferenceType value_
Reference to the accessed matrix element.
Definition: UniUpperProxy.h:198
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
If< IsComplex< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type::Type ValueType
Value type of the represented complex element.
Definition: UniUpperProxy.h:136
void reset() const
Reset the represented element to its default initial value.
Definition: UniUpperProxy.h:434
Header file for the If class template.
#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:116
Constraint on the data type.
Header file for the isZero shim.
Constraint on the data type.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:629
#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:118
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
ValueType value_type
Value type of the represented complex element.
Definition: UniUpperProxy.h:138
const UniUpperProxy & operator=(const UniUpperProxy &uup) const
Copy assignment operator for UniUpperProxy.
Definition: UniUpperProxy.h:280
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the isOne shim.
Header file for the conjugate shim.
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
Evaluation of the return type of a complex conjugate expression.Via this type trait it is possible to...
Definition: ConjExprTrait.h:87
#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:116
UniUpperProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a UniUpperProxy.
Definition: UniUpperProxy.h:239
Utility type for generic codes.
RepresentedType get() const
Returning the value of the accessed matrix element.
Definition: UniUpperProxy.h:491
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
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:118
#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:116
Header file for the isDefault shim.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniUpperProxy.h:588
Constraint on the data type.
Constraint on the data type.
void clear() const
Clearing the represented element.
Definition: UniUpperProxy.h:452
void invert() const
In-place inversion of the represented element.
Definition: UniUpperProxy.h:471
#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:118
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:589
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniUpperProxy.h:549
Header file for the IsComplex type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
bool isRestricted() const
Returns whether the proxy represents a restricted matrix element..
Definition: UniUpperProxy.h:504
#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:79
Header file for exception macros.
Header file for the ConjExprTrait class template.
Header file for the isReal shim.