mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Improved lapacke binding code for HouseholderQR and PartialPivLU
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
7ef5f0641f
commit
d60f7fa518
@@ -40,28 +40,35 @@ namespace Eigen {
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \internal Specialization for the data types supported by LAPACKe */
|
||||
namespace lapacke_helpers {
|
||||
|
||||
#define EIGEN_LAPACKE_QR_NOPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \
|
||||
template<typename MatrixQR, typename HCoeffs> \
|
||||
struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \
|
||||
{ \
|
||||
static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \
|
||||
typename MatrixQR::Scalar* = 0) \
|
||||
{ \
|
||||
lapack_int m = (lapack_int) mat.rows(); \
|
||||
lapack_int n = (lapack_int) mat.cols(); \
|
||||
lapack_int lda = (lapack_int) mat.outerStride(); \
|
||||
lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
|
||||
LAPACKE_##LAPACKE_PREFIX##geqrf( matrix_order, m, n, (LAPACKE_TYPE*)mat.data(), lda, (LAPACKE_TYPE*)hCoeffs.data()); \
|
||||
hCoeffs.adjointInPlace(); \
|
||||
} \
|
||||
template<typename MatrixQR, typename HCoeffs>
|
||||
struct lapacke_hqr
|
||||
{
|
||||
static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, typename MatrixQR::Scalar* = 0)
|
||||
{
|
||||
lapack_int m = to_lapack(mat.rows());
|
||||
lapack_int n = to_lapack(mat.cols());
|
||||
lapack_int lda = to_lapack(mat.outerStride());
|
||||
lapack_int matrix_order = lapack_storage_of(mat);
|
||||
geqrf(matrix_order, m, n, to_lapack(mat.data()), lda, to_lapack(hCoeffs.data()));
|
||||
hCoeffs.adjointInPlace();
|
||||
}
|
||||
};
|
||||
|
||||
EIGEN_LAPACKE_QR_NOPIV(double, double, d)
|
||||
EIGEN_LAPACKE_QR_NOPIV(float, float, s)
|
||||
EIGEN_LAPACKE_QR_NOPIV(dcomplex, lapack_complex_double, z)
|
||||
EIGEN_LAPACKE_QR_NOPIV(scomplex, lapack_complex_float, c)
|
||||
}
|
||||
|
||||
/** \internal Specialization for the data types supported by LAPACKe */
|
||||
#define EIGEN_LAPACKE_HH_QR(EIGTYPE) \
|
||||
template<typename MatrixQR, typename HCoeffs> \
|
||||
struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> : public lapacke_helpers::lapacke_hqr<MatrixQR, HCoeffs> {};
|
||||
|
||||
EIGEN_LAPACKE_HH_QR(double)
|
||||
EIGEN_LAPACKE_HH_QR(float)
|
||||
EIGEN_LAPACKE_HH_QR(std::complex<double>)
|
||||
EIGEN_LAPACKE_HH_QR(std::complex<float>)
|
||||
|
||||
#undef EIGEN_LAPACKE_HH_QR
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
|
||||
Reference in New Issue
Block a user