Eigen.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_DENSE_EIGEN_H_
36 #define _BLAZE_MATH_DENSE_EIGEN_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
50 #include <blaze/math/lapack/geev.h>
57 #include <blaze/util/DisableIf.h>
58 #include <blaze/util/EnableIf.h>
59 #include <blaze/util/mpl/And.h>
60 #include <blaze/util/mpl/Or.h>
63 
64 
65 namespace blaze {
66 
67 //=================================================================================================
68 //
69 // EIGENVALUE FUNCTIONS
70 //
71 //=================================================================================================
72 
73 //*************************************************************************************************
76 template< typename MT, bool SO, typename VT, bool TF >
77 inline void eigen( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w );
78 
79 template< typename MT1, bool SO1, typename VT, bool TF, typename MT2, bool SO2 >
80 inline void eigen( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V );
82 //*************************************************************************************************
83 
84 
85 //*************************************************************************************************
104 template< typename MT // Type of the matrix A
105  , bool SO // Storage order of the matrix A
106  , typename VT // Type of the vector w
107  , bool TF > // Transpose flag of the vector w
108 inline EnableIf_< And< IsSymmetric<MT>, IsFloatingPoint< ElementType_<MT> > > >
109  eigen_backend( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
110 {
111  using Tmp = ResultType_< RemoveAdaptor_<MT> >;
112 
113  Tmp tmp( A );
114 
115  syevd( tmp, ~w, 'N', 'L' );
116 }
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
140 template< typename MT // Type of the matrix A
141  , bool SO // Storage order of the matrix A
142  , typename VT // Type of the vector w
143  , bool TF > // Transpose flag of the vector w
144 inline EnableIf_< And< IsHermitian<MT>, IsComplex< ElementType_<MT> > > >
145  eigen_backend( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
146 {
147  using Tmp = ResultType_< RemoveAdaptor_<MT> >;
148 
149  Tmp tmp( A );
150 
151  heevd( tmp, ~w, 'N', 'L' );
152 }
154 //*************************************************************************************************
155 
156 
157 //*************************************************************************************************
176 template< typename MT // Type of the matrix A
177  , bool SO // Storage order of the matrix A
178  , typename VT // Type of the vector w
179  , bool TF > // Transpose flag of the vector w
180 inline DisableIf_< Or< And< IsSymmetric<MT>, IsFloatingPoint< ElementType_<MT> > >
181  , And< IsHermitian<MT>, IsComplex< ElementType_<MT> > > > >
182  eigen_backend( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
183 {
184  using Tmp = ResultType_< RemoveAdaptor_<MT> >;
185 
186  Tmp tmp( A );
187 
188  geev( tmp, ~w );
189 }
191 //*************************************************************************************************
192 
193 
194 //*************************************************************************************************
281 template< typename MT // Type of the matrix A
282  , bool SO // Storage order of the matrix A
283  , typename VT // Type of the vector w
284  , bool TF > // Transpose flag of the vector w
285 inline void eigen( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
286 {
289 
293 
294  eigen_backend( ~A, ~w );
295 }
296 //*************************************************************************************************
297 
298 
299 //*************************************************************************************************
320 template< typename MT1 // Type of the matrix A
321  , bool SO1 // Storage order of the matrix A
322  , typename VT // Type of the vector w
323  , bool TF // Transpose flag of the vector w
324  , typename MT2 // Type of the matrix V
325  , bool SO2 > // Storage order of the matrix V
327  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
328 {
329  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
330 
331  Tmp tmp( A );
332 
333  syevd( tmp, ~w, 'V', 'L' );
334 
335  (~V) = tmp;
336 }
338 //*************************************************************************************************
339 
340 
341 //*************************************************************************************************
362 template< typename MT1 // Type of the matrix A
363  , bool SO1 // Storage order of the matrix A
364  , typename VT // Type of the vector w
365  , bool TF // Transpose flag of the vector w
366  , typename MT2 // Type of the matrix V
367  , bool SO2 > // Storage order of the matrix V
369  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
370 {
371  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
372 
373  Tmp tmp( A );
374 
375  heevd( tmp, ~w, 'V', 'L' );
376 
377  (~V) = tmp;
378 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
404 template< typename MT1 // Type of the matrix A
405  , bool SO1 // Storage order of the matrix A
406  , typename VT // Type of the vector w
407  , bool TF // Transpose flag of the vector w
408  , typename MT2 // Type of the matrix V
409  , bool SO2 > // Storage order of the matrix V
412  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
413 {
414  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
415 
416  Tmp tmp( A );
417 
419  geev( tmp, ~V, ~w );
420  else
421  geev( tmp, ~w, ~V );
422 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
527 template< typename MT1 // Type of the matrix A
528  , bool SO1 // Storage order of the matrix A
529  , typename VT // Type of the vector w
530  , bool TF // Transpose flag of the vector w
531  , typename MT2 // Type of the matrix V
532  , bool SO2 > // Storage order of the matrix V
534 {
537 
541 
546 
547  eigen_backend( ~A, ~w, ~V );
548 }
549 //*************************************************************************************************
550 
551 } // namespace blaze
552 
553 #endif
Constraint on the data type.
Header file for auxiliary alias declarations.
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.In case the given data type T does not provide low-level data access to m...
Definition: MutableDataAccess.h:61
#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
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
Header file for the And class template.
Header file for the DenseVector base class.
Constraint on the data type.
typename T::ResultType ResultType_
Alias declaration for nested ResultType type definitions.The ResultType_ alias declaration provides a...
Definition: Aliases.h:323
Header file for the LAPACK general matrix eigenvalue functions (geev)
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE(T)
Constraint on the data type.In case the given data type T is an adaptor type (as for instance LowerMa...
Definition: Adaptor.h:81
Base class for dense matrices.The DenseMatrix class is a base class for all dense matrix classes...
Definition: DenseMatrix.h:71
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:83
Header file for the IsFloatingPoint type trait.
void geev(char jobvl, char jobvr, int n, float *A, int lda, float *wr, float *wi, float *VL, int ldvl, float *VR, int ldvr, float *work, int lwork, int *info)
LAPACK kernel for computing the eigenvalues of the given dense general single precision column-major ...
Definition: geev.h:161
Header file for the Or class template.
Header file for the DenseMatrix base class.
typename T::ElementType ElementType_
Alias declaration for nested ElementType type definitions.The ElementType_ alias declaration provides...
Definition: Aliases.h:163
Base class for N-dimensional dense vectors.The DenseVector class is a base class for all arbitrarily ...
Definition: DenseVector.h:70
Compile time check for floating point data types.This type trait tests whether or not the given templ...
Definition: IsFloatingPoint.h:75
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the LAPACK Hermitian matrix eigenvalue functions (heevd)
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.In case the given data type T is not a BLAS compatible data type (i...
Definition: BLASCompatible.h:61
Header file for the LAPACK symmetric matrix eigenvalue functions (syevd)
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Compile time check for complex types.This type trait tests whether or not the given template paramete...
Definition: IsComplex.h:76
Header file for the IsRowMajorMatrix type trait.
Header file for the IsComplex type trait.
Compile time logical and evaluation.The And class template performs at compile time a logical and (&#39;&&&#3...
Definition: And.h:101
Header file for the IsHermitian type trait.
void syevd(char jobz, char uplo, int n, float *A, int lda, float *w, float *work, int lwork, int *iwork, int liwork, int *info)
LAPACK kernel for computing the eigenvalues of the given dense symmetric single precision column-majo...
Definition: syevd.h:129
void eigen(const DenseMatrix< MT, SO > &A, DenseVector< VT, TF > &w)
Eigenvalue computation of the given dense matrix.
Definition: Eigen.h:285