ColPivHouseholderQR_LAPACKE.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2011, Intel Corporation. All rights reserved.
3 
4  Redistribution and use in source and binary forms, with or without modification,
5  are permitted provided that the following conditions are met:
6 
7  * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice,
10  this list of conditions and the following disclaimer in the documentation
11  and/or other materials provided with the distribution.
12  * Neither the name of Intel Corporation nor the names of its contributors may
13  be used to endorse or promote products derived from this software without
14  specific prior written permission.
15 
16  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27  ********************************************************************************
28  * Content : Eigen bindings to LAPACKe
29  * Householder QR decomposition of a matrix with column pivoting based on
30  * LAPACKE_?geqp3 function.
31  ********************************************************************************
32 */
33 
34 #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H
35 #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H
36 
37 namespace Eigen {
38 
41 #define EIGEN_LAPACKE_QR_COLPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW) \
42 template<> template<typename InputType> inline \
43 ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >& \
44 ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >::compute( \
45  const EigenBase<InputType>& matrix) \
46 \
47 { \
48  using std::abs; \
49  typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
50  typedef MatrixType::RealScalar RealScalar; \
51  Index rows = matrix.rows();\
52  Index cols = matrix.cols();\
53 \
54  m_qr = matrix;\
55  Index size = m_qr.diagonalSize();\
56  m_hCoeffs.resize(size);\
57 \
58  m_colsTranspositions.resize(cols);\
59  /*Index number_of_transpositions = 0;*/ \
60 \
61  m_nonzero_pivots = 0; \
62  m_maxpivot = RealScalar(0);\
63  m_colsPermutation.resize(cols); \
64  m_colsPermutation.indices().setZero(); \
65 \
66  lapack_int lda = internal::convert_index<lapack_int,Index>(m_qr.outerStride()); \
67  lapack_int matrix_order = LAPACKE_COLROW; \
68  LAPACKE_##LAPACKE_PREFIX##geqp3( matrix_order, internal::convert_index<lapack_int,Index>(rows), internal::convert_index<lapack_int,Index>(cols), \
69  (LAPACKE_TYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (LAPACKE_TYPE*)m_hCoeffs.data()); \
70  m_isInitialized = true; \
71  m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \
72  m_hCoeffs.adjointInPlace(); \
73  RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \
74  lapack_int *perm = m_colsPermutation.indices().data(); \
75  for(Index i=0;i<size;i++) { \
76  m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\
77  } \
78  for(Index i=0;i<cols;i++) perm[i]--;\
79 \
80  /*m_det_pq = (number_of_transpositions%2) ? -1 : 1; // TODO: It's not needed now; fix upon availability in Eigen */ \
81 \
82  return *this; \
83 }
84 
89 
94 
95 } // end namespace Eigen
96 
97 #endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_LAPACKE_H
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
s
RealScalar s
Definition: level1_cplx_impl.h:126
d
static const double d[K][N]
Definition: igam.h:11
LAPACK_COL_MAJOR
#define LAPACK_COL_MAJOR
Definition: lapacke.h:123
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Eigen::RowMajor
@ RowMajor
Definition: Constants.h:321
LAPACK_ROW_MAJOR
#define LAPACK_ROW_MAJOR
Definition: lapacke.h:122
lapack_complex_float
#define lapack_complex_float
Definition: lapacke.h:76
Eigen::scomplex
std::complex< float > scomplex
Definition: MKL_support.h:126
Eigen::dcomplex
std::complex< double > dcomplex
Definition: MKL_support.h:125
lapack_complex_double
#define lapack_complex_double
Definition: lapacke.h:92
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
EIGEN_LAPACKE_QR_COLPIV
#define EIGEN_LAPACKE_QR_COLPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX, EIGCOLROW, LAPACKE_COLROW)
Definition: ColPivHouseholderQR_LAPACKE.h:41
Eigen::ColMajor
@ ColMajor
Definition: Constants.h:319


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:15