34 #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H
35 #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H
42 #if defined(EIGEN_USE_LAPACKE)
44 template <
typename Scalar>
68 template <
typename MatrixType>
69 struct ColPivHouseholderQR_LAPACKE_impl {
76 typedef PermutationMatrix<Dynamic, Dynamic, lapack_int> PermutationType;
78 static void run(
MatrixType&
qr, HCoeffsType& hCoeffs, PermutationType& colsPermutation,
Index& nonzero_pivots,
80 bool& isInitialized) {
81 isInitialized =
false;
82 hCoeffs.resize(
qr.diagonalSize());
85 colsPermutation.resize(
qr.cols());
86 colsPermutation.indices().setZero();
90 LapackeType* qr_data = (LapackeType*)(
qr.data());
92 lapack_int* perm_data = colsPermutation.indices().data();
93 LapackeType* hCoeffs_data = (LapackeType*)(hCoeffs.data());
96 if (
info != 0)
return;
98 maxpivot =
qr.diagonal().cwiseAbs().maxCoeff();
99 hCoeffs.adjointInPlace();
101 RealScalar threshold = usePrescribedThreshold ? prescribedThreshold : defaultThreshold;
102 RealScalar premultiplied_threshold = maxpivot * threshold;
103 nonzero_pivots = (
qr.diagonal().cwiseAbs().array() > premultiplied_threshold).count();
104 colsPermutation.indices().array() -= 1;
105 det_p = colsPermutation.determinant();
106 isInitialized =
true;
110 bool& usePrescribedThreshold,
bool& isInitialized) {
112 hCoeffs.resize(
diag);
113 colsPermutation.resize(
cols);
114 usePrescribedThreshold =
false;
115 isInitialized =
false;
119 #define COLPIVQR_LAPACKE_COMPUTEINPLACE(EIGTYPE) \
121 inline void ColPivHouseholderQR<EIGTYPE, lapack_int>::computeInPlace() { \
122 ColPivHouseholderQR_LAPACKE_impl<MatrixType>::run(m_qr, m_hCoeffs, m_colsPermutation, m_nonzero_pivots, \
123 m_maxpivot, m_usePrescribedThreshold, m_prescribedThreshold, \
124 m_det_p, m_isInitialized); \
127 #define COLPIVQR_LAPACKE_INIT(EIGTYPE) \
129 inline void ColPivHouseholderQR<EIGTYPE, lapack_int>::init(Index rows, Index cols) { \
130 ColPivHouseholderQR_LAPACKE_impl<MatrixType>::init(rows, cols, m_hCoeffs, m_colsPermutation, m_isInitialized, \
131 m_usePrescribedThreshold); \
134 #define COLPIVQR_LAPACKE(EIGTYPE) \
135 COLPIVQR_LAPACKE_COMPUTEINPLACE(EIGTYPE) \
136 COLPIVQR_LAPACKE_INIT(EIGTYPE) \
137 COLPIVQR_LAPACKE_COMPUTEINPLACE(Ref<EIGTYPE>) \
138 COLPIVQR_LAPACKE_INIT(Ref<EIGTYPE>)
140 typedef Matrix<float, Dynamic, Dynamic, ColMajor> MatrixXfC;
141 typedef Matrix<double, Dynamic, Dynamic, ColMajor> MatrixXdC;
144 typedef Matrix<float, Dynamic, Dynamic, RowMajor> MatrixXfR;
145 typedef Matrix<double, Dynamic, Dynamic, RowMajor> MatrixXdR;
149 COLPIVQR_LAPACKE(MatrixXfC)
150 COLPIVQR_LAPACKE(MatrixXdC)
151 COLPIVQR_LAPACKE(MatrixXcfC)
152 COLPIVQR_LAPACKE(MatrixXcdC)
153 COLPIVQR_LAPACKE(MatrixXfR)
154 COLPIVQR_LAPACKE(MatrixXdR)
155 COLPIVQR_LAPACKE(MatrixXcfR)
156 COLPIVQR_LAPACKE(MatrixXcdR)
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
HouseholderQR< MatrixXf > qr(A)
int rows
Definition: Tutorial_commainit_02.cpp:1
int cols
Definition: Tutorial_commainit_02.cpp:1
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
@ ColMajor
Definition: Constants.h:318
@ RowMajor
Definition: Constants.h:320
#define LAPACK_COL_MAJOR
Definition: lapacke.h:124
lapack_int LAPACKE_sgeqp3(int matrix_order, lapack_int m, lapack_int n, float *a, lapack_int lda, lapack_int *jpvt, float *tau)
#define lapack_int
Definition: lapacke.h:52
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:123
lapack_int LAPACKE_zgeqp3(int matrix_order, lapack_int m, lapack_int n, lapack_complex_double *a, lapack_int lda, lapack_int *jpvt, lapack_complex_double *tau)
lapack_int LAPACKE_dgeqp3(int matrix_order, lapack_int m, lapack_int n, double *a, lapack_int lda, lapack_int *jpvt, double *tau)
#define lapack_complex_double
Definition: lapacke.h:94
#define lapack_complex_float
Definition: lapacke.h:79
lapack_int LAPACKE_cgeqp3(int matrix_order, lapack_int m, lapack_int n, lapack_complex_float *a, lapack_int lda, lapack_int *jpvt, lapack_complex_float *tau)
const Scalar * a
Definition: level2_cplx_impl.h:32
const char const int const RealScalar const RealScalar const int * lda
Definition: level2_cplx_impl.h:20
int * m
Definition: level2_cplx_impl.h:294
int info
Definition: level2_cplx_impl.h:39
const char const char const char * diag
Definition: level2_impl.h:86
EIGEN_ALWAYS_INLINE auto to_lapack(Source value)
Definition: lapacke_helpers.h:61
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: MathFunctions.h:920
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:70
auto run(Kernel kernel, Args &&... args) -> decltype(kernel(args...))
Definition: gpu_test_helper.h:414
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
const int Dynamic
Definition: Constants.h:25
type
Definition: compute_granudrum_aor.py:141
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43
std::conditional_t< is_same< typename traits< MatrixType >::XprKind, MatrixXpr >::value, MatrixDiagType, ArrayDiagType > type
Definition: XprHelper.h:797
Definition: TutorialInplaceLU.cpp:2