22#ifndef BELFEM_FN_GEES_HPP
23#define BELFEM_FN_GEES_HPP
146 template<
typename T >
152 template<
typename R >
158 template<
typename T >
167 template<
typename T >
186 "gees not implemented for selected data type" );
200 std::complex< float > * w,
210 const_cast< char *
>( jobvs ),
211 const_cast< char *
>(
sort ),
213 const_cast< int_t *
>( n ),
215 const_cast< int_t *
>( lda ),
220 const_cast< int_t *
>( ldvs ),
222 const_cast< int_t *
>( lwork ),
231 for (
int_t k = 0; k < *n; ++k )
233 w[ k ] = std::complex< float >( rwork[ k ], rwork[ k + *n ] );
249 std::complex< double > * w,
259 const_cast< char *
>( jobvs ),
260 const_cast< char *
>(
sort ),
262 const_cast< int_t *
>( n ),
264 const_cast< int_t *
>( lda ),
269 const_cast< int_t *
>( ldvs ),
271 const_cast< int_t *
>( lwork ),
278 for (
int_t k = 0; k < *n; ++k )
280 w[ k ] = std::complex< double >( rwork[ k ], rwork[ k + *n ] );
293 std::complex< float > * a,
296 std::complex< float > * w,
297 std::complex< float > * vs,
299 std::complex< float > * work,
306 const_cast< char *
>( jobvs ),
307 const_cast< char *
>(
sort ),
314 const_cast< int_t *
>( n ),
316 const_cast< int_t *
>( lda ),
320 const_cast< int_t *
>( ldvs ),
322 const_cast< int_t *
>( lwork ),
337 std::complex< double > * a,
340 std::complex< double > * w,
341 std::complex< double > * vs,
343 std::complex< double > * work,
350 const_cast< char *
>( jobvs ),
351 const_cast< char *
>(
sort ),
353 const_cast< int_t *
>( n ),
355 const_cast< int_t *
>( lda ),
359 const_cast< int_t *
>( ldvs ),
361 const_cast< int_t *
>( lwork ),
411 template<
typename T >
420 const char jobvs =
'V',
421 const char sort =
'N',
422 int_t * aSdim =
nullptr,
423 const bool AbortOnError =
true )
426 "Matrix A must be square ( is %lu x %lu )",
427 (
long unsigned int ) A.
n_rows(),
428 (
long unsigned int ) A.
n_cols() );
430 "unsupported jobvs flag '%c'", jobvs );
432 "unsupported sort flag '%c'",
sort );
434 "sort = 'S' requires a select callback, sort = 'N' forbids it" );
437 constexpr int_t tRealsPerT =
438 std::is_same< T, lapack::real_t< T > >
::value ? 1 : 2 ;
460 const int_t tTail = ( tRealsPerT == 1 ) ? 2 * n : n ;
463 int_t lwork = std::max< int_t >( 1, tRealsPerT == 1 ? 3 * n : 2 * n );
469 if (
static_cast< int_t >( Work.length() ) < tRealsPerT * lwork + tTail )
472 Work.set_size( tRealsPerT + tTail );
477 W.data(), VS.
data(), &ldvs,
478 reinterpret_cast< T *
>( Work.data() ), &query,
479 Work.data() + tRealsPerT, BWork.
data(), &info );
482 "LAPACK gees workspace query has thrown an error: %i", (
int ) info );
484 if ( info != 0 )
return info ;
489 Work.set_size( tRealsPerT * lwork + tTail );
494 lwork = ( (
int_t ) Work.length() - tTail ) / tRealsPerT ;
499 W.data(), VS.
data(), &ldvs,
500 reinterpret_cast< T *
>( Work.data() ), &lwork,
501 Work.data() + tRealsPerT * lwork, BWork.
data(), &info );
504 "LAPACK gees has thrown an error: %i", (
int ) info );
506 if ( aSdim !=
nullptr )
#define BELFEM_ERROR(aCheck,...)
Definition assert.hpp:264
#define BELFEM_ASSERT(aCheck,...)
Definition assert.hpp:244
Dense column-major matrix.
Definition cl_BZ_Matrix.hpp:28
void set_size(const size_t aNumRows, const size_t aNumCols)
Definition cl_AR_Matrix.hpp:186
size_t n_rows() const
Definition cl_AR_Matrix.hpp:205
size_t n_cols() const
Definition cl_AR_Matrix.hpp:213
T * data()
Definition cl_AR_Matrix.hpp:135
Column vector.
Definition cl_BZ_Vector.hpp:41
T * data()
expose the underlying raw pointer ( writable version )
Definition cl_AR_Vector.hpp:182
void set_size(const size_t aNumRows)
change the size of the vector
Definition cl_AR_Vector.hpp:237
size_t length() const
get the length of the vector
Definition cl_AR_Vector.hpp:257
Definition fn_gees.hpp:33
void sgees_(char *jobvs, char *sort, sgees_select_t select, int_t *n, float *a, int_t *lda, int_t *sdim, float *wr, float *wi, float *vs, int_t *ldvs, float *work, int_t *lwork, int_t *bwork, int_t *info, fortran_charlen_t lj, fortran_charlen_t ls)
constexpr bool dependent_false
Definition lapacktools.hpp:49
float cplx_float_t
Definition lapacktools.hpp:90
int_t leading_dimension(const Vector< T > &A)
logical length of a vector operand, as passed to LAPACK as LDB; vector storage is contiguous under bo...
Definition lapacktools.hpp:143
void zgees_(char *jobvs, char *sort, zgees_select_t select, int_t *n, cplx_double_t *a, int_t *lda, int_t *sdim, cplx_double_t *w, cplx_double_t *vs, int_t *ldvs, cplx_double_t *work, int_t *lwork, double *rwork, int_t *bwork, int_t *info, fortran_charlen_t lj, fortran_charlen_t ls)
int_t work_size(const float &aValue)
lapack reports the optimal work size in the first entry of the work array, which stays real valued fo...
Definition lapacktools.hpp:191
void dgees_(char *jobvs, char *sort, dgees_select_t select, int_t *n, double *a, int_t *lda, int_t *sdim, double *wr, double *wi, double *vs, int_t *ldvs, double *work, int_t *lwork, int_t *bwork, int_t *info, fortran_charlen_t lj, fortran_charlen_t ls)
size_t fortran_charlen_t
Definition lapacktools.hpp:100
void gees(const char *jobvs, const char *sort, gees_select_t< T > select, const int_t *n, T *a, const int_t *lda, int_t *sdim, cplx_t< T > *w, T *vs, const int_t *ldvs, T *work, const int_t *lwork, real_t< T > *rwork, int_t *bwork, int_t *info)
Definition fn_gees.hpp:168
int_t(*) sgees_select_t(const float *, const float *)
Definition fn_gees.hpp:48
double cplx_double_t
Definition lapacktools.hpp:91
typename real_type< T >::type real_t
Definition lapacktools.hpp:63
int_t(*) dgees_select_t(const double *, const double *)
Definition fn_gees.hpp:49
void cgees_(char *jobvs, char *sort, cgees_select_t select, int_t *n, cplx_float_t *a, int_t *lda, int_t *sdim, cplx_float_t *w, cplx_float_t *vs, int_t *ldvs, cplx_float_t *work, int_t *lwork, float *rwork, int_t *bwork, int_t *info, fortran_charlen_t lj, fortran_charlen_t ls)
typename gees_select< T >::type gees_select_t
Definition fn_gees.hpp:159
typename cplx_type< T >::type cplx_t
Definition lapacktools.hpp:75
int_t(*) zgees_select_t(const cplx_double_t *)
Definition fn_gees.hpp:51
int_t(*) cgees_select_t(const cplx_float_t *)
Definition fn_gees.hpp:50
USER GUIDES:
Definition cl_Capacitor.cpp:16
std::pair< real, unit > value
Definition typedefs.hpp:74
int_t gees(Matrix< T > &A, Vector< lapack::cplx_t< T > > &W, Matrix< T > &VS, Vector< lapack::real_t< T > > &Work, Vector< int_t > &BWork, lapack::gees_select_t< T > select=nullptr, const char jobvs='V', const char sort='N', int_t *aSdim=nullptr, const bool AbortOnError=true)
Schur decomposition of a general square matrix via LAPACK ?gees: A = Z * T * Z^T for the real flavors...
Definition fn_gees.hpp:413
void sort(Cell< T > &aCell)
Definition cl_Cell.hpp:455
int32_t int_t
Definition typedefs.hpp:51
int_t(*) type(const std::complex< R > *)
Definition fn_gees.hpp:155
Definition fn_gees.hpp:148
int_t(*) type(const T *, const T *)
Definition fn_gees.hpp:149