35#ifndef _BLAZE_MATH_LAPACK_GGES_H_
36#define _BLAZE_MATH_LAPACK_GGES_H_
77template<
typename MT1,
bool SO1,
typename MT2,
bool SO2
78 ,
typename VT1,
bool TF1,
typename VT2,
bool TF2 >
79void gges( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
80 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta );
82template<
typename MT1,
bool SO1,
typename MT2,
bool SO2
83 ,
typename VT1,
bool TF1,
typename VT2,
bool TF2
85void gges( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
86 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta,
89template<
typename MT1,
bool SO1,
typename MT2,
bool SO2,
typename MT3,
bool SO3
90 ,
typename VT1,
bool TF1,
typename VT2,
bool TF2,
typename MT4,
bool SO4 >
91void gges( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B, DenseMatrix<MT3,SO3>& VSL,
92 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta, DenseMatrix<MT4,SO4>& VSR );
94template<
typename MT1,
bool SO1,
typename MT2,
bool SO2,
typename MT3,
bool SO3
95 ,
typename VT1,
bool TF1,
typename VT2,
bool TF2,
typename MT4,
bool SO4
97void gges( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B, DenseMatrix<MT3,SO3>& VSL,
98 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta, DenseMatrix<MT4,SO4>& VSR,
124template<
typename MT1
133inline auto gges_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
134 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta,
136 -> DisableIf_t< IsComplex_v< ElementType_t<MT1> > >
144 using CT = ElementType_t<VT1>;
145 using BT = ElementType_t<MT1>;
150 const blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
151 const blas_int_t lda( numeric_cast<blas_int_t>( (*A).spacing() ) );
152 const blas_int_t ldb( numeric_cast<blas_int_t>( (*B).spacing() ) );
157 const std::unique_ptr<BT[]> alphar(
new BT[n] );
158 const std::unique_ptr<BT[]> alphai(
new BT[n] );
159 const std::unique_ptr<BT[]> work(
new BT[
max(1,lwork)] );
160 const std::unique_ptr<blas_int_t[]> bwork(
select ?
new blas_int_t[n] :
nullptr );
162 gges(
'N',
'N', (
select ?
'S' :
'N' ),
select, n, (*A).data(), lda, (*B).data(), ldb, &sdim,
163 alphar.get(), alphai.get(), (*beta).data(),
nullptr, 1,
nullptr, 1,
164 work.get(), lwork, bwork.get(), &info );
172 for(
size_t i=0UL; i<(*A).rows(); ++i ) {
173 (*alpha)[i] = CT( alphar[i], alphai[i] );
200template<
typename MT1
209inline auto gges_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
210 DenseVector<VT1,TF1>& alpha, DenseVector<VT2,TF2>& beta,
212 -> EnableIf_t< IsComplex_v< ElementType_t<MT1> > >
220 using CT = ElementType_t<VT1>;
221 using BT =
typename CT::value_type;
226 const blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
227 const blas_int_t lda( numeric_cast<blas_int_t>( (*A).spacing() ) );
228 const blas_int_t ldb( numeric_cast<blas_int_t>( (*B).spacing() ) );
233 const std::unique_ptr<CT[]> work(
new CT[
max(1,lwork)] );
234 const std::unique_ptr<BT[]> rwork(
new BT[8*n] );
235 const std::unique_ptr<blas_int_t[]> bwork(
select ?
new blas_int_t[n] :
nullptr );
237 gges(
'N',
'N', (
select ?
'S' :
'N' ),
select, n, (*A).data(), lda, (*B).data(), ldb, &sdim,
238 (*alpha).data(), (*beta).data(),
nullptr, 1,
nullptr, 1,
239 work.get(), lwork, rwork.get(), bwork.get(), &info );
318template<
typename MT1
352 const size_t N( (*A).rows() );
358 resize( *B, N, N,
false );
359 resize( *alpha, N,
false );
360 resize( *beta, N,
false );
366 gges_backend( *A, *B, *alpha, *beta,
nullptr );
451template<
typename MT1
487 const size_t N( (*A).rows() );
493 resize( *B, N, N,
false );
494 resize( *alpha, N,
false );
495 resize( *beta, N,
false );
501 gges_backend( *A, *B, *alpha, *beta,
select );
528template<
typename MT1
541inline auto gges_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
542 DenseMatrix<MT3,SO3>& VSL, DenseVector<VT1,TF1>& alpha,
543 DenseVector<VT2,TF2>& beta, DenseMatrix<MT4,SO4>& VSR,
545 -> DisableIf_t< IsComplex_v< ElementType_t<MT1> > >
557 using CT = ElementType_t<VT1>;
558 using BT = ElementType_t<MT1>;
563 const blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
564 const blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
565 const blas_int_t ldb ( numeric_cast<blas_int_t>( (*B).spacing() ) );
566 const blas_int_t ldvsl( numeric_cast<blas_int_t>( (*VSL).spacing() ) );
567 const blas_int_t ldvsr( numeric_cast<blas_int_t>( (*VSR).spacing() ) );
572 const std::unique_ptr<BT[]> alphar(
new BT[n] );
573 const std::unique_ptr<BT[]> alphai(
new BT[n] );
574 const std::unique_ptr<BT[]> work(
new BT[
max(1, lwork)] );
575 const std::unique_ptr<blas_int_t[]> bwork(
select ?
new blas_int_t[n] :
nullptr );
577 gges(
'V',
'V', (
select ?
'S' :
'N' ),
select, n, (*A).data(), lda, (*B).data(), ldb, &sdim,
578 alphar.get(), alphai.get(), (*beta).data(), (*VSL).data(), ldvsl, (*VSR).data(), ldvsr,
579 work.get(), lwork, bwork.get(), &info );
587 for(
size_t i=0UL; i<(*A).rows(); ++i ) {
588 (*alpha)[i] = CT( alphar[i], alphai[i] );
617template<
typename MT1
630inline auto gges_backend( DenseMatrix<MT1,SO1>& A, DenseMatrix<MT2,SO2>& B,
631 DenseMatrix<MT3,SO3>& VSL, DenseVector<VT1,TF1>& alpha,
632 DenseVector<VT2,TF2>& beta, DenseMatrix<MT4,SO4>& VSR,
634 -> EnableIf_t< IsComplex_v< ElementType_t<MT1> > >
646 using CT = ElementType_t<VT1>;
647 using BT =
typename CT::value_type;
652 const blas_int_t n ( numeric_cast<blas_int_t>( (*A).rows() ) );
653 const blas_int_t lda ( numeric_cast<blas_int_t>( (*A).spacing() ) );
654 const blas_int_t ldb ( numeric_cast<blas_int_t>( (*B).spacing() ) );
655 const blas_int_t ldvsl( numeric_cast<blas_int_t>( (*VSL).spacing() ) );
656 const blas_int_t ldvsr( numeric_cast<blas_int_t>( (*VSR).spacing() ) );
661 const std::unique_ptr<CT[]> work(
new CT[
max(1,lwork)] );
662 const std::unique_ptr<BT[]> rwork(
new BT[8*n] );
663 const std::unique_ptr<blas_int_t[]> bwork(
select ?
new blas_int_t[n] :
nullptr );
665 gges(
'V',
'V', (
select ?
'S' :
'N' ),
select, n, (*A).data(), lda, (*B).data(), ldb, &sdim,
666 (*alpha).data(), (*beta).data(), (*VSL).data(), ldvsl, (*VSR).data(), ldvsr,
667 work.get(), lwork, rwork.get(), bwork.get(), &info );
761template<
typename MT1
812 const size_t N( (*A).rows() );
818 if( (*A).rows() != (*B).rows() || (*A).columns() != (*B).columns() ) {
822 resize( *VSL, N, N,
false );
823 resize( *alpha, N,
false );
824 resize( *beta, N,
false );
825 resize( *VSR, N, N,
false );
831 gges_backend( *A, *B, *VSL, *alpha, *beta, *VSR,
nullptr );
932template<
typename MT1
985 const size_t N( (*A).rows() );
991 resize( *B, N, N,
false );
992 resize( *VSL, N, N,
false );
993 resize( *alpha, N,
false );
994 resize( *beta, N,
false );
995 resize( *VSR, N, N,
false );
1001 gges_backend( *A, *B, *VSL, *alpha, *beta, *VSR,
select );
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.
Header file for the complex data type.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsComplex type trait.
Deactivation of problematic macros.
Constraint on the data type.
Cast operators for numeric types.
Header file for the CLAPACK gges 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
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
decltype(auto) select(const DenseMatrix< MT1, SO > &cond, const DenseMatrix< MT2, SO > &lhs, const DenseMatrix< MT3, SO > &rhs)
Elementwise conditional selection of values from the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1528
void gges(DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO2 > &B, DenseMatrix< MT3, SO3 > &VSL, DenseVector< VT1, TF1 > &alpha, DenseVector< VT2, TF2 > &beta, DenseMatrix< MT4, SO4 > &VSR, Select select)
LAPACK kernel for computing the generalized Schur factorization of the given pair of dense general ma...
Definition: gges.h:945
#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 the equal shim.
Header file for the generic max algorithm.