Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/eigen3/Eigen/src/Cholesky/LLT_LAPACKE.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  Copyright (c) 2011, Intel Corporation. All rights reserved.
0003 
0004  Redistribution and use in source and binary forms, with or without modification,
0005  are permitted provided that the following conditions are met:
0006 
0007  * Redistributions of source code must retain the above copyright notice, this
0008    list of conditions and the following disclaimer.
0009  * Redistributions in binary form must reproduce the above copyright notice,
0010    this list of conditions and the following disclaimer in the documentation
0011    and/or other materials provided with the distribution.
0012  * Neither the name of Intel Corporation nor the names of its contributors may
0013    be used to endorse or promote products derived from this software without
0014    specific prior written permission.
0015 
0016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
0017  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0018  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0019  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
0020  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
0021  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
0022  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
0023  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0024  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
0025  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0026 
0027  ********************************************************************************
0028  *   Content : Eigen bindings to LAPACKe
0029  *     LLt decomposition based on LAPACKE_?potrf function.
0030  ********************************************************************************
0031 */
0032 
0033 #ifndef EIGEN_LLT_LAPACKE_H
0034 #define EIGEN_LLT_LAPACKE_H
0035 
0036 namespace Eigen { 
0037 
0038 namespace internal {
0039 
0040 template<typename Scalar> struct lapacke_llt;
0041 
0042 #define EIGEN_LAPACKE_LLT(EIGTYPE, BLASTYPE, LAPACKE_PREFIX) \
0043 template<> struct lapacke_llt<EIGTYPE> \
0044 { \
0045   template<typename MatrixType> \
0046   static inline Index potrf(MatrixType& m, char uplo) \
0047   { \
0048     lapack_int matrix_order; \
0049     lapack_int size, lda, info, StorageOrder; \
0050     EIGTYPE* a; \
0051     eigen_assert(m.rows()==m.cols()); \
0052     /* Set up parameters for ?potrf */ \
0053     size = convert_index<lapack_int>(m.rows()); \
0054     StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \
0055     matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
0056     a = &(m.coeffRef(0,0)); \
0057     lda = convert_index<lapack_int>(m.outerStride()); \
0058 \
0059     info = LAPACKE_##LAPACKE_PREFIX##potrf( matrix_order, uplo, size, (BLASTYPE*)a, lda ); \
0060     info = (info==0) ? -1 : info>0 ? info-1 : size; \
0061     return info; \
0062   } \
0063 }; \
0064 template<> struct llt_inplace<EIGTYPE, Lower> \
0065 { \
0066   template<typename MatrixType> \
0067   static Index blocked(MatrixType& m) \
0068   { \
0069     return lapacke_llt<EIGTYPE>::potrf(m, 'L'); \
0070   } \
0071   template<typename MatrixType, typename VectorType> \
0072   static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
0073   { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \
0074 }; \
0075 template<> struct llt_inplace<EIGTYPE, Upper> \
0076 { \
0077   template<typename MatrixType> \
0078   static Index blocked(MatrixType& m) \
0079   { \
0080     return lapacke_llt<EIGTYPE>::potrf(m, 'U'); \
0081   } \
0082   template<typename MatrixType, typename VectorType> \
0083   static Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
0084   { \
0085     Transpose<MatrixType> matt(mat); \
0086     return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \
0087   } \
0088 };
0089 
0090 EIGEN_LAPACKE_LLT(double, double, d)
0091 EIGEN_LAPACKE_LLT(float, float, s)
0092 EIGEN_LAPACKE_LLT(dcomplex, lapack_complex_double, z)
0093 EIGEN_LAPACKE_LLT(scomplex, lapack_complex_float, c)
0094 
0095 } // end namespace internal
0096 
0097 } // end namespace Eigen
0098 
0099 #endif // EIGEN_LLT_LAPACKE_H