35 #ifndef _BLAZE_MATH_LAPACK_GEEV_H_ 36 #define _BLAZE_MATH_LAPACK_GEEV_H_ 77 template<
typename MT,
bool SO,
typename VT,
bool TF >
78 inline void geev( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w );
80 template<
typename MT1,
bool SO1,
typename MT2,
bool SO2,
typename VT,
bool TF >
81 inline void geev( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL, DenseVector<VT,TF>& w );
83 template<
typename MT1,
bool SO1,
typename VT,
bool TF,
typename MT2,
bool SO2 >
84 inline void geev( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& VR );
86 template<
typename MT1,
bool SO1,
typename MT2,
bool SO2,
typename VT,
bool TF,
typename MT3,
bool SO3 >
87 inline void geev( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
88 DenseVector<VT,TF>& w, DenseMatrix<MT3,SO3>& VR );
110 template<
typename MT
114 inline DisableIf_< IsComplex< ElementType_<MT> > >
115 geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
120 using CT = ElementType_<VT>;
121 using BT = ElementType_<MT>;
126 int n ( numeric_cast<int>( (~A).
rows() ) );
127 int lda ( numeric_cast<int>( (~A).
spacing() ) );
130 int lwork( 3*n + 2 );
131 const std::unique_ptr<BT[]> wr (
new BT[n] );
132 const std::unique_ptr<BT[]> wi (
new BT[n] );
133 const std::unique_ptr<BT[]> work(
new BT[lwork] );
135 geev(
'N',
'N', n, (~A).
data(), lda, wr.get(), wi.get(),
136 nullptr, 1,
nullptr, 1, work.get(), lwork, &info );
144 for(
size_t i=0UL; i<(~A).
rows(); ++i ) {
145 (~w)[i] = CT( wr[i], wi[i] );
169 template<
typename MT
173 inline EnableIf_< IsComplex< ElementType_<MT> > >
174 geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
179 using CT = ElementType_<MT>;
180 using BT = UnderlyingElement_<CT>;
185 int n ( numeric_cast<int>( (~A).
rows() ) );
186 int lda ( numeric_cast<int>( (~A).
spacing() ) );
189 int lwork( 2*n + 2 );
190 const std::unique_ptr<CT[]> work (
new CT[lwork] );
191 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
194 nullptr, 1,
nullptr, 1, work.get(), lwork, rwork.get(), &info );
261 template<
typename MT
277 const size_t N( (~A).
rows() );
289 geev_backend( ~A, ~w );
312 template<
typename MT1
332 int n ( numeric_cast<int>( (~A).
rows() ) );
333 int lda ( numeric_cast<int>( (~A).
spacing() ) );
336 int lwork( 4*n + 2 );
337 const std::unique_ptr<BT[]> vl (
new BT[n*n] );
338 const std::unique_ptr<BT[]> wr (
new BT[n] );
339 const std::unique_ptr<BT[]> wi (
new BT[n] );
340 const std::unique_ptr<BT[]> work(
new BT[lwork] );
342 geev( ( SO1 ?
'V' :
'N' ), ( SO1 ?
'N' :
'V' ), n, (~A).
data(), lda, wr.get(), wi.get(),
343 ( SO1 ? vl.get() : nullptr ), ( SO1 ? n : 1 ),
344 ( SO1 ? nullptr : vl.get() ), ( SO1 ? 1 : n ),
345 work.get(), lwork, &info );
353 const size_t N( (~A).
rows() );
355 for(
size_t j=0UL; j<N; ++j ) {
356 (~w)[j] = CT( wr[j], wi[j] );
359 for(
size_t j=0UL; j<N; ++j ) {
360 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
361 for(
size_t i=0UL; i<N; ++i )
363 const size_t j1( SO1 ? j : j+1UL );
364 const size_t j2( SO1 ? j+1UL : j );
366 const BT vl1( vl[i+j*N] );
367 const BT vl2( vl[i+(j+1UL)*N] );
369 ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
370 ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
376 for(
size_t i=0UL; i<N; ++i ) {
377 ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
404 template<
typename MT1
424 int n ( numeric_cast<int>( (~A).
rows() ) );
425 int lda ( numeric_cast<int>( (~A).
spacing() ) );
426 int ldvl( numeric_cast<int>( (~VL).
spacing() ) );
429 int lwork( 2*n + 2 );
430 const std::unique_ptr<CT[]> work (
new CT[lwork] );
431 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
433 geev( ( SO1 ?
'V' :
'N' ), ( SO1 ?
'N' :
'V' ), n, (~A).
data(), lda, (~w).
data(),
434 ( SO1 ? (~VL).
data() :
nullptr ), ( SO1 ? ldvl : 1 ),
435 ( SO1 ?
nullptr : (~VL).
data() ), ( SO1 ? 1 : ldvl ),
436 work.get(), lwork, rwork.get(), &info );
517 template<
typename MT1
541 const size_t N( (~A).
rows() );
548 resize( ~VL, N, N,
false );
554 geev_backend( ~A, ~VL, ~w );
577 template<
typename MT1
597 int n ( numeric_cast<int>( (~A).
rows() ) );
598 int lda ( numeric_cast<int>( (~A).
spacing() ) );
601 int lwork( 4*n + 2 );
602 const std::unique_ptr<BT[]> vr (
new BT[n*n] );
603 const std::unique_ptr<BT[]> wr (
new BT[n] );
604 const std::unique_ptr<BT[]> wi (
new BT[n] );
605 const std::unique_ptr<BT[]> work(
new BT[lwork] );
607 geev( ( SO1 ?
'N' :
'V' ), ( SO1 ?
'V' :
'N' ), n, (~A).
data(), lda, wr.get(), wi.get(),
608 ( SO1 ? nullptr : vr.get() ), ( SO1 ? 1 : n ),
609 ( SO1 ? vr.get() : nullptr ), ( SO1 ? n : 1 ),
610 work.get(), lwork, &info );
618 const size_t N( (~A).
rows() );
620 for(
size_t j=0UL; j<N; ++j ) {
621 (~w)[j] = CT( wr[j], wi[j] );
624 for(
size_t j=0UL; j<N; ++j ) {
625 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
626 for(
size_t i=0UL; i<N; ++i )
628 const size_t j1( SO1 ? j : j+1UL );
629 const size_t j2( SO1 ? j+1UL : j );
631 const BT vr1( vr[i+j*N] );
632 const BT vr2( vr[i+(j+1UL)*N] );
634 ( SO2 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO2 ? vr2 : -vr2 ) );
635 ( SO2 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO2 ? -vr2 : vr2 ) );
641 for(
size_t i=0UL; i<N; ++i ) {
642 ( SO2 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
669 template<
typename MT1
689 int n ( numeric_cast<int>( (~A).
rows() ) );
690 int lda ( numeric_cast<int>( (~A).
spacing() ) );
691 int ldvr( numeric_cast<int>( (~VR).
spacing() ) );
694 int lwork( 2*n + 2 );
695 const std::unique_ptr<CT[]> work (
new CT[lwork] );
696 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
698 geev( ( SO1 ?
'N' :
'V' ), ( SO1 ?
'V' :
'N' ), n, (~A).
data(), lda, (~w).
data(),
699 ( SO1 ?
nullptr : (~VR).
data() ), ( SO1 ? 1 : ldvr ),
700 ( SO1 ? (~VR).
data() :
nullptr ), ( SO1 ? ldvr : 1 ),
701 work.get(), lwork, rwork.get(), &info );
782 template<
typename MT1
806 const size_t N( (~A).
rows() );
813 resize( ~VR, N, N,
false );
819 geev_backend( ~A, ~w, ~VR );
843 template<
typename MT1
868 int n ( numeric_cast<int>( (~A).
rows() ) );
869 int lda ( numeric_cast<int>( (~A).
spacing() ) );
872 int lwork( 4*n + 2 );
873 const std::unique_ptr<BT[]> vl (
new BT[n*n] );
874 const std::unique_ptr<BT[]> vr (
new BT[n*n] );
875 const std::unique_ptr<BT[]> wr (
new BT[n] );
876 const std::unique_ptr<BT[]> wi (
new BT[n] );
877 const std::unique_ptr<BT[]> work(
new BT[lwork] );
879 geev(
'V',
'V', n, (~A).
data(), lda, wr.get(), wi.get(),
880 ( SO1 ? vl.get() : vr.get() ), n, ( SO1 ? vr.get() : vl.get() ), n,
881 work.get(), lwork, &info );
889 const size_t N( (~A).
rows() );
891 for(
size_t j=0UL; j<N; ++j ) {
892 (~w)[j] = CT( wr[j], wi[j] );
895 for(
size_t j=0UL; j<N; ++j ) {
896 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
897 for(
size_t i=0UL; i<N; ++i )
899 const size_t j1( SO1 ? j : j+1UL );
900 const size_t j2( SO1 ? j+1UL : j );
902 const BT vl1( vl[i+j*N] );
903 const BT vl2( vl[i+(j+1UL)*N] );
904 const BT vr1( vr[i+j*N] );
905 const BT vr2( vr[i+(j+1UL)*N] );
907 ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
908 ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
909 ( SO3 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO3 ? vr2 : -vr2 ) );
910 ( SO3 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO3 ? -vr2 : vr2 ) );
916 for(
size_t i=0UL; i<N; ++i ) {
917 ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
918 ( SO3 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
946 template<
typename MT1
971 int n ( numeric_cast<int>( (~A).
rows() ) );
972 int lda ( numeric_cast<int>( (~A).
spacing() ) );
973 int ldvl( numeric_cast<int>( (~VL).
spacing() ) );
974 int ldvr( numeric_cast<int>( (~VR).
spacing() ) );
977 int lwork( 2*n + 2 );
978 const std::unique_ptr<CT[]> work (
new CT[lwork] );
979 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
982 ( SO1 ? (~VL).
data() : (~VR).
data() ), ( SO1 ? ldvl : ldvr ),
983 ( SO1 ? (~VR).
data() : (~VL).
data() ), ( SO1 ? ldvr : ldvl ),
984 work.get(), lwork, rwork.get(), &info );
1074 template<
typename MT1
1107 const size_t N( (~A).
rows() );
1114 resize( ~VL, N, N,
false );
1115 resize( ~VR, N, N,
false );
1121 geev_backend( ~A, ~VL, ~w, ~VR );
#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.
#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
constexpr bool equal(const T1 &a, const T2 &b)
Generic equality check.
Definition: Equal.h:76
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#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
Constraint on the data type.
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 DenseVector base class.
Header file for the UnderlyingElement type trait.
Constraint on the data type.
Cast operators for numeric types.
#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
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Constraint on the data type.
Header file for the DisableIf class template.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
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 DenseMatrix base class.
typename UnderlyingElement< T >::Type UnderlyingElement_
Auxiliary alias declaration for the UnderlyingElement type trait.The UnderlyingElement_ alias declara...
Definition: UnderlyingElement.h:132
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
Header file for the equal shim.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:714
Constraint on the data type.
Header file for the EnableIf class template.
Header file for run time assertion macros.
#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
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
#define BLAZE_CONSTRAINT_MUST_BE_BUILTIN_TYPE(T)
Constraint on the data type.In case the given data type T is not a built-in data type, a compilation error is created.
Definition: Builtin.h:60
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
#define BLAZE_CONSTRAINT_MUST_BE_COMPLEX_TYPE(T)
Constraint on the data type.This compile time constraint checks that the given data type T is a compl...
Definition: Complex.h:62
#define BLAZE_THROW_LAPACK_ERROR(MESSAGE)
Macro for the emission of an exception on detection of a LAPACK error.This macro encapsulates the def...
Definition: Exception.h:146
Header file for the IsComplex type trait.
Header file for the complex data type.
decltype(auto) conj(const DenseMatrix< MT, SO > &dm)
Returns a matrix containing the complex conjugate of each single element of dm.
Definition: DMatMapExpr.h:1321
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Constraint on the data type.
Header file for the CLAPACK geev wrapper functions.