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 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/Exception.h>
51 #include <blaze/math/proxy/Proxy.h>
52 #include <blaze/math/shims/Clear.h>
55 #include <blaze/math/shims/IsNaN.h>
56 #include <blaze/math/shims/IsOne.h>
59 #include <blaze/math/shims/Reset.h>
65 #include <blaze/util/InvalidType.h>
66 #include <blaze/util/mpl/If.h>
67 #include <blaze/util/Types.h>
69 
70 
71 namespace blaze {
72 
73 //=================================================================================================
74 //
75 // CLASS DEFINITION
76 //
77 //=================================================================================================
78 
79 //*************************************************************************************************
104 template< typename MT > // Type of the adapted matrix
106  : public Proxy< UniLowerValue<MT> >
107 {
108  private:
109  //**struct BuiltinType**************************************************************************
113  template< typename T >
114  struct BuiltinType { using Type = INVALID_TYPE; };
116  //**********************************************************************************************
117 
118  //**struct ComplexType**************************************************************************
122  template< typename T >
123  struct ComplexType { using Type = typename T::value_type; };
125  //**********************************************************************************************
126 
127  public:
128  //**Type definitions****************************************************************************
130 
133  , ComplexType<RepresentedType>
134  , BuiltinType<RepresentedType> >::Type;
135 
137  //**********************************************************************************************
138 
139  //**Constructors********************************************************************************
142  inline UniLowerValue( RepresentedType& value, bool diagonal );
144  //**********************************************************************************************
145 
146  //**Assignment operators************************************************************************
149  inline UniLowerValue& operator= ( const UniLowerValue& ulv );
150  template< typename T > inline UniLowerValue& operator= ( const T& value );
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 );
156  //**********************************************************************************************
157 
158  //**Utility functions***************************************************************************
161  inline void reset () const;
162  inline void clear () const;
163  inline void invert() const;
164 
165  inline RepresentedType get() const noexcept;
166  inline bool isRestricted() const noexcept;
168  //**********************************************************************************************
169 
170  //**Conversion operator*************************************************************************
173  inline operator RepresentedType() const noexcept;
175  //**********************************************************************************************
176 
177  //**Complex data access functions***************************************************************
180  inline ValueType real() const;
181  inline void real( ValueType value ) const;
182  inline ValueType imag() const;
183  inline void imag( ValueType value ) const;
185  //**********************************************************************************************
186 
187  private:
188  //**Member variables****************************************************************************
190  bool diagonal_;
191  //**********************************************************************************************
192 
193  //**Compile time checks*************************************************************************
207  //**********************************************************************************************
208 };
209 //*************************************************************************************************
210 
211 
212 
213 
214 //=================================================================================================
215 //
216 // CONSTRUCTORS
217 //
218 //=================================================================================================
219 
220 //*************************************************************************************************
226 template< typename MT > // Type of the adapted matrix
228  : value_ ( &value ) // The represented value.
229  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
230 {}
231 //*************************************************************************************************
232 
233 
234 
235 
236 //=================================================================================================
237 //
238 // OPERATORS
239 //
240 //=================================================================================================
241 
242 //*************************************************************************************************
249 template< typename MT > // Type of the adapted matrix
251 {
252  if( diagonal_ ) {
253  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
254  }
255 
256  *value_ = *ulv.value;
257 
258  return *this;
259 }
260 //*************************************************************************************************
261 
262 
263 //*************************************************************************************************
270 template< typename MT > // Type of the adapted matrix
271 template< typename T > // Type of the right-hand side value
273 {
274  if( diagonal_ ) {
275  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
276  }
277 
278  *value_ = value;
279 
280  return *this;
281 }
282 //*************************************************************************************************
283 
284 
285 //*************************************************************************************************
292 template< typename MT > // Type of the adapted matrix
293 template< typename T > // Type of the right-hand side value
295 {
296  if( diagonal_ ) {
297  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
298  }
299 
300  *value_ += value;
301 
302  return *this;
303 }
304 //*************************************************************************************************
305 
306 
307 //*************************************************************************************************
314 template< typename MT > // Type of the adapted matrix
315 template< typename T > // Type of the right-hand side value
317 {
318  if( diagonal_ ) {
319  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
320  }
321 
322  *value_ -= value;
323 
324  return *this;
325 }
326 //*************************************************************************************************
327 
328 
329 //*************************************************************************************************
336 template< typename MT > // Type of the adapted matrix
337 template< typename T > // Type of the right-hand side value
339 {
340  if( diagonal_ ) {
341  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
342  }
343 
344  *value_ *= value;
345 
346  return *this;
347 }
348 //*************************************************************************************************
349 
350 
351 //*************************************************************************************************
358 template< typename MT > // Type of the adapted matrix
359 template< typename T > // Type of the right-hand side value
361 {
362  if( diagonal_ ) {
363  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
364  }
365 
366  *value_ /= value;
367 
368  return *this;
369 }
370 //*************************************************************************************************
371 
372 
373 
374 
375 //=================================================================================================
376 //
377 // UTILITY FUNCTIONS
378 //
379 //=================================================================================================
380 
381 //*************************************************************************************************
388 template< typename MT > // Type of the adapted matrix
389 inline void UniLowerValue<MT>::reset() const
390 {
391  using blaze::reset;
392 
393  if( !diagonal_ )
394  reset( *value_ );
395 }
396 //*************************************************************************************************
397 
398 
399 //*************************************************************************************************
406 template< typename MT > // Type of the adapted matrix
407 inline void UniLowerValue<MT>::clear() const
408 {
409  using blaze::clear;
410 
411  if( !diagonal_ )
412  clear( *value_ );
413 }
414 //*************************************************************************************************
415 
416 
417 //*************************************************************************************************
422 template< typename MT > // Type of the adapted matrix
423 inline void UniLowerValue<MT>::invert() const
424 {
425  using blaze::invert;
426 
427  if( !diagonal_ )
428  invert( *value_ );
429 }
430 //*************************************************************************************************
431 
432 
433 //*************************************************************************************************
438 template< typename MT > // Type of the adapted matrix
440 {
441  return *value_;
442 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
451 template< typename MT > // Type of the adapted matrix
452 inline bool UniLowerValue<MT>::isRestricted() const noexcept
453 {
454  return diagonal_;
455 }
456 //*************************************************************************************************
457 
458 
459 
460 
461 //=================================================================================================
462 //
463 // CONVERSION OPERATOR
464 //
465 //=================================================================================================
466 
467 //*************************************************************************************************
472 template< typename MT > // Type of the adapted matrix
474 {
475  return *value_;
476 }
477 //*************************************************************************************************
478 
479 
480 
481 
482 //=================================================================================================
483 //
484 // COMPLEX DATA ACCESS FUNCTIONS
485 //
486 //=================================================================================================
487 
488 //*************************************************************************************************
496 template< typename MT > // Type of the adapted matrix
498 {
499  return value_->real();
500 }
501 //*************************************************************************************************
502 
503 
504 //*************************************************************************************************
513 template< typename MT > // Type of the adapted matrix
514 inline void UniLowerValue<MT>::real( ValueType value ) const
515 {
516  if( isRestricted() ) {
517  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
518  }
519 
520  value_->real( value );
521 }
522 //*************************************************************************************************
523 
524 
525 //*************************************************************************************************
533 template< typename MT > // Type of the adapted matrix
535 {
536  return value_->imag();
537 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
552 template< typename MT > // Type of the adapted matrix
553 inline void UniLowerValue<MT>::imag( ValueType value ) const
554 {
555  if( isRestricted() ) {
556  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
557  }
558 
559  value_->imag( value );
560 }
561 //*************************************************************************************************
562 
563 
564 
565 
566 //=================================================================================================
567 //
568 // GLOBAL FUNCTIONS
569 //
570 //=================================================================================================
571 
572 //*************************************************************************************************
575 template< typename MT >
576 void reset( const UniLowerValue<MT>& value );
577 
578 template< typename MT >
579 void clear( const UniLowerValue<MT>& value );
580 
581 template< typename MT >
582 void invert( const UniLowerValue<MT>& value );
583 
584 template< bool RF, typename MT >
585 bool isDefault( const UniLowerValue<MT>& value );
586 
587 template< bool RF, typename MT >
588 bool isReal( const UniLowerValue<MT>& value );
589 
590 template< bool RF, typename MT >
591 bool isZero( const UniLowerValue<MT>& value );
592 
593 template< bool RF, typename MT >
594 bool isOne( const UniLowerValue<MT>& value );
595 
596 template< typename MT >
597 bool isnan( const UniLowerValue<MT>& value );
599 //*************************************************************************************************
600 
601 
602 //*************************************************************************************************
611 template< typename MT >
612 inline void reset( const UniLowerValue<MT>& value )
613 {
614  value.reset();
615 }
616 //*************************************************************************************************
617 
618 
619 //*************************************************************************************************
628 template< typename MT >
629 inline void clear( const UniLowerValue<MT>& value )
630 {
631  value.clear();
632 }
633 //*************************************************************************************************
634 
635 
636 //*************************************************************************************************
643 template< typename MT >
644 inline void invert( const UniLowerValue<MT>& value )
645 {
646  value.invert();
647 }
648 //*************************************************************************************************
649 
650 
651 //*************************************************************************************************
661 template< bool RF, typename MT >
662 inline bool isDefault( const UniLowerValue<MT>& value )
663 {
664  using blaze::isDefault;
665 
666  return isDefault<RF>( value.get() );
667 }
668 //*************************************************************************************************
669 
670 
671 //*************************************************************************************************
683 template< bool RF, typename MT >
684 inline bool isReal( const UniLowerValue<MT>& value )
685 {
686  using blaze::isReal;
687 
688  return isReal<RF>( value.get() );
689 }
690 //*************************************************************************************************
691 
692 
693 //*************************************************************************************************
703 template< bool RF, typename MT >
704 inline bool isZero( const UniLowerValue<MT>& value )
705 {
706  using blaze::isZero;
707 
708  return isZero<RF>( value.get() );
709 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
723 template< bool RF, typename MT >
724 inline bool isOne( const UniLowerValue<MT>& value )
725 {
726  using blaze::isOne;
727 
728  return isOne<RF>( value.get() );
729 }
730 //*************************************************************************************************
731 
732 
733 //*************************************************************************************************
743 template< typename MT >
744 inline bool isnan( const UniLowerValue<MT>& value )
745 {
746  using blaze::isnan;
747 
748  return isnan( value.get() );
749 }
750 //*************************************************************************************************
751 
752 } // namespace blaze
753 
754 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:653
Header file for the isnan shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Constraint on the data type.
Representation of a value within a sparse lower unitriangular matrix.The UniLowerValue class represen...
Definition: UniLowerValue.h:105
Header file for basic type definitions.
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerValue.h:190
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias declaration for the If class template.The If_t alias declaration provides a convenien...
Definition: If.h:109
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.
void reset() const
Reset the unilower value to its default initial value.
Definition: UniLowerValue.h:389
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
void clear() const
Clearing the unilower value.
Definition: UniLowerValue.h:407
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
Header file for the invert shim.
RepresentedType * value_
The represented value.
Definition: UniLowerValue.h:189
Header file for the reset shim.
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.
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:775
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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:79
RepresentedType get() const noexcept
Access to the represented value.
Definition: UniLowerValue.h:439
Constraint on the data type.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:713
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
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerValue.h:497
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:375
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerValue.h:129
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the isOne shim.
typename If_t< IsComplex_v< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type ValueType
Value type of the represented complex element.
Definition: UniLowerValue.h:134
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
Utility type for generic codes.
void invert() const
In-place inversion of the unilower value.
Definition: UniLowerValue.h:423
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:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:693
Header file for the isDefault shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerValue.h:136
Constraint on the data type.
Constraint on the data type.
bool isRestricted() const noexcept
Returns whether the value represents a restricted matrix element..
Definition: UniLowerValue.h:452
UniLowerValue & operator=(const UniLowerValue &ulv)
Copy assignment operator for UniLowerValue.
Definition: UniLowerValue.h:250
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
Header file for the IsComplex type trait.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerValue.h:534
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
UniLowerValue(RepresentedType &value, bool diagonal)
Constructor for the UniLowerValue class.
Definition: UniLowerValue.h:227
Header file for the isReal shim.
#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:61
Header file for the clear shim.