35#ifndef _BLAZE_MATH_LAPACK_HEEVX_H_
36#define _BLAZE_MATH_LAPACK_HEEVX_H_
74template<
typename MT,
bool SO,
typename VT,
bool TF >
75size_t heevx( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
char uplo );
77template<
typename MT,
bool SO,
typename VT,
bool TF,
typename ST >
78size_t heevx( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
char uplo, ST low, ST upp );
80template<
typename MT1,
bool SO1,
typename VT,
bool TF,
typename MT2,
bool SO2 >
81size_t heevx( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
82 DenseMatrix<MT2,SO2>& Z,
char uplo );
84template<
typename MT1,
bool SO1,
typename VT,
bool TF,
typename MT2,
bool SO2,
typename ST >
85size_t heevx( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
86 DenseMatrix<MT2,SO2>& Z,
char uplo, ST low, ST upp );
119inline size_t heevx_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
120 char uplo,
char range, ST vl, ST vu,
124 BLAZE_INTERNAL_ASSERT( range !=
'A' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
125 BLAZE_INTERNAL_ASSERT( range !=
'V' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
126 BLAZE_INTERNAL_ASSERT( range !=
'I' || (*w).size() ==
size_t( iu-il+1 ),
"Invalid vector dimension detected" );
128 using CT = ElementType_t<MT>;
129 using BT = UnderlyingElement_t<CT>;
134 blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
135 blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
140 const std::unique_ptr<CT[]> work (
new CT[lwork] );
141 const std::unique_ptr<BT[]> rwork(
new BT[7*n] );
142 const std::unique_ptr<blas_int_t[]> iwork(
new blas_int_t[5*n] );
143 const std::unique_ptr<blas_int_t[]> ifail(
new blas_int_t[n] );
145 heevx(
'N', range, uplo, n, (*A).data(), lda, vl, vu, il, iu, BT(0), &m, (*w).data(),
146 nullptr, 1, work.get(), lwork, rwork.get(), iwork.get(), ifail.get(), &info );
148 const size_t num( numeric_cast<size_t>( m ) );
241 const size_t N( (*A).rows() );
247 if( uplo !=
'L' && uplo !=
'U' ) {
257 return heevx_backend( *A, *w, uplo,
'A', BT(), BT(), 0, 0 );
372 if( IsFloatingPoint_v<ST> && low >= upp ) {
376 if( !IsFloatingPoint_v<ST> && low > upp ) {
380 const size_t N( (*A).rows() );
381 const size_t num( IsFloatingPoint_v<ST> ? N :
size_t( upp - low ) + 1UL );
383 if( !IsFloatingPoint_v<ST> && num > N ) {
387 if( uplo !=
'L' && uplo !=
'U' ) {
397 const char range( IsFloatingPoint_v<ST> ?
'V' :
'I' );
398 const ST vl ( IsFloatingPoint_v<ST> ? low : ST() );
399 const ST vu ( IsFloatingPoint_v<ST> ? upp : ST() );
400 const blas_int_t il ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( low ) );
401 const blas_int_t iu ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( upp ) );
403 return heevx_backend( *A, *w, uplo, range, vl, vu, il, iu );
432template<
typename MT1
439inline size_t heevx_backend( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
440 DenseMatrix<MT2,SO2>& Z,
char uplo,
char range,
444 BLAZE_INTERNAL_ASSERT( range !=
'A' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
445 BLAZE_INTERNAL_ASSERT( range !=
'V' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
446 BLAZE_INTERNAL_ASSERT( range !=
'I' || (*w).size() ==
size_t( iu-il+1 ),
"Invalid vector dimension detected" );
452 using CT = ElementType_t<MT1>;
453 using BT = UnderlyingElement_t<CT>;
458 blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
459 blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
461 blas_int_t ldz ( numeric_cast<blas_int_t>( (*Z).spacing() ) );
465 const std::unique_ptr<CT[]> work (
new CT[lwork] );
466 const std::unique_ptr<BT[]> rwork(
new BT[7*n] );
467 const std::unique_ptr<blas_int_t[]> iwork(
new blas_int_t[5*n] );
468 const std::unique_ptr<blas_int_t[]> ifail(
new blas_int_t[n] );
470 heevx(
'N', range, uplo, n, (*A).data(), lda, vl, vu, il, iu, BT(0), &m, (*w).data(),
471 (*Z).data(), ldz, work.get(), lwork, rwork.get(), iwork.get(), ifail.get(), &info );
473 const size_t num( numeric_cast<size_t>( m ) );
551template<
typename MT1
583 const size_t N( (*A).rows() );
589 if( uplo !=
'L' && uplo !=
'U' ) {
594 resize( *Z, N, N,
false );
600 return heevx_backend( *A, *w, *Z, uplo,
'A', BT(), BT(), 0, 0 );
701template<
typename MT1
735 if( IsFloatingPoint_v<ST> && low >= upp ) {
739 if( !IsFloatingPoint_v<ST> && low > upp ) {
743 const size_t N( (*A).rows() );
744 const size_t num( IsFloatingPoint_v<ST> ? N :
size_t( upp - low ) + 1UL );
746 if( !IsFloatingPoint_v<ST> && num > N ) {
750 if( uplo !=
'L' && uplo !=
'U' ) {
755 resize( *Z, ( IsRowMajorMatrix_v<MT2> ? num : N ),
756 ( IsRowMajorMatrix_v<MT2> ? N : num ),
false );
762 const char range( IsFloatingPoint_v<ST> ?
'V' :
'I' );
763 const ST vl ( IsFloatingPoint_v<ST> ? low : ST() );
764 const ST vu ( IsFloatingPoint_v<ST> ? upp : ST() );
765 const blas_int_t il ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( low ) );
766 const blas_int_t iu ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( upp ) );
768 return heevx_backend( *A, *w, *Z, uplo, range, vl, vu, il, iu );
Constraint on the data type.
Header file for auxiliary alias declarations.
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition: Aliases.h:190
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the IsFloatingPoint type trait.
Header file for the IsRowMajorMatrix type trait.
Constraint on the data type.
Cast operators for numeric types.
Header file for the CLAPACK heevx wrapper functions.
Base class for dense matrices.
Definition: DenseMatrix.h:82
Base class for N-dimensional dense vectors.
Definition: DenseVector.h:77
Constraint on the data type.
Constraint on the data type.
Header file for the DenseMatrix base class.
Header file for the DenseVector base class.
#define BLAZE_CONSTRAINT_MUST_BE_BUILTIN_TYPE(T)
Constraint on the data type.
Definition: Builtin.h:60
#define BLAZE_CONSTRAINT_MUST_BE_COMPLEX_TYPE(T)
Constraint on the data type.
Definition: Complex.h:62
size_t heevx(DenseMatrix< MT1, SO1 > &A, DenseVector< VT, TF > &w, DenseMatrix< MT2, SO2 > &Z, char uplo, ST low, ST upp)
LAPACK kernel for computing the eigenvalues of the given dense Hermitian matrix.
Definition: heevx.h:708
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_BE_CONTIGUOUS_TYPE(T)
Constraint on the data type.
Definition: Contiguous.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_ADAPTOR_TYPE(T)
Constraint on the data type.
Definition: Adaptor.h:81
#define BLAZE_CONSTRAINT_MUST_HAVE_MUTABLE_DATA_ACCESS(T)
Constraint on the data type.
Definition: MutableDataAccess.h:61
typename UnderlyingElement< T >::Type UnderlyingElement_t
Auxiliary alias declaration for the UnderlyingElement type trait.
Definition: UnderlyingElement.h:119
int32_t blas_int_t
Signed integer type used in the BLAS/LAPACK wrapper functions.
Definition: Types.h:64
#define BLAZE_THROW_LAPACK_ERROR(MESSAGE)
Macro for the emission of an exception on detection of a LAPACK error.
Definition: Exception.h:146
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
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
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for basic type definitions.