Blaze 3.9
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>
68#include <blaze/util/mpl/If.h>
69#include <blaze/util/Types.h>
71
72
73namespace blaze {
74
75//=================================================================================================
76//
77// CLASS DEFINITION
78//
79//=================================================================================================
80
81//*************************************************************************************************
106template< 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 );
145
146 UniLowerValue( const UniLowerValue& ) = default;
148 //**********************************************************************************************
149
150 //**Destructor**********************************************************************************
153 ~UniLowerValue() = default;
155 //**********************************************************************************************
156
157 //**Assignment operators************************************************************************
160 inline UniLowerValue& operator= ( const UniLowerValue& ulv );
161 template< typename T > inline UniLowerValue& operator= ( const T& value );
162 template< typename T > inline UniLowerValue& operator+=( const T& value );
163 template< typename T > inline UniLowerValue& operator-=( const T& value );
164 template< typename T > inline UniLowerValue& operator*=( const T& value );
165 template< typename T > inline UniLowerValue& operator/=( const T& value );
167 //**********************************************************************************************
168
169 //**Utility functions***************************************************************************
172 inline void invert() const;
173
174 inline RepresentedType get() const noexcept;
175 inline bool isRestricted() const noexcept;
177 //**********************************************************************************************
178
179 //**Conversion operator*************************************************************************
182 inline operator RepresentedType() const noexcept;
184 //**********************************************************************************************
185
186 //**Complex data access functions***************************************************************
189 inline ValueType real() const;
190 inline void real( ValueType value ) const;
191 inline ValueType imag() const;
192 inline void imag( ValueType value ) const;
194 //**********************************************************************************************
195
196 private:
197 //**Member variables****************************************************************************
200 //**********************************************************************************************
201
202 //**Compile time checks*************************************************************************
218 //**********************************************************************************************
219
220 //**********************************************************************************************
230 friend inline void reset( const UniLowerValue& value )
231 {
232 using blaze::reset;
233
234 if( !value.diagonal_ ) {
235 reset( *value.value_ );
236 }
237 }
239 //**********************************************************************************************
240
241 //**********************************************************************************************
251 friend inline void clear( const UniLowerValue& value )
252 {
253 using blaze::clear;
254
255 if( !value.diagonal_ ) {
256 clear( *value.value_ );
257 }
258 }
260 //**********************************************************************************************
261};
262//*************************************************************************************************
263
264
265
266
267//=================================================================================================
268//
269// CONSTRUCTORS
270//
271//=================================================================================================
272
273//*************************************************************************************************
279template< typename MT > // Type of the adapted matrix
281 : value_ ( &value ) // The represented value.
282 , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
283{}
284//*************************************************************************************************
285
286
287
288
289//=================================================================================================
290//
291// OPERATORS
292//
293//=================================================================================================
294
295//*************************************************************************************************
302template< typename MT > // Type of the adapted matrix
304{
305 if( diagonal_ ) {
306 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
307 }
308
309 *value_ = *ulv.value;
310
311 return *this;
312}
313//*************************************************************************************************
314
315
316//*************************************************************************************************
323template< typename MT > // Type of the adapted matrix
324template< typename T > // Type of the right-hand side value
326{
327 if( diagonal_ ) {
328 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
329 }
330
331 *value_ = value;
332
333 return *this;
334}
335//*************************************************************************************************
336
337
338//*************************************************************************************************
345template< typename MT > // Type of the adapted matrix
346template< typename T > // Type of the right-hand side value
348{
349 if( diagonal_ ) {
350 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
351 }
352
353 *value_ += value;
354
355 return *this;
356}
357//*************************************************************************************************
358
359
360//*************************************************************************************************
367template< typename MT > // Type of the adapted matrix
368template< typename T > // Type of the right-hand side value
370{
371 if( diagonal_ ) {
372 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
373 }
374
375 *value_ -= value;
376
377 return *this;
378}
379//*************************************************************************************************
380
381
382//*************************************************************************************************
389template< typename MT > // Type of the adapted matrix
390template< typename T > // Type of the right-hand side value
392{
393 if( diagonal_ ) {
394 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
395 }
396
397 *value_ *= value;
398
399 return *this;
400}
401//*************************************************************************************************
402
403
404//*************************************************************************************************
411template< typename MT > // Type of the adapted matrix
412template< typename T > // Type of the right-hand side value
414{
415 if( diagonal_ ) {
416 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix element" );
417 }
418
419 *value_ /= value;
420
421 return *this;
422}
423//*************************************************************************************************
424
425
426
427
428//=================================================================================================
429//
430// UTILITY FUNCTIONS
431//
432//=================================================================================================
433
434//*************************************************************************************************
439template< typename MT > // Type of the adapted matrix
440inline void UniLowerValue<MT>::invert() const
441{
442 using blaze::invert;
443
444 if( !diagonal_ )
445 invert( *value_ );
446}
447//*************************************************************************************************
448
449
450//*************************************************************************************************
455template< typename MT > // Type of the adapted matrix
457{
458 return *value_;
459}
460//*************************************************************************************************
461
462
463//*************************************************************************************************
468template< typename MT > // Type of the adapted matrix
469inline bool UniLowerValue<MT>::isRestricted() const noexcept
470{
471 return diagonal_;
472}
473//*************************************************************************************************
474
475
476
477
478//=================================================================================================
479//
480// CONVERSION OPERATOR
481//
482//=================================================================================================
483
484//*************************************************************************************************
489template< typename MT > // Type of the adapted matrix
491{
492 return *value_;
493}
494//*************************************************************************************************
495
496
497
498
499//=================================================================================================
500//
501// COMPLEX DATA ACCESS FUNCTIONS
502//
503//=================================================================================================
504
505//*************************************************************************************************
513template< typename MT > // Type of the adapted matrix
515{
516 return value_->real();
517}
518//*************************************************************************************************
519
520
521//*************************************************************************************************
530template< typename MT > // Type of the adapted matrix
531inline void UniLowerValue<MT>::real( ValueType value ) const
532{
533 if( isRestricted() ) {
534 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
535 }
536
537 value_->real( value );
538}
539//*************************************************************************************************
540
541
542//*************************************************************************************************
550template< typename MT > // Type of the adapted matrix
552{
553 return value_->imag();
554}
555//*************************************************************************************************
556
557
558//*************************************************************************************************
569template< typename MT > // Type of the adapted matrix
570inline void UniLowerValue<MT>::imag( ValueType value ) const
571{
572 if( isRestricted() ) {
573 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setting for diagonal matrix element" );
574 }
575
576 value_->imag( value );
577}
578//*************************************************************************************************
579
580
581
582
583//=================================================================================================
584//
585// GLOBAL FUNCTIONS
586//
587//=================================================================================================
588
589//*************************************************************************************************
592template< typename MT >
593void invert( const UniLowerValue<MT>& value );
595//*************************************************************************************************
596
597
598//*************************************************************************************************
605template< typename MT >
606inline void invert( const UniLowerValue<MT>& value )
607{
608 value.invert();
609}
610//*************************************************************************************************
611
612} // namespace blaze
613
614#endif
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Constraint on the data type.
Constraint on the data type.
Header file for the If class template.
Utility type for generic codes.
Header file for the invert shim.
Header file for the IsComplex type trait.
Header file for the isDefault shim.
Header file for the isOne shim.
Header file for the isReal shim.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the relaxation flag enumeration.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Proxy base class.
Definition: Proxy.h:169
Representation of a value within a sparse lower unitriangular matrix.
Definition: UniLowerValue.h:109
void invert() const
In-place inversion of the unilower value.
Definition: UniLowerValue.h:440
RepresentedType get() const noexcept
Access to the represented value.
Definition: UniLowerValue.h:456
bool isRestricted() const noexcept
Returns whether the value represents a restricted matrix element..
Definition: UniLowerValue.h:469
RepresentedType * value_
The represented value.
Definition: UniLowerValue.h:198
UniLowerValue & operator=(const UniLowerValue &ulv)
Copy assignment operator for UniLowerValue.
Definition: UniLowerValue.h:303
ValueType imag() const
Returns the imaginary part of the represented complex number.
Definition: UniLowerValue.h:551
ElementType_t< MT > RepresentedType
Type of the represented matrix element.
Definition: UniLowerValue.h:131
bool diagonal_
true in case the element is on the diagonal, false if not.
Definition: UniLowerValue.h:199
ValueType real() const
Returns the real part of the represented complex number.
Definition: UniLowerValue.h:514
typename If_t< IsComplex_v< RepresentedType >, ComplexType< RepresentedType >, BuiltinType< RepresentedType > >::Type ValueType
Value type of the represented complex element.
Definition: UniLowerValue.h:136
ValueType value_type
Value type of the represented complex element.
Definition: UniLowerValue.h:138
UniLowerValue(RepresentedType &value, bool diagonal)
Constructor for the UniLowerValue class.
Definition: UniLowerValue.h:280
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:380
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.
Definition: View.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
void invert(const UniLowerValue< MT > &value)
In-place inversion of the unilower value.
Definition: UniLowerValue.h:606
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition: If.h:108
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the Proxy class.
Header file for the clear shim.
Header file for the isZero shim.
Header file for the reset shim.
Header file for basic type definitions.