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 auto geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
115 -> DisableIf_t< IsComplex_v< ElementType_t<MT> > >
120 using CT = ElementType_t<VT>;
121 using BT = ElementType_t<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 auto geev_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w )
174 -> EnableIf_t< IsComplex_v< ElementType_t<MT> > >
179 using CT = ElementType_t<MT>;
180 using BT = UnderlyingElement_t<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
279 const size_t N( (~A).
rows() );
291 geev_backend( ~A, ~w );
314 template<
typename MT1
320 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL, DenseVector<VT,TF>& w )
321 -> DisableIf_t< IsComplex_v< ElementType_t<MT1> > >
328 using CT = ElementType_t<VT>;
329 using BT = ElementType_t<MT1>;
334 int n ( numeric_cast<int>( (~A).
rows() ) );
335 int lda ( numeric_cast<int>( (~A).
spacing() ) );
338 int lwork( 4*n + 2 );
339 const std::unique_ptr<BT[]> vl (
new BT[n*n] );
340 const std::unique_ptr<BT[]> wr (
new BT[n] );
341 const std::unique_ptr<BT[]> wi (
new BT[n] );
342 const std::unique_ptr<BT[]> work(
new BT[lwork] );
344 geev( ( SO1 ?
'V' :
'N' ), ( SO1 ?
'N' :
'V' ), n, (~A).
data(), lda, wr.get(), wi.get(),
345 ( SO1 ? vl.get() : nullptr ), ( SO1 ? n : 1 ),
346 ( SO1 ? nullptr : vl.get() ), ( SO1 ? 1 : n ),
347 work.get(), lwork, &info );
355 const size_t N( (~A).
rows() );
357 for(
size_t j=0UL; j<N; ++j ) {
358 (~w)[j] = CT( wr[j], wi[j] );
361 for(
size_t j=0UL; j<N; ++j ) {
362 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
363 for(
size_t i=0UL; i<N; ++i )
365 const size_t j1( SO1 ? j : j+1UL );
366 const size_t j2( SO1 ? j+1UL : j );
368 const BT vl1( vl[i+j*N] );
369 const BT vl2( vl[i+(j+1UL)*N] );
371 ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
372 ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
378 for(
size_t i=0UL; i<N; ++i ) {
379 ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
406 template<
typename MT1
412 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL, DenseVector<VT,TF>& w )
413 -> EnableIf_t< IsComplex_v< ElementType_t<MT1> > >
420 using CT = ElementType_t<MT1>;
421 using BT = UnderlyingElement_t<CT>;
426 int n ( numeric_cast<int>( (~A).
rows() ) );
427 int lda ( numeric_cast<int>( (~A).
spacing() ) );
428 int ldvl( numeric_cast<int>( (~VL).
spacing() ) );
431 int lwork( 2*n + 2 );
432 const std::unique_ptr<CT[]> work (
new CT[lwork] );
433 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
435 geev( ( SO1 ?
'V' :
'N' ), ( SO1 ?
'N' :
'V' ), n, (~A).
data(), lda, (~w).
data(),
436 ( SO1 ? (~VL).
data() :
nullptr ), ( SO1 ? ldvl : 1 ),
437 ( SO1 ?
nullptr : (~VL).
data() ), ( SO1 ? 1 : ldvl ),
438 work.get(), lwork, rwork.get(), &info );
519 template<
typename MT1
546 const size_t N( (~A).
rows() );
553 resize( ~VL, N, N,
false );
559 geev_backend( ~A, ~VL, ~w );
582 template<
typename MT1
588 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& VR )
589 -> DisableIf_t< IsComplex_v< ElementType_t<MT1> > >
596 using CT = ElementType_t<VT>;
597 using BT = ElementType_t<MT1>;
602 int n ( numeric_cast<int>( (~A).
rows() ) );
603 int lda ( numeric_cast<int>( (~A).
spacing() ) );
606 int lwork( 4*n + 2 );
607 const std::unique_ptr<BT[]> vr (
new BT[n*n] );
608 const std::unique_ptr<BT[]> wr (
new BT[n] );
609 const std::unique_ptr<BT[]> wi (
new BT[n] );
610 const std::unique_ptr<BT[]> work(
new BT[lwork] );
612 geev( ( SO1 ?
'N' :
'V' ), ( SO1 ?
'V' :
'N' ), n, (~A).
data(), lda, wr.get(), wi.get(),
613 ( SO1 ? nullptr : vr.get() ), ( SO1 ? 1 : n ),
614 ( SO1 ? vr.get() : nullptr ), ( SO1 ? n : 1 ),
615 work.get(), lwork, &info );
623 const size_t N( (~A).
rows() );
625 for(
size_t j=0UL; j<N; ++j ) {
626 (~w)[j] = CT( wr[j], wi[j] );
629 for(
size_t j=0UL; j<N; ++j ) {
630 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
631 for(
size_t i=0UL; i<N; ++i )
633 const size_t j1( SO1 ? j : j+1UL );
634 const size_t j2( SO1 ? j+1UL : j );
636 const BT vr1( vr[i+j*N] );
637 const BT vr2( vr[i+(j+1UL)*N] );
639 ( SO2 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO2 ? vr2 : -vr2 ) );
640 ( SO2 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO2 ? -vr2 : vr2 ) );
646 for(
size_t i=0UL; i<N; ++i ) {
647 ( SO2 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
674 template<
typename MT1
680 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w, DenseMatrix<MT2,SO2>& VR )
681 -> EnableIf_t< IsComplex_v< ElementType_t<MT1> > >
688 using CT = ElementType_t<MT1>;
689 using BT = UnderlyingElement_t<CT>;
694 int n ( numeric_cast<int>( (~A).
rows() ) );
695 int lda ( numeric_cast<int>( (~A).
spacing() ) );
696 int ldvr( numeric_cast<int>( (~VR).
spacing() ) );
699 int lwork( 2*n + 2 );
700 const std::unique_ptr<CT[]> work (
new CT[lwork] );
701 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
703 geev( ( SO1 ?
'N' :
'V' ), ( SO1 ?
'V' :
'N' ), n, (~A).
data(), lda, (~w).
data(),
704 ( SO1 ?
nullptr : (~VR).
data() ), ( SO1 ? 1 : ldvr ),
705 ( SO1 ? (~VR).
data() :
nullptr ), ( SO1 ? ldvr : 1 ),
706 work.get(), lwork, rwork.get(), &info );
787 template<
typename MT1
811 const size_t N( (~A).
rows() );
818 resize( ~VR, N, N,
false );
824 geev_backend( ~A, ~w, ~VR );
848 template<
typename MT1
856 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
857 DenseVector<VT,TF>& w, DenseMatrix<MT3,SO3>& VR )
858 -> DisableIf_t< IsComplex_v< ElementType_t<MT1> > >
867 using CT = ElementType_t<VT>;
868 using BT = ElementType_t<MT1>;
873 int n ( numeric_cast<int>( (~A).
rows() ) );
874 int lda ( numeric_cast<int>( (~A).
spacing() ) );
877 int lwork( 4*n + 2 );
878 const std::unique_ptr<BT[]> vl (
new BT[n*n] );
879 const std::unique_ptr<BT[]> vr (
new BT[n*n] );
880 const std::unique_ptr<BT[]> wr (
new BT[n] );
881 const std::unique_ptr<BT[]> wi (
new BT[n] );
882 const std::unique_ptr<BT[]> work(
new BT[lwork] );
884 geev(
'V',
'V', n, (~A).
data(), lda, wr.get(), wi.get(),
885 ( SO1 ? vl.get() : vr.get() ), n, ( SO1 ? vr.get() : vl.get() ), n,
886 work.get(), lwork, &info );
894 const size_t N( (~A).
rows() );
896 for(
size_t j=0UL; j<N; ++j ) {
897 (~w)[j] = CT( wr[j], wi[j] );
900 for(
size_t j=0UL; j<N; ++j ) {
901 if( j+1UL < N &&
equal( (~w)[j],
conj( (~w)[j+1UL] ) ) ) {
902 for(
size_t i=0UL; i<N; ++i )
904 const size_t j1( SO1 ? j : j+1UL );
905 const size_t j2( SO1 ? j+1UL : j );
907 const BT vl1( vl[i+j*N] );
908 const BT vl2( vl[i+(j+1UL)*N] );
909 const BT vr1( vr[i+j*N] );
910 const BT vr2( vr[i+(j+1UL)*N] );
912 ( SO2 ? (~VL)(i,j1) : (~VL)(j1,i) ) = CT( vl1, ( SO2 ? vl2 : -vl2 ) );
913 ( SO2 ? (~VL)(i,j2) : (~VL)(j2,i) ) = CT( vl1, ( SO2 ? -vl2 : vl2 ) );
914 ( SO3 ? (~VR)(i,j1) : (~VR)(j1,i) ) = CT( vr1, ( SO3 ? vr2 : -vr2 ) );
915 ( SO3 ? (~VR)(i,j2) : (~VR)(j2,i) ) = CT( vr1, ( SO3 ? -vr2 : vr2 ) );
921 for(
size_t i=0UL; i<N; ++i ) {
922 ( SO2 ? (~VL)(i,j) : (~VL)(j,i) ) = CT( vl[i+j*N] );
923 ( SO3 ? (~VR)(i,j) : (~VR)(j,i) ) = CT( vr[i+j*N] );
951 template<
typename MT1
959 inline auto geev_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& VL,
960 DenseVector<VT,TF>& w, DenseMatrix<MT3,SO3>& VR )
961 -> EnableIf_t< IsComplex_v< ElementType_t<MT1> > >
970 using CT = ElementType_t<MT1>;
971 using BT = UnderlyingElement_t<CT>;
976 int n ( numeric_cast<int>( (~A).
rows() ) );
977 int lda ( numeric_cast<int>( (~A).
spacing() ) );
978 int ldvl( numeric_cast<int>( (~VL).
spacing() ) );
979 int ldvr( numeric_cast<int>( (~VR).
spacing() ) );
982 int lwork( 2*n + 2 );
983 const std::unique_ptr<CT[]> work (
new CT[lwork] );
984 const std::unique_ptr<BT[]> rwork(
new BT[2*n] );
987 ( SO1 ? (~VL).
data() : (~VR).
data() ), ( SO1 ? ldvl : ldvr ),
988 ( SO1 ? (~VR).
data() : (~VL).
data() ), ( SO1 ? ldvr : ldvl ),
989 work.get(), lwork, rwork.get(), &info );
1079 template<
typename MT1
1112 const size_t N( (~A).
rows() );
1119 resize( ~VL, N, N,
false );
1120 resize( ~VR, N, N,
false );
1126 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
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_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.
Header file for the DenseVector base class.
Header file for the UnderlyingElement type trait.
Constraint on the data type.
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
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.The ElementType_t alias declaration provide...
Definition: Aliases.h:170
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
#define BLAZE_CONSTRAINT_MUST_BE_CONTIGUOUS_TYPE(T)
Constraint on the data type.In case the given data type T is not an array-like data type with contigu...
Definition: Contiguous.h:61
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.
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.
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
Constraint on the data type.
Header file for the EnableIf class template.
Header file for run time assertion macros.
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#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
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
#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
#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:1326
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
#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
bool equal(const SharedValue< T1 > &lhs, const SharedValue< T2 > &rhs)
Equality check for a two shared values.
Definition: SharedValue.h:342
Constraint on the data type.
Header file for the CLAPACK geev wrapper functions.