35#ifndef _BLAZE_MATH_LAPACK_SYEVX_H_
36#define _BLAZE_MATH_LAPACK_SYEVX_H_
73template<
typename MT,
bool SO,
typename VT,
bool TF >
74size_t syevx( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
char uplo );
76template<
typename MT,
bool SO,
typename VT,
bool TF,
typename ST >
77size_t syevx( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
char uplo, ST low, ST upp );
79template<
typename MT1,
bool SO1,
typename VT,
bool TF,
typename MT2,
bool SO2 >
80size_t syevx( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
81 DenseMatrix<MT2,SO2>& Z,
char uplo );
83template<
typename MT1,
bool SO1,
typename VT,
bool TF,
typename MT2,
bool SO2,
typename ST >
84size_t syevx( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
85 DenseMatrix<MT2,SO2>& Z,
char uplo, ST low, ST upp );
118inline size_t syevx_backend( DenseMatrix<MT,SO>& A, DenseVector<VT,TF>& w,
119 char uplo,
char range, ST vl, ST vu,
123 BLAZE_INTERNAL_ASSERT( range !=
'A' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
124 BLAZE_INTERNAL_ASSERT( range !=
'V' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
125 BLAZE_INTERNAL_ASSERT( range !=
'I' || (*w).size() ==
size_t( iu-il+1 ),
"Invalid vector dimension detected" );
127 using ET = ElementType_t<MT>;
131 blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
132 blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
137 const std::unique_ptr<ET[]> work (
new ET[lwork] );
138 const std::unique_ptr<blas_int_t[]> iwork(
new blas_int_t[12*n] );
139 const std::unique_ptr<blas_int_t[]> ifail(
new blas_int_t[n] );
141 syevx(
'N', range, uplo, n, (*A).data(), lda, vl, vu, il, iu, ET(0), &m,
142 (*w).data(),
nullptr, 1, work.get(), lwork, iwork.get(), ifail.get(), &info );
144 const size_t num( numeric_cast<size_t>( m ) );
236 const size_t N( (*A).rows() );
242 if( uplo !=
'L' && uplo !=
'U' ) {
252 return syevx_backend( *A, *w, uplo,
'A', ET(), ET(), 0, 0 );
367 if( uplo !=
'L' && uplo !=
'U' ) {
371 if( IsFloatingPoint_v<ST> && low >= upp ) {
375 if( !IsFloatingPoint_v<ST> && low > upp ) {
379 const size_t N( (*A).rows() );
380 const size_t num( IsFloatingPoint_v<ST> ? N :
size_t( upp - low ) + 1UL );
382 if( !IsFloatingPoint_v<ST> && num > N ) {
392 const char range( IsFloatingPoint_v<ST> ?
'V' :
'I' );
393 const ST vl ( IsFloatingPoint_v<ST> ? low : ST() );
394 const ST vu ( IsFloatingPoint_v<ST> ? upp : ST() );
395 const blas_int_t il ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( low ) );
396 const blas_int_t iu ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( upp ) );
398 return syevx_backend( *A, *w, uplo, range, vl, vu, il, iu );
427template<
typename MT1
434inline size_t syevx_backend( DenseMatrix<MT1,SO1>& A, DenseVector<VT,TF>& w,
435 DenseMatrix<MT2,SO2>& Z,
char uplo,
char range,
439 BLAZE_INTERNAL_ASSERT( range !=
'A' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
440 BLAZE_INTERNAL_ASSERT( range !=
'V' || (*w).size() == (*A).rows(),
"Invalid vector dimension detected" );
441 BLAZE_INTERNAL_ASSERT( range !=
'I' || (*w).size() ==
size_t( iu-il+1 ),
"Invalid vector dimension detected" );
447 using ET = ElementType_t<MT1>;
451 blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
452 blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
454 blas_int_t ldz ( numeric_cast<blas_int_t>( (*Z).spacing() ) );
458 const std::unique_ptr<ET[]> work (
new ET[lwork] );
459 const std::unique_ptr<blas_int_t[]> iwork(
new blas_int_t[12*n] );
460 const std::unique_ptr<blas_int_t[]> ifail(
new blas_int_t[n] );
462 syevx(
'N', range, uplo, n, (*A).data(), lda, vl, vu, il, iu, ET(0), &m,
463 (*w).data(), (*Z).data(), ldz, work.get(), lwork, iwork.get(), ifail.get(), &info );
465 const size_t num( numeric_cast<size_t>( m ) );
543template<
typename MT1
574 const size_t N( (*A).rows() );
580 if( uplo !=
'L' && uplo !=
'U' ) {
585 resize( *Z, N, N,
false );
591 return syevx_backend( *A, *w, *Z, uplo,
'A', ET(), ET(), 0, 0 );
692template<
typename MT1
726 if( uplo !=
'L' && uplo !=
'U' ) {
730 if( IsFloatingPoint_v<ST> && low >= upp ) {
734 if( !IsFloatingPoint_v<ST> && low > upp ) {
738 const size_t N( (*A).rows() );
739 const size_t num( IsFloatingPoint_v<ST> ? N :
size_t( upp - low ) + 1UL );
741 if( !IsFloatingPoint_v<ST> && num > N ) {
746 resize( *Z, ( IsRowMajorMatrix_v<MT2> ? num : N ),
747 ( IsRowMajorMatrix_v<MT2> ? N : num ),
false );
753 const char range( IsFloatingPoint_v<ST> ?
'V' :
'I' );
754 const ST vl ( IsFloatingPoint_v<ST> ? low : ST() );
755 const ST vu ( IsFloatingPoint_v<ST> ? upp : ST() );
756 const blas_int_t il ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( low ) );
757 const blas_int_t iu ( IsFloatingPoint_v<ST> ? 0 : numeric_cast<blas_int_t>( upp ) );
759 return syevx_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 syevx 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.
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
size_t syevx(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 symmetric matrix.
Definition: syevx.h:699
#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
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.