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 
117 
118  Tmp tmp( A );
119 
120  syevd( tmp, ~w, 'N', 'L' );
121 }
123 //*************************************************************************************************
124 
125 
126 //*************************************************************************************************
145 template< typename MT // Type of the matrix A
146  , bool SO // Storage order of the matrix A
147  , typename VT // Type of the vector w
148  , bool TF > // Transpose flag of the vector w
149 inline EnableIf_< And< IsHermitian<MT>, IsComplex< ElementType_<MT> > > >
150  eigen_backend( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
151 {
152  using Tmp = ResultType_< RemoveAdaptor_<MT> >;
153 
158 
159  Tmp tmp( A );
160 
161  heevd( tmp, ~w, 'N', 'L' );
162 }
164 //*************************************************************************************************
165 
166 
167 //*************************************************************************************************
186 template< typename MT // Type of the matrix A
187  , bool SO // Storage order of the matrix A
188  , typename VT // Type of the vector w
189  , bool TF > // Transpose flag of the vector w
190 inline DisableIf_< Or< And< IsSymmetric<MT>, IsFloatingPoint< ElementType_<MT> > >
191  , And< IsHermitian<MT>, IsComplex< ElementType_<MT> > > > >
192  eigen_backend( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
193 {
194  using Tmp = ResultType_< RemoveAdaptor_<MT> >;
195 
200 
201  Tmp tmp( A );
202 
203  geev( tmp, ~w );
204 }
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
296 template< typename MT // Type of the matrix A
297  , bool SO // Storage order of the matrix A
298  , typename VT // Type of the vector w
299  , bool TF > // Transpose flag of the vector w
300 inline void eigen( const DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
301 {
304 
308 
309  eigen_backend( ~A, ~w );
310 }
311 //*************************************************************************************************
312 
313 
314 //*************************************************************************************************
335 template< typename MT1 // Type of the matrix A
336  , bool SO1 // Storage order of the matrix A
337  , typename VT // Type of the vector w
338  , bool TF // Transpose flag of the vector w
339  , typename MT2 // Type of the matrix V
340  , bool SO2 > // Storage order of the matrix V
342  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
343 {
344  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
345 
350 
351  Tmp tmp( A );
352 
353  syevd( tmp, ~w, 'V', 'L' );
354 
355  (~V) = tmp;
356 }
358 //*************************************************************************************************
359 
360 
361 //*************************************************************************************************
382 template< typename MT1 // Type of the matrix A
383  , bool SO1 // Storage order of the matrix A
384  , typename VT // Type of the vector w
385  , bool TF // Transpose flag of the vector w
386  , typename MT2 // Type of the matrix V
387  , bool SO2 > // Storage order of the matrix V
389  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
390 {
391  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
392 
397 
398  Tmp tmp( A );
399 
400  heevd( tmp, ~w, 'V', 'L' );
401 
402  (~V) = tmp;
403 }
405 //*************************************************************************************************
406 
407 
408 //*************************************************************************************************
429 template< typename MT1 // Type of the matrix A
430  , bool SO1 // Storage order of the matrix A
431  , typename VT // Type of the vector w
432  , bool TF // Transpose flag of the vector w
433  , typename MT2 // Type of the matrix V
434  , bool SO2 > // Storage order of the matrix V
437  eigen_backend( const DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& V )
438 {
439  using Tmp = ResultType_< RemoveAdaptor_<MT1> >;
440 
445 
446  Tmp tmp( A );
447 
449  geev( tmp, ~V, ~w );
450  else
451  geev( tmp, ~w, ~V );
452 }
454 //*************************************************************************************************
455 
456 
457 //*************************************************************************************************
557 template< typename MT1 // Type of the matrix A
558  , bool SO1 // Storage order of the matrix A
559  , typename VT // Type of the vector w
560  , bool TF // Transpose flag of the vector w
561  , typename MT2 // Type of the matrix V
562  , bool SO2 > // Storage order of the matrix V
564 {
567 
571 
576 
577  eigen_backend( ~A, ~w, ~V );
578 }
579 //*************************************************************************************************
580 
581 } // namespace blaze
582 
583 #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:224
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:343
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:80
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:58
Compile time check for row-major matrix types.This type trait tests whether or not the given template...
Definition: IsRowMajorMatrix.h:110
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:163
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:76
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:224
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 &#39;and&#39; evaluation.The And alias declaration performs at compile time a logical &#39;a...
Definition: And.h:76
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:131
void eigen(const DenseMatrix< MT, SO > &A, DenseVector< VT, TF > &w)
Eigenvalue computation of the given dense matrix.
Definition: Eigen.h:300