Blaze  3.6
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>
52 #include <blaze/math/Exception.h>
53 #include <blaze/math/proxy/Proxy.h>
54 #include <blaze/math/shims/Clear.h>
57 #include <blaze/math/shims/IsNaN.h>
58 #include <blaze/math/shims/IsOne.h>
61 #include <blaze/math/shims/Reset.h>
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
108  : public Proxy< UniLowerValue<MT> >
109 {
110  private:
111  //**struct BuiltinType**************************************************************************
115  template< typename T >
116  struct BuiltinType { using Type = INVALID_TYPE; };
118  //**********************************************************************************************
119 
120  //**struct ComplexType**************************************************************************
124  template< typename T >
125  struct ComplexType { using Type = typename T::value_type; };
127  //**********************************************************************************************
128 
129  public:
130  //**Type definitions****************************************************************************
132 
135  , ComplexType<RepresentedType>
136  , BuiltinType<RepresentedType> >::Type;
137 
139  //**********************************************************************************************
140 
141  //**Constructors********************************************************************************
144  inline UniLowerValue( RepresentedType& value, bool diagonal );
146  //**********************************************************************************************
147 
148  //**Assignment operators************************************************************************
151  inline UniLowerValue& operator= ( const UniLowerValue& ulv );
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 );
156  template< typename T > inline UniLowerValue& operator/=( const T& value );
158  //**********************************************************************************************
159 
160  //**Utility functions***************************************************************************
163  inline void reset () const;
164  inline void clear () const;
165  inline void invert() const;
166 
167  inline RepresentedType get() const noexcept;
168  inline bool isRestricted() const noexcept;
170  //**********************************************************************************************
171 
172  //**Conversion operator*************************************************************************
175  inline operator RepresentedType() const noexcept;
177  //**********************************************************************************************
178 
179  //**Complex data access functions***************************************************************
182  inline ValueType real() const;
183  inline void real( ValueType value ) const;
184  inline ValueType imag() const;
185  inline void imag( ValueType value ) const;
187  //**********************************************************************************************
188 
189  private:
190  //**Member variables****************************************************************************
192  bool diagonal_;
193  //**********************************************************************************************
194 
195  //**Compile time checks*************************************************************************
211  //**********************************************************************************************
212 };
213 //*************************************************************************************************
214 
215 
216 
217 
218 //=================================================================================================
219 //
220 // CONSTRUCTORS
221 //
222 //=================================================================================================
223 
224 //*************************************************************************************************
230 template< typename MT > // Type of the adapted matrix
232  : value_ ( &value ) // The represented value.
233  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
234 {}
235 //*************************************************************************************************
236 
237 
238 
239 
240 //=================================================================================================
241 //
242 // OPERATORS
243 //
244 //=================================================================================================
245 
246 //*************************************************************************************************
253 template< typename MT > // Type of the adapted matrix
255 {
256  if( diagonal_ ) {
257  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
258  }
259 
260  *value_ = *ulv.value;
261 
262  return *this;
263 }
264 //*************************************************************************************************
265 
266 
267 //*************************************************************************************************
274 template< typename MT > // Type of the adapted matrix
275 template< typename T > // Type of the right-hand side value
277 {
278  if( diagonal_ ) {
279  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
280  }
281 
282  *value_ = value;
283 
284  return *this;
285 }
286 //*************************************************************************************************
287 
288 
289 //*************************************************************************************************
296 template< typename MT > // Type of the adapted matrix
297 template< typename T > // Type of the right-hand side value
299 {
300  if( diagonal_ ) {
301  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
302  }
303 
304  *value_ += value;
305 
306  return *this;
307 }
308 //*************************************************************************************************
309 
310 
311 //*************************************************************************************************
318 template< typename MT > // Type of the adapted matrix
319 template< typename T > // Type of the right-hand side value
321 {
322  if( diagonal_ ) {
323  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
324  }
325 
326  *value_ -= value;
327 
328  return *this;
329 }
330 //*************************************************************************************************
331 
332 
333 //*************************************************************************************************
340 template< typename MT > // Type of the adapted matrix
341 template< typename T > // Type of the right-hand side value
343 {
344  if( diagonal_ ) {
345  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
346  }
347 
348  *value_ *= value;
349 
350  return *this;
351 }
352 //*************************************************************************************************
353 
354 
355 //*************************************************************************************************
362 template< typename MT > // Type of the adapted matrix
363 template< typename T > // Type of the right-hand side value
365 {
366  if( diagonal_ ) {
367  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
368  }
369 
370  *value_ /= value;
371 
372  return *this;
373 }
374 //*************************************************************************************************
375 
376 
377 
378 
379 //=================================================================================================
380 //
381 // UTILITY FUNCTIONS
382 //
383 //=================================================================================================
384 
385 //*************************************************************************************************
392 template< typename MT > // Type of the adapted matrix
393 inline void UniLowerValue<MT>::reset() const
394 {
395  using blaze::reset;
396 
397  if( !diagonal_ )
398  reset( *value_ );
399 }
400 //*************************************************************************************************
401 
402 
403 //*************************************************************************************************
410 template< typename MT > // Type of the adapted matrix
411 inline void UniLowerValue<MT>::clear() const
412 {
413  using blaze::clear;
414 
415  if( !diagonal_ )
416  clear( *value_ );
417 }
418 //*************************************************************************************************
419 
420 
421 //*************************************************************************************************
426 template< typename MT > // Type of the adapted matrix
427 inline void UniLowerValue<MT>::invert() const
428 {
429  using blaze::invert;
430 
431  if( !diagonal_ )
432  invert( *value_ );
433 }
434 //*************************************************************************************************
435 
436 
437 //*************************************************************************************************
442 template< typename MT > // Type of the adapted matrix
444 {
445  return *value_;
446 }
447 //*************************************************************************************************
448 
449 
450 //*************************************************************************************************
455 template< typename MT > // Type of the adapted matrix
456 inline bool UniLowerValue<MT>::isRestricted() const noexcept
457 {
458  return diagonal_;
459 }
460 //*************************************************************************************************
461 
462 
463 
464 
465 //=================================================================================================
466 //
467 // CONVERSION OPERATOR
468 //
469 //=================================================================================================
470 
471 //*************************************************************************************************
476 template< typename MT > // Type of the adapted matrix
478 {
479  return *value_;
480 }
481 //*************************************************************************************************
482 
483 
484 
485 
486 //=================================================================================================
487 //
488 // COMPLEX DATA ACCESS FUNCTIONS
489 //
490 //=================================================================================================
491 
492 //*************************************************************************************************
500 template< typename MT > // Type of the adapted matrix
502 {
503  return value_->real();
504 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
517 template< typename MT > // Type of the adapted matrix
518 inline void UniLowerValue<MT>::real( ValueType value ) const
519 {
520  if( isRestricted() ) {
521  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
522  }
523 
524  value_->real( value );
525 }
526 //*************************************************************************************************
527 
528 
529 //*************************************************************************************************
537 template< typename MT > // Type of the adapted matrix
539 {
540  return value_->imag();
541 }
542 //*************************************************************************************************
543 
544 
545 //*************************************************************************************************
556 template< typename MT > // Type of the adapted matrix
557 inline void UniLowerValue<MT>::imag( ValueType value ) const
558 {
559  if( isRestricted() ) {
560  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
561  }
562 
563  value_->imag( value );
564 }
565 //*************************************************************************************************
566 
567 
568 
569 
570 //=================================================================================================
571 //
572 // GLOBAL FUNCTIONS
573 //
574 //=================================================================================================
575 
576 //*************************************************************************************************
579 template< typename MT >
580 void reset( const UniLowerValue<MT>& value );
581 
582 template< typename MT >
583 void clear( const UniLowerValue<MT>& value );
584 
585 template< typename MT >
586 void invert( const UniLowerValue<MT>& value );
587 
588 template< bool RF, typename MT >
589 bool isDefault( const UniLowerValue<MT>& value );
590 
591 template< bool RF, typename MT >
592 bool isReal( const UniLowerValue<MT>& value );
593 
594 template< bool RF, typename MT >
595 bool isZero( const UniLowerValue<MT>& value );
596 
597 template< bool RF, typename MT >
598 bool isOne( const UniLowerValue<MT>& value );
599 
600 template< typename MT >
601 bool isnan( const UniLowerValue<MT>& value );
603 //*************************************************************************************************
604 
605 
606 //*************************************************************************************************
615 template< typename MT >
616 inline void reset( const UniLowerValue<MT>& value )
617 {
618  value.reset();
619 }
620 //*************************************************************************************************
621 
622 
623 //*************************************************************************************************
632 template< typename MT >
633 inline void clear( const UniLowerValue<MT>& value )
634 {
635  value.clear();
636 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
647 template< typename MT >
648 inline void invert( const UniLowerValue<MT>& value )
649 {
650  value.invert();
651 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
665 template< bool RF, typename MT >
666 inline bool isDefault( const UniLowerValue<MT>& value )
667 {
668  using blaze::isDefault;
669 
670  return isDefault<RF>( value.get() );
671 }
672 //*************************************************************************************************
673 
674 
675 //*************************************************************************************************
687 template< bool RF, typename MT >
688 inline bool isReal( const UniLowerValue<MT>& value )
689 {
690  using blaze::isReal;
691 
692  return isReal<RF>( value.get() );
693 }
694 //*************************************************************************************************
695 
696 
697 //*************************************************************************************************
707 template< bool RF, typename MT >
708 inline bool isZero( const UniLowerValue<MT>& value )
709 {
710  using blaze::isZero;
711 
712  return isZero<RF>( value.get() );
713 }
714 //*************************************************************************************************
715 
716 
717 //*************************************************************************************************
727 template< bool RF, typename MT >
728 inline bool isOne( const UniLowerValue<MT>& value )
729 {
730  using blaze::isOne;
731 
732  return isOne<RF>( value.get() );
733 }
734 //*************************************************************************************************
735 
736 
737 //*************************************************************************************************
747 template< typename MT >
748 inline bool isnan( const UniLowerValue<MT>& value )
749 {
750  using blaze::isnan;
751 
752  return isnan( value.get() );
753 }
754 //*************************************************************************************************
755 
756 } // namespace blaze
757 
758 #endif
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:657
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
Header file for the isnan shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for 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:107
Constraint on the data type.
Header file for basic type definitions.
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerValue.h:192
typename If< Condition, T1, T2 >::Type If_t
Auxiliary alias template for the If class template.The If_t alias template provides a convenient shor...
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:393
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void clear() const
Clearing the unilower value.
Definition: UniLowerValue.h:411
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
Header file for the invert shim.
RepresentedType * value_
The represented value.
Definition: UniLowerValue.h:191
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:677
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:779
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:443
Constraint on the data type.
bool isnan(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is not a number.
Definition: DiagonalProxy.h:717
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type,...
Definition: Upper.h:81
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerValue.h:501
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:377
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerValue.h:131
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
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:136
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type,...
Definition: Symmetric.h:79
Utility type for generic codes.
void invert() const
In-place inversion of the unilower value.
Definition: UniLowerValue.h:427
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,...
Definition: Reference.h:79
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:697
Header file for the isDefault shim.
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerValue.h:138
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
bool isRestricted() const noexcept
Returns whether the value represents a restricted matrix element..
Definition: UniLowerValue.h:456
UniLowerValue & operator=(const UniLowerValue &ulv)
Copy assignment operator for UniLowerValue.
Definition: UniLowerValue.h:254
Header file for the IsComplex type trait.
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerValue.h:538
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type,...
Definition: Hermitian.h:79
UniLowerValue(RepresentedType &value, bool diagonal)
Constructor for the UniLowerValue class.
Definition: UniLowerValue.h:231
Constraint on the data type.
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.