UniLowerValue.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_UNILOWERVALUE_H_
36 #define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_UNILOWERVALUE_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>
66 #include <blaze/util/Exception.h>
67 #include <blaze/util/InvalidType.h>
68 #include <blaze/util/mpl/If.h>
69 #include <blaze/util/Types.h>
71 
72 
73 namespace blaze {
74 
75 //=================================================================================================
76 //
77 // CLASS DEFINITION
78 //
79 //=================================================================================================
80 
81 //*************************************************************************************************
106 template< typename MT > // Type of the adapted matrix
107 class UniLowerValue : public Proxy< UniLowerValue<MT> >
108 {
109  private:
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****************************************************************************
130  typedef typename MT::ElementType RepresentedType;
131 
133  typedef typename If< IsComplex<RepresentedType>
134  , ComplexType<RepresentedType>
135  , BuiltinType<RepresentedType> >::Type::Type ValueType;
136 
137  typedef ValueType value_type;
138  //**********************************************************************************************
139 
140  //**Constructors********************************************************************************
143  inline UniLowerValue( RepresentedType& value, bool diagonal );
145  //**********************************************************************************************
146 
147  //**Assignment operators************************************************************************
150  inline UniLowerValue& operator= ( const UniLowerValue& ulv );
151  template< typename T > inline UniLowerValue& operator= ( const T& value );
152  template< typename T > inline UniLowerValue& operator+=( const T& value );
153  template< typename T > inline UniLowerValue& operator-=( const T& value );
154  template< typename T > inline UniLowerValue& operator*=( const T& value );
155  template< typename T > inline UniLowerValue& operator/=( const T& value );
157  //**********************************************************************************************
158 
159  //**Utility functions***************************************************************************
162  inline void reset () const;
163  inline void clear () const;
164  inline void invert() const;
165 
166  inline RepresentedType get() const;
167  inline bool isRestricted() const;
169  //**********************************************************************************************
170 
171  //**Conversion operator*************************************************************************
174  inline operator RepresentedType() const;
176  //**********************************************************************************************
177 
178  //**Complex data access functions***************************************************************
181  inline ValueType real() const;
182  inline void real( ValueType value ) const;
183  inline ValueType imag() const;
184  inline void imag( ValueType value ) const;
186  //**********************************************************************************************
187 
188  private:
189  //**Member variables****************************************************************************
190  RepresentedType* value_;
191  bool diagonal_;
192  //**********************************************************************************************
193 
194  //**Compile time checks*************************************************************************
206  BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE( RepresentedType );
208  //**********************************************************************************************
209 };
210 //*************************************************************************************************
211 
212 
213 
214 
215 //=================================================================================================
216 //
217 // CONSTRUCTORS
218 //
219 //=================================================================================================
220 
221 //*************************************************************************************************
227 template< typename MT > // Type of the adapted matrix
228 inline UniLowerValue<MT>::UniLowerValue( RepresentedType& value, bool diagonal )
229  : value_ ( &value ) // The represented value.
230  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
231 {}
232 //*************************************************************************************************
233 
234 
235 
236 
237 //=================================================================================================
238 //
239 // OPERATORS
240 //
241 //=================================================================================================
242 
243 //*************************************************************************************************
250 template< typename MT > // Type of the adapted matrix
252 {
253  if( diagonal_ ) {
254  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
255  }
256 
257  *value_ = *ulv.value;
258 
259  return *this;
260 }
261 //*************************************************************************************************
262 
263 
264 //*************************************************************************************************
271 template< typename MT > // Type of the adapted matrix
272 template< typename T > // Type of the right-hand side value
274 {
275  if( diagonal_ ) {
276  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
277  }
278 
279  *value_ = value;
280 
281  return *this;
282 }
283 //*************************************************************************************************
284 
285 
286 //*************************************************************************************************
293 template< typename MT > // Type of the adapted matrix
294 template< typename T > // Type of the right-hand side value
296 {
297  if( diagonal_ ) {
298  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
299  }
300 
301  *value_ += value;
302 
303  return *this;
304 }
305 //*************************************************************************************************
306 
307 
308 //*************************************************************************************************
315 template< typename MT > // Type of the adapted matrix
316 template< typename T > // Type of the right-hand side value
318 {
319  if( diagonal_ ) {
320  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
321  }
322 
323  *value_ -= value;
324 
325  return *this;
326 }
327 //*************************************************************************************************
328 
329 
330 //*************************************************************************************************
337 template< typename MT > // Type of the adapted matrix
338 template< typename T > // Type of the right-hand side value
340 {
341  if( diagonal_ ) {
342  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
343  }
344 
345  *value_ *= value;
346 
347  return *this;
348 }
349 //*************************************************************************************************
350 
351 
352 //*************************************************************************************************
359 template< typename MT > // Type of the adapted matrix
360 template< typename T > // Type of the right-hand side value
362 {
363  if( diagonal_ ) {
364  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
365  }
366 
367  *value_ /= value;
368 
369  return *this;
370 }
371 //*************************************************************************************************
372 
373 
374 
375 
376 //=================================================================================================
377 //
378 // UTILITY FUNCTIONS
379 //
380 //=================================================================================================
381 
382 //*************************************************************************************************
389 template< typename MT > // Type of the adapted matrix
390 inline void UniLowerValue<MT>::reset() const
391 {
392  using blaze::reset;
393 
394  if( !diagonal_ )
395  reset( *value_ );
396 }
397 //*************************************************************************************************
398 
399 
400 //*************************************************************************************************
407 template< typename MT > // Type of the adapted matrix
408 inline void UniLowerValue<MT>::clear() const
409 {
410  using blaze::clear;
411 
412  if( !diagonal_ )
413  clear( *value_ );
414 }
415 //*************************************************************************************************
416 
417 
418 //*************************************************************************************************
423 template< typename MT > // Type of the adapted matrix
424 inline void UniLowerValue<MT>::invert() const
425 {
426  using blaze::invert;
427 
428  if( !diagonal_ )
429  invert( *value_ );
430 }
431 //*************************************************************************************************
432 
433 
434 //*************************************************************************************************
439 template< typename MT > // Type of the adapted matrix
441 {
442  return *value_;
443 }
444 //*************************************************************************************************
445 
446 
447 //*************************************************************************************************
452 template< typename MT > // Type of the adapted matrix
454 {
455  return diagonal_;
456 }
457 //*************************************************************************************************
458 
459 
460 
461 
462 //=================================================================================================
463 //
464 // CONVERSION OPERATOR
465 //
466 //=================================================================================================
467 
468 //*************************************************************************************************
473 template< typename MT > // Type of the adapted matrix
475 {
476  return *value_;
477 }
478 //*************************************************************************************************
479 
480 
481 
482 
483 //=================================================================================================
484 //
485 // COMPLEX DATA ACCESS FUNCTIONS
486 //
487 //=================================================================================================
488 
489 //*************************************************************************************************
497 template< typename MT > // Type of the adapted matrix
499 {
500  return value_->real();
501 }
502 //*************************************************************************************************
503 
504 
505 //*************************************************************************************************
514 template< typename MT > // Type of the adapted matrix
515 inline void UniLowerValue<MT>::real( ValueType value ) const
516 {
517  if( isRestricted() ) {
518  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
519  }
520 
521  value_->real( value );
522 }
523 //*************************************************************************************************
524 
525 
526 //*************************************************************************************************
534 template< typename MT > // Type of the adapted matrix
536 {
537  return value_->imag();
538 }
539 //*************************************************************************************************
540 
541 
542 //*************************************************************************************************
553 template< typename MT > // Type of the adapted matrix
554 inline void UniLowerValue<MT>::imag( ValueType value ) const
555 {
556  if( isRestricted() ) {
557  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
558  }
559 
560  value_->imag( value );
561 }
562 //*************************************************************************************************
563 
564 
565 
566 
567 //=================================================================================================
568 //
569 // GLOBAL FUNCTIONS
570 //
571 //=================================================================================================
572 
573 //*************************************************************************************************
576 template< typename MT >
578  conj( const UniLowerValue<MT>& value );
579 
580 template< typename MT >
581 inline void reset( const UniLowerValue<MT>& value );
582 
583 template< typename MT >
584 inline void clear( const UniLowerValue<MT>& value );
585 
586 template< typename MT >
587 inline void invert( const UniLowerValue<MT>& value );
588 
589 template< typename MT >
590 inline bool isDefault( const UniLowerValue<MT>& value );
591 
592 template< typename MT >
593 inline bool isReal( const UniLowerValue<MT>& value );
594 
595 template< typename MT >
596 inline bool isZero( const UniLowerValue<MT>& value );
597 
598 template< typename MT >
599 inline bool isOne( const UniLowerValue<MT>& value );
600 
601 template< typename MT >
602 inline bool isnan( const UniLowerValue<MT>& value );
604 //*************************************************************************************************
605 
606 
607 //*************************************************************************************************
618 template< typename MT >
620  conj( const UniLowerValue<MT>& value )
621 {
622  using blaze::conj;
623 
624  return conj( (~value).get() );
625 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
638 template< typename MT >
639 inline void reset( const UniLowerValue<MT>& value )
640 {
641  value.reset();
642 }
643 //*************************************************************************************************
644 
645 
646 //*************************************************************************************************
655 template< typename MT >
656 inline void clear( const UniLowerValue<MT>& value )
657 {
658  value.clear();
659 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
670 template< typename MT >
671 inline void invert( const UniLowerValue<MT>& value )
672 {
673  value.invert();
674 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
688 template< typename MT >
689 inline bool isDefault( const UniLowerValue<MT>& value )
690 {
691  using blaze::isDefault;
692 
693  return isDefault( value.get() );
694 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
710 template< typename MT >
711 inline bool isReal( const UniLowerValue<MT>& value )
712 {
713  using blaze::isReal;
714 
715  return isReal( value.get() );
716 }
717 //*************************************************************************************************
718 
719 
720 //*************************************************************************************************
730 template< typename MT >
731 inline bool isZero( const UniLowerValue<MT>& value )
732 {
733  using blaze::isZero;
734 
735  return isZero( value.get() );
736 }
737 //*************************************************************************************************
738 
739 
740 //*************************************************************************************************
750 template< typename MT >
751 inline bool isOne( const UniLowerValue<MT>& value )
752 {
753  using blaze::isOne;
754 
755  return isOne( value.get() );
756 }
757 //*************************************************************************************************
758 
759 
760 //*************************************************************************************************
770 template< typename MT >
771 inline bool isnan( const UniLowerValue<MT>& value )
772 {
773  using blaze::isnan;
774 
775  return isnan( value.get() );
776 }
777 //*************************************************************************************************
778 
779 } // namespace blaze
780 
781 #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
Constraint on the data type.
Representation of a value within a sparse lower unitriangular matrix.The UniLowerValue class represen...
Definition: UniLowerValue.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.
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerValue.h:191
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
bool isRestricted() const
Returns whether the value represents a restricted matrix element..
Definition: UniLowerValue.h:453
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
#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.
RepresentedType * value_
The represented value.
Definition: UniLowerValue.h:190
Constraint on the data type.
RepresentedType get() const
Access to the represented value.
Definition: UniLowerValue.h:440
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
Constraint on the data type.
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:767
MT::ElementType RepresentedType
Type of the represented matrix element.
Definition: UniLowerValue.h:130
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
If< IsComplex< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type::Type ValueType
Value type of the represented complex element.
Definition: UniLowerValue.h:135
#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
Header file for the isZero shim.
Constraint on the data type.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerValue.h:137
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
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.
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
void invert() const
In-place inversion of the unilower value.
Definition: UniLowerValue.h:424
Utility type for generic codes.
Constraint on the data type.
Constraint on the data type.
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerValue.h:498
#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.
Constraint on the data type.
Constraint on the data type.
void reset() const
Reset the unilower value to its default initial value.
Definition: UniLowerValue.h:390
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerValue.h:535
Header file for the IsRowMajorMatrix type trait.
UniLowerValue & operator=(const UniLowerValue &ulv)
Copy assignment operator for UniLowerValue.
Definition: UniLowerValue.h:251
#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
Header file for the IsComplex 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
Header file for exception macros.
UniLowerValue(RepresentedType &value, bool diagonal)
Constructor for the UniLowerValue class.
Definition: UniLowerValue.h:228
Header file for the ConjExprTrait class template.
Header file for the isReal shim.
void clear() const
Clearing the unilower value.
Definition: UniLowerValue.h:408
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79