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 
49 #include <blaze/math/proxy/Proxy.h>
50 #include <blaze/math/shims/Clear.h>
53 #include <blaze/math/shims/IsNaN.h>
54 #include <blaze/math/shims/IsOne.h>
57 #include <blaze/math/shims/Reset.h>
63 #include <blaze/util/Exception.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>, typename MT::ElementType >
101 {
102  private:
103  //**Type definitions****************************************************************************
106  //**********************************************************************************************
107 
108  public:
109  //**Type definitions****************************************************************************
112 
115 
117  typedef const RepresentedType& ConstReference;
118  //**********************************************************************************************
119 
120  //**Constructors********************************************************************************
123  explicit inline StrictlyUpperProxy( MT& matrix, size_t row, size_t column );
124  inline StrictlyUpperProxy( const StrictlyUpperProxy& uup );
126  //**********************************************************************************************
127 
128  //**Destructor**********************************************************************************
129  // No explicitly declared destructor.
130  //**********************************************************************************************
131 
132  //**Assignment operators************************************************************************
135  inline const StrictlyUpperProxy& operator= ( const StrictlyUpperProxy& uup ) const;
136  template< typename T > inline const StrictlyUpperProxy& operator= ( const T& value ) const;
137  template< typename T > inline const StrictlyUpperProxy& operator+=( const T& value ) const;
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;
142  //**********************************************************************************************
143 
144  //**Utility functions***************************************************************************
147  inline RawReference get() const;
148  inline bool isRestricted() const;
150  //**********************************************************************************************
151 
152  //**Conversion operator*************************************************************************
155  inline operator ConstReference() const;
157  //**********************************************************************************************
158 
159  private:
160  //**Member variables****************************************************************************
163  ReferenceType value_;
164  const bool restricted_;
165 
169  //**********************************************************************************************
170 
171  //**Compile time checks*************************************************************************
184  //**********************************************************************************************
185 };
186 //*************************************************************************************************
187 
188 
189 
190 
191 //=================================================================================================
192 //
193 // CONSTRUCTORS
194 //
195 //=================================================================================================
196 
197 //*************************************************************************************************
204 template< typename MT > // Type of the adapted matrix
205 inline StrictlyUpperProxy<MT>::StrictlyUpperProxy( MT& matrix, size_t row, size_t column )
206  : value_ ( matrix( row, column ) ) // Reference to the accessed matrix element
207  , restricted_( column <= row ) // Access flag for the accessed matrix element
208 {}
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
217 template< typename MT > // Type of the adapted matrix
219  : value_ ( uup.value_ ) // Reference to the accessed matrix element
220  , restricted_( uup.restricted_ ) // Access flag for the accessed matrix element
221 {}
222 //*************************************************************************************************
223 
224 
225 
226 
227 //=================================================================================================
228 //
229 // OPERATORS
230 //
231 //=================================================================================================
232 
233 //*************************************************************************************************
243 template< typename MT > // Type of the adapted matrix
245 {
246  if( restricted_ ) {
247  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
248  }
249 
250  value_ = uup.value_;
251 
252  return *this;
253 }
254 //*************************************************************************************************
255 
256 
257 //*************************************************************************************************
267 template< typename MT > // Type of the adapted matrix
268 template< typename T > // Type of the right-hand side value
269 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator=( const T& value ) const
270 {
271  if( restricted_ ) {
272  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
273  }
274 
275  value_ = value;
276 
277  return *this;
278 }
279 //*************************************************************************************************
280 
281 
282 //*************************************************************************************************
292 template< typename MT > // Type of the adapted matrix
293 template< typename T > // Type of the right-hand side value
294 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator+=( const T& value ) const
295 {
296  if( restricted_ ) {
297  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
298  }
299 
300  value_ += value;
301 
302  return *this;
303 }
304 //*************************************************************************************************
305 
306 
307 //*************************************************************************************************
317 template< typename MT > // Type of the adapted matrix
318 template< typename T > // Type of the right-hand side value
319 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator-=( const T& value ) const
320 {
321  if( restricted_ ) {
322  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
323  }
324 
325  value_ -= value;
326 
327  return *this;
328 }
329 //*************************************************************************************************
330 
331 
332 //*************************************************************************************************
342 template< typename MT > // Type of the adapted matrix
343 template< typename T > // Type of the right-hand side value
344 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator*=( const T& value ) const
345 {
346  if( restricted_ ) {
347  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
348  }
349 
350  value_ *= value;
351 
352  return *this;
353 }
354 //*************************************************************************************************
355 
356 
357 //*************************************************************************************************
367 template< typename MT > // Type of the adapted matrix
368 template< typename T > // Type of the right-hand side value
369 inline const StrictlyUpperProxy<MT>& StrictlyUpperProxy<MT>::operator/=( const T& value ) const
370 {
371  if( restricted_ ) {
372  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal or lower matrix element" );
373  }
374 
375  value_ /= value;
376 
377  return *this;
378 }
379 //*************************************************************************************************
380 
381 
382 
383 
384 //=================================================================================================
385 //
386 // UTILITY FUNCTIONS
387 //
388 //=================================================================================================
389 
390 //*************************************************************************************************
395 template< typename MT > // Type of the adapted matrix
397 {
398  return value_;
399 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
408 template< typename MT > // Type of the adapted matrix
410 {
411  return restricted_;
412 }
413 //*************************************************************************************************
414 
415 
416 
417 
418 //=================================================================================================
419 //
420 // CONVERSION OPERATOR
421 //
422 //=================================================================================================
423 
424 //*************************************************************************************************
429 template< typename MT > // Type of the adapted matrix
431 {
432  return static_cast<ConstReference>( value_ );
433 }
434 //*************************************************************************************************
435 
436 
437 
438 
439 //=================================================================================================
440 //
441 // GLOBAL FUNCTIONS
442 //
443 //=================================================================================================
444 
445 //*************************************************************************************************
448 template< typename MT >
450  conj( const StrictlyUpperProxy<MT>& proxy );
451 
452 template< typename MT >
453 inline void reset( const StrictlyUpperProxy<MT>& proxy );
454 
455 template< typename MT >
456 inline void clear( const StrictlyUpperProxy<MT>& proxy );
457 
458 template< typename MT >
459 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy );
460 
461 template< typename MT >
462 inline bool isReal( const StrictlyUpperProxy<MT>& proxy );
463 
464 template< typename MT >
465 inline bool isZero( const StrictlyUpperProxy<MT>& proxy );
466 
467 template< typename MT >
468 inline bool isOne( const StrictlyUpperProxy<MT>& proxy );
469 
470 template< typename MT >
471 inline bool isnan( const StrictlyUpperProxy<MT>& proxy );
473 //*************************************************************************************************
474 
475 
476 //*************************************************************************************************
487 template< typename MT >
489  conj( const StrictlyUpperProxy<MT>& proxy )
490 {
491  using blaze::conj;
492 
493  return conj( (~proxy).get() );
494 }
495 //*************************************************************************************************
496 
497 
498 //*************************************************************************************************
508 template< typename MT >
509 inline void reset( const StrictlyUpperProxy<MT>& proxy )
510 {
511  using blaze::reset;
512 
513  reset( proxy.get() );
514 }
515 //*************************************************************************************************
516 
517 
518 //*************************************************************************************************
528 template< typename MT >
529 inline void clear( const StrictlyUpperProxy<MT>& proxy )
530 {
531  using blaze::clear;
532 
533  clear( proxy.get() );
534 }
535 //*************************************************************************************************
536 
537 
538 //*************************************************************************************************
548 template< typename MT >
549 inline bool isDefault( const StrictlyUpperProxy<MT>& proxy )
550 {
551  using blaze::isDefault;
552 
553  return isDefault( proxy.get() );
554 }
555 //*************************************************************************************************
556 
557 
558 //*************************************************************************************************
570 template< typename MT >
571 inline bool isReal( const StrictlyUpperProxy<MT>& proxy )
572 {
573  using blaze::isReal;
574 
575  return isReal( proxy.get() );
576 }
577 //*************************************************************************************************
578 
579 
580 //*************************************************************************************************
590 template< typename MT >
591 inline bool isZero( const StrictlyUpperProxy<MT>& proxy )
592 {
593  using blaze::isZero;
594 
595  return isZero( proxy.get() );
596 }
597 //*************************************************************************************************
598 
599 
600 //*************************************************************************************************
610 template< typename MT >
611 inline bool isOne( const StrictlyUpperProxy<MT>& proxy )
612 {
613  using blaze::isOne;
614 
615  return isOne( proxy.get() );
616 }
617 //*************************************************************************************************
618 
619 
620 //*************************************************************************************************
630 template< typename MT >
631 inline bool isnan( const StrictlyUpperProxy<MT>& proxy )
632 {
633  using blaze::isnan;
634 
635  return isnan( proxy.get() );
636 }
637 //*************************************************************************************************
638 
639 } // namespace blaze
640 
641 #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
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:609
Header file for the AddConst type trait.
ReferenceType value_
Reference to the accessed matrix element.
Definition: StrictlyUpperProxy.h:163
Header file for basic type definitions.
Addition of a top level 'const' qualifier.The AddConst type trait adds a top level 'const' qualifier ...
Definition: AddConst.h:69
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
const StrictlyUpperProxy & operator=(const StrictlyUpperProxy &uup) const
Copy assignment operator for StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:244
Constraint on the data type.
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
Access proxy for strictly upper triangular matrices.The StrictlyUpperProxy provides controlled access...
Definition: StrictlyUpperProxy.h:100
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.
Addition of a top level reference.In case the given type T is not a reference type, the AddReference type trait adds a top level reference to the given type T. Else the resulting type Type is T.
Definition: AddReference.h:69
ConjExprTrait< typename DiagonalProxy< MT >::RepresentedType >::Type conj(const DiagonalProxy< MT > &proxy)
Computing the complex conjugate of the represented element.
Definition: DiagonalProxy.h:487
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:116
AddConst< typename MT::Reference >::Type ReferenceType
Reference type of the underlying matrix type.
Definition: StrictlyUpperProxy.h:105
StrictlyUpperProxy(MT &matrix, size_t row, size_t column)
Initialization constructor for a StrictlyUpperProxy.
Definition: StrictlyUpperProxy.h:205
Constraint on the data type.
Header file for the isZero shim.
Constraint on the data type.
RawReference get() const
Returning the value of the accessed matrix element.
Definition: StrictlyUpperProxy.h:396
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
const bool restricted_
Access flag for the accessed matrix element.
Definition: StrictlyUpperProxy.h:164
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
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
AddReference< ReferenceType >::Type RawReference
Reference-to-non-const to the represented element.
Definition: StrictlyUpperProxy.h:114
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: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.
const RepresentedType & ConstReference
Reference-to-const to the represented element.
Definition: StrictlyUpperProxy.h:117
Constraint on the data type.
Constraint on the data type.
bool isRestricted() const
Returns whether the proxy represents a restricted matrix element..
Definition: StrictlyUpperProxy.h:409
#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
MT::ElementType RepresentedType
Type of the represented matrix element.
Definition: StrictlyUpperProxy.h:111
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:589
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:116
#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.