Blaze 3.9
DMatEigenExpr.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATEIGENEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATEIGENEXPR_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
59#include <blaze/util/Assert.h>
61#include <blaze/util/mpl/If.h>
62#include <blaze/util/Types.h>
63
64
65namespace blaze {
66
67//=================================================================================================
68//
69// CLASS DMATEIGENEXPR
70//
71//=================================================================================================
72
73//*************************************************************************************************
80template< typename MT // Type of the dense matrix
81 , bool SO > // Storage order
83 : public EigenExpr< DenseVector< DMatEigenExpr<MT,SO>, false > >
84 , private Computation
85{
86 private:
87 //**Type definitions****************************************************************************
90
92 using ET = typename If_t< IsSymmetric_v<MT> || IsHermitian_v<MT>
95 //**********************************************************************************************
96
97 public:
98 //**Type definitions****************************************************************************
101
104
109
112
114 using Operand = If_t< IsExpression_v<MT>, const MT, const MT& >;
115 //**********************************************************************************************
116
117 //**Compilation flags***************************************************************************
119 static constexpr bool simdEnabled = false;
120
122 static constexpr bool smpAssignable = false;
123 //**********************************************************************************************
124
125 //**Constructor*********************************************************************************
130 explicit inline DMatEigenExpr( const MT& dm ) noexcept
131 : dm_( dm ) // Dense matrix of the eigenvalue expression
132 {
133 BLAZE_INTERNAL_ASSERT( isSquare( *dm ), "Non-square matrix detected" );
134 }
135 //**********************************************************************************************
136
137 //**Size function*******************************************************************************
142 inline size_t size() const noexcept {
143 return dm_.rows();
144 }
145 //**********************************************************************************************
146
147 //**Operand access******************************************************************************
152 inline Operand operand() const noexcept {
153 return dm_;
154 }
155 //**********************************************************************************************
156
157 //**********************************************************************************************
163 template< typename T >
164 inline bool canAlias( const T* alias ) const noexcept {
165 return dm_.isAliased( alias );
166 }
167 //**********************************************************************************************
168
169 //**********************************************************************************************
175 template< typename T >
176 inline bool isAliased( const T* alias ) const noexcept {
177 return dm_.isAliased( alias );
178 }
179 //**********************************************************************************************
180
181 private:
182 //**Member variables****************************************************************************
184 //**********************************************************************************************
185
186 //**Assignment to dense vectors*****************************************************************
198 template< typename VT > // Type of the target dense vector
199 friend inline void assign( DenseVector<VT,false>& lhs, const DMatEigenExpr& rhs )
200 {
202
203 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
204
205 eigen( rhs.operand(), *lhs );
206 }
208 //**********************************************************************************************
209
210 //**Assignment to sparse vectors****************************************************************
222 template< typename VT > // Type of the target sparse vector
223 friend inline void assign( SparseVector<VT,false>& lhs, const DMatEigenExpr& rhs )
224 {
226
227 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
228
229 const ResultType tmp( serial( rhs ) );
230 assign( *lhs, tmp );
231 }
233 //**********************************************************************************************
234
235 //**Addition assignment to dense vectors********************************************************
247 template< typename VT > // Type of the target dense vector
248 friend inline void addAssign( DenseVector<VT,false>& lhs, const DMatEigenExpr& rhs )
249 {
251
252 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
253
254 const ResultType tmp( serial( rhs ) );
255 addAssign( *lhs, tmp );
256 }
258 //**********************************************************************************************
259
260 //**Addition assignment to sparse vectors*******************************************************
261 // No special implementation for the addition assignment to sparse vectors.
262 //**********************************************************************************************
263
264 //**Subtraction assignment to dense vectors*****************************************************
276 template< typename VT > // Type of the target dense vector
277 friend inline void subAssign( DenseMatrix<VT,false>& lhs, const DMatEigenExpr& rhs )
278 {
280
281 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
282
283 const ResultType tmp( serial( rhs ) );
284 subAssign( *lhs, tmp );
285 }
287 //**********************************************************************************************
288
289 //**Subtraction assignment to sparse vectors****************************************************
290 // No special implementation for the subtraction assignment to sparse vectors.
291 //**********************************************************************************************
292
293 //**Multiplication assignment to dense vectors**************************************************
305 template< typename VT > // Type of the target dense vector
306 friend inline void multAssign( DenseMatrix<VT,false>& lhs, const DMatEigenExpr& rhs )
307 {
309
310 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
311
312 const ResultType tmp( serial( rhs ) );
313 multAssign( *lhs, tmp );
314 }
316 //**********************************************************************************************
317
318 //**Multiplication assignment to sparse vectors*************************************************
319 // No special implementation for the multiplication assignment to sparse vectors.
320 //**********************************************************************************************
321
322 //**Division assignment to dense vectors********************************************************
334 template< typename VT > // Type of the target dense vector
335 friend inline void divAssign( DenseMatrix<VT,false>& lhs, const DMatEigenExpr& rhs )
336 {
338
339 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
340
341 const ResultType tmp( serial( rhs ) );
342 divAssign( *lhs, tmp );
343 }
345 //**********************************************************************************************
346
347 //**Division assignment to sparse vectors*******************************************************
348 // No special implementation for the division assignment to sparse vectors.
349 //**********************************************************************************************
350
351 //**Compile time checks*************************************************************************
356 //**********************************************************************************************
357};
358//*************************************************************************************************
359
360
361
362
363//=================================================================================================
364//
365// GLOBAL OPERATORS
366//
367//=================================================================================================
368
369//*************************************************************************************************
400template< typename MT // Type of the dense matrix
401 , bool SO > // Storage order
402inline decltype(auto) eigen( const DenseMatrix<MT,SO>& dm )
403{
405
407
408 if( !isSquare( *dm ) ) {
409 BLAZE_THROW_INVALID_ARGUMENT( "Invalid non-square matrix provided" );
410 }
411
412 using ReturnType = const DMatEigenExpr<MT,SO>;
413 return ReturnType( *dm );
414}
415//*************************************************************************************************
416
417} // namespace blaze
418
419#endif
Header file for auxiliary alias declarations.
typename T1::template Rebind< T2 >::Other Rebind_t
Alias declaration for nested Rebind class templates.
Definition: Aliases.h:350
typename T::ReturnType ReturnType_t
Alias declaration for nested ReturnType type definitions.
Definition: Aliases.h:470
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition: Aliases.h:550
Header file for run time assertion macros.
Constraint on the data type.
Header file for the column trait.
Header file for the function trace functionality.
Header file for the If class template.
Header file for the IsExpression type trait class.
Header file for the IsHermitian type trait.
Header file for the IsSymmetric type trait.
Header file for the MakeComplex type trait.
Header file for the UnderlyingElement type trait.
Expression object for dense matrix eigenvalue solvers.
Definition: DMatEigenExpr.h:85
Rebind_t< VT, ET > ResultType
Result type for expression template evaluations.
Definition: DMatEigenExpr.h:105
typename If_t< IsSymmetric_v< MT >||IsHermitian_v< MT >, UnderlyingElement< ElementType_t< MT > >, MakeComplex< ElementType_t< MT > > >::Type ET
Element type of the resulting vector.
Definition: DMatEigenExpr.h:94
const ResultType CompositeType
Data type for composite expression templates.
Definition: DMatEigenExpr.h:111
DMatEigenExpr(const MT &dm) noexcept
Constructor for the DMatEigenExpr class.
Definition: DMatEigenExpr.h:130
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition: DMatEigenExpr.h:142
ColumnTrait_t< ResultType_t< MT > > VT
Type of the resulting vector.
Definition: DMatEigenExpr.h:89
If_t< IsExpression_v< MT >, const MT, const MT & > Operand
Composite data type of the dense matrix expression.
Definition: DMatEigenExpr.h:114
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition: DMatEigenExpr.h:176
ElementType_t< ResultType > ElementType
Resulting element type.
Definition: DMatEigenExpr.h:107
Operand operand() const noexcept
Returns the dense matrix operand.
Definition: DMatEigenExpr.h:152
TransposeType_t< ResultType > TransposeType
Transpose type for expression template evaluations.
Definition: DMatEigenExpr.h:106
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition: DMatEigenExpr.h:122
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition: DMatEigenExpr.h:164
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition: DMatEigenExpr.h:119
Operand dm_
Dense matrix of the eigenvalue expression.
Definition: DMatEigenExpr.h:183
ReturnType_t< ResultType > ReturnType
Return type for expression template evaluations.
Definition: DMatEigenExpr.h:108
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Base class for sparse vectors.
Definition: SparseVector.h:72
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseVector base class.
Header file for the EigenExpr base class.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) eigen(const DenseMatrix< MT, SO > &dm)
Calculation of the eigenvalues of the given dense matrix.
Definition: DMatEigenExpr.h:402
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
typename ColumnTrait< MT, CCAs... >::Type ColumnTrait_t
Auxiliary alias declaration for the ColumnTrait type trait.
Definition: ColumnTrait.h:144
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
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
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Base class for all compute expression templates.
Definition: Computation.h:68
Base class for all eigenvalue expression templates.
Definition: EigenExpr.h:68
Converting the given type to the matching 'complex' type.
Definition: MakeComplex.h:74
Evaluation of the element type of a given data type.
Definition: UnderlyingElement.h:94
Header file for basic type definitions.