LLT_MKL.h
Go to the documentation of this file.
00001 /*
00002  Copyright (c) 2011, Intel Corporation. All rights reserved.
00003 
00004  Redistribution and use in source and binary forms, with or without modification,
00005  are permitted provided that the following conditions are met:
00006 
00007  * Redistributions of source code must retain the above copyright notice, this
00008    list of conditions and the following disclaimer.
00009  * Redistributions in binary form must reproduce the above copyright notice,
00010    this list of conditions and the following disclaimer in the documentation
00011    and/or other materials provided with the distribution.
00012  * Neither the name of Intel Corporation nor the names of its contributors may
00013    be used to endorse or promote products derived from this software without
00014    specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00017  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00018  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
00020  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00021  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00022  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00023  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00024  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00025  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026 
00027  ********************************************************************************
00028  *   Content : Eigen bindings to Intel(R) MKL
00029  *     LLt decomposition based on LAPACKE_?potrf function.
00030  ********************************************************************************
00031 */
00032 
00033 #ifndef EIGEN_LLT_MKL_H
00034 #define EIGEN_LLT_MKL_H
00035 
00036 #include "Eigen/src/Core/util/MKL_support.h"
00037 #include <iostream>
00038 
00039 namespace Eigen { 
00040 
00041 namespace internal {
00042 
00043 template<typename Scalar> struct mkl_llt;
00044 
00045 #define EIGEN_MKL_LLT(EIGTYPE, MKLTYPE, MKLPREFIX) \
00046 template<> struct mkl_llt<EIGTYPE> \
00047 { \
00048   template<typename MatrixType> \
00049   static inline typename MatrixType::Index potrf(MatrixType& m, char uplo) \
00050   { \
00051     lapack_int matrix_order; \
00052     lapack_int size, lda, info, StorageOrder; \
00053     EIGTYPE* a; \
00054     eigen_assert(m.rows()==m.cols()); \
00055     /* Set up parameters for ?potrf */ \
00056     size = m.rows(); \
00057     StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \
00058     matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
00059     a = &(m.coeffRef(0,0)); \
00060     lda = m.outerStride(); \
00061 \
00062     info = LAPACKE_##MKLPREFIX##potrf( matrix_order, uplo, size, (MKLTYPE*)a, lda ); \
00063     info = (info==0) ? -1 : info>0 ? info-1 : size; \
00064     return info; \
00065   } \
00066 }; \
00067 template<> struct llt_inplace<EIGTYPE, Lower> \
00068 { \
00069   template<typename MatrixType> \
00070   static typename MatrixType::Index blocked(MatrixType& m) \
00071   { \
00072     return mkl_llt<EIGTYPE>::potrf(m, 'L'); \
00073   } \
00074   template<typename MatrixType, typename VectorType> \
00075   static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
00076   { return Eigen::internal::llt_rank_update_lower(mat, vec, sigma); } \
00077 }; \
00078 template<> struct llt_inplace<EIGTYPE, Upper> \
00079 { \
00080   template<typename MatrixType> \
00081   static typename MatrixType::Index blocked(MatrixType& m) \
00082   { \
00083     return mkl_llt<EIGTYPE>::potrf(m, 'U'); \
00084   } \
00085   template<typename MatrixType, typename VectorType> \
00086   static typename MatrixType::Index rankUpdate(MatrixType& mat, const VectorType& vec, const typename MatrixType::RealScalar& sigma) \
00087   { \
00088     Transpose<MatrixType> matt(mat); \
00089     return llt_inplace<EIGTYPE, Lower>::rankUpdate(matt, vec.conjugate(), sigma); \
00090   } \
00091 };
00092 
00093 EIGEN_MKL_LLT(double, double, d)
00094 EIGEN_MKL_LLT(float, float, s)
00095 EIGEN_MKL_LLT(dcomplex, MKL_Complex16, z)
00096 EIGEN_MKL_LLT(scomplex, MKL_Complex8, c)
00097 
00098 } // end namespace internal
00099 
00100 } // end namespace Eigen
00101 
00102 #endif // EIGEN_LLT_MKL_H


turtlebot_exploration_3d
Author(s): Bona , Shawn
autogenerated on Thu Jun 6 2019 20:59:00