xref: /aosp_15_r20/external/eigen/Eigen/src/QR/HouseholderQR_LAPACKE.h (revision bf2c37156dfe67e5dfebd6d394bad8b2ab5804d4)
1*bf2c3715SXin Li /*
2*bf2c3715SXin Li  Copyright (c) 2011, Intel Corporation. All rights reserved.
3*bf2c3715SXin Li 
4*bf2c3715SXin Li  Redistribution and use in source and binary forms, with or without modification,
5*bf2c3715SXin Li  are permitted provided that the following conditions are met:
6*bf2c3715SXin Li 
7*bf2c3715SXin Li  * Redistributions of source code must retain the above copyright notice, this
8*bf2c3715SXin Li    list of conditions and the following disclaimer.
9*bf2c3715SXin Li  * Redistributions in binary form must reproduce the above copyright notice,
10*bf2c3715SXin Li    this list of conditions and the following disclaimer in the documentation
11*bf2c3715SXin Li    and/or other materials provided with the distribution.
12*bf2c3715SXin Li  * Neither the name of Intel Corporation nor the names of its contributors may
13*bf2c3715SXin Li    be used to endorse or promote products derived from this software without
14*bf2c3715SXin Li    specific prior written permission.
15*bf2c3715SXin Li 
16*bf2c3715SXin Li  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17*bf2c3715SXin Li  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18*bf2c3715SXin Li  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19*bf2c3715SXin Li  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20*bf2c3715SXin Li  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21*bf2c3715SXin Li  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22*bf2c3715SXin Li  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23*bf2c3715SXin Li  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24*bf2c3715SXin Li  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25*bf2c3715SXin Li  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*bf2c3715SXin Li 
27*bf2c3715SXin Li  ********************************************************************************
28*bf2c3715SXin Li  *   Content : Eigen bindings to LAPACKe
29*bf2c3715SXin Li  *    Householder QR decomposition of a matrix w/o pivoting based on
30*bf2c3715SXin Li  *    LAPACKE_?geqrf function.
31*bf2c3715SXin Li  ********************************************************************************
32*bf2c3715SXin Li */
33*bf2c3715SXin Li 
34*bf2c3715SXin Li #ifndef EIGEN_QR_LAPACKE_H
35*bf2c3715SXin Li #define EIGEN_QR_LAPACKE_H
36*bf2c3715SXin Li 
37*bf2c3715SXin Li namespace Eigen {
38*bf2c3715SXin Li 
39*bf2c3715SXin Li namespace internal {
40*bf2c3715SXin Li 
41*bf2c3715SXin Li /** \internal Specialization for the data types supported by LAPACKe */
42*bf2c3715SXin Li 
43*bf2c3715SXin Li #define EIGEN_LAPACKE_QR_NOPIV(EIGTYPE, LAPACKE_TYPE, LAPACKE_PREFIX) \
44*bf2c3715SXin Li template<typename MatrixQR, typename HCoeffs> \
45*bf2c3715SXin Li struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \
46*bf2c3715SXin Li { \
47*bf2c3715SXin Li   static void run(MatrixQR& mat, HCoeffs& hCoeffs, Index = 32, \
48*bf2c3715SXin Li       typename MatrixQR::Scalar* = 0) \
49*bf2c3715SXin Li   { \
50*bf2c3715SXin Li     lapack_int m = (lapack_int) mat.rows(); \
51*bf2c3715SXin Li     lapack_int n = (lapack_int) mat.cols(); \
52*bf2c3715SXin Li     lapack_int lda = (lapack_int) mat.outerStride(); \
53*bf2c3715SXin Li     lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
54*bf2c3715SXin Li     LAPACKE_##LAPACKE_PREFIX##geqrf( matrix_order, m, n, (LAPACKE_TYPE*)mat.data(), lda, (LAPACKE_TYPE*)hCoeffs.data()); \
55*bf2c3715SXin Li     hCoeffs.adjointInPlace(); \
56*bf2c3715SXin Li   } \
57*bf2c3715SXin Li };
58*bf2c3715SXin Li 
59*bf2c3715SXin Li EIGEN_LAPACKE_QR_NOPIV(double, double, d)
60*bf2c3715SXin Li EIGEN_LAPACKE_QR_NOPIV(float, float, s)
61*bf2c3715SXin Li EIGEN_LAPACKE_QR_NOPIV(dcomplex, lapack_complex_double, z)
62*bf2c3715SXin Li EIGEN_LAPACKE_QR_NOPIV(scomplex, lapack_complex_float, c)
63*bf2c3715SXin Li 
64*bf2c3715SXin Li } // end namespace internal
65*bf2c3715SXin Li 
66*bf2c3715SXin Li } // end namespace Eigen
67*bf2c3715SXin Li 
68*bf2c3715SXin Li #endif // EIGEN_QR_LAPACKE_H
69