00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef EIGEN_COLPIVOTINGHOUSEHOLDERQR_MKL_H
00035 #define EIGEN_COLPIVOTINGHOUSEHOLDERQR_MKL_H
00036
00037 #include "Eigen/src/Core/util/MKL_support.h"
00038
00039 namespace Eigen {
00040
00043 #define EIGEN_MKL_QR_COLPIV(EIGTYPE, MKLTYPE, MKLPREFIX, EIGCOLROW, MKLCOLROW) \
00044 template<> inline \
00045 ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >& \
00046 ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> >::compute( \
00047 const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix) \
00048 \
00049 { \
00050 using std::abs; \
00051 typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
00052 typedef MatrixType::Scalar Scalar; \
00053 typedef MatrixType::RealScalar RealScalar; \
00054 Index rows = matrix.rows();\
00055 Index cols = matrix.cols();\
00056 Index size = matrix.diagonalSize();\
00057 \
00058 m_qr = matrix;\
00059 m_hCoeffs.resize(size);\
00060 \
00061 m_colsTranspositions.resize(cols);\
00062 \
00063 \
00064 m_nonzero_pivots = 0; \
00065 m_maxpivot = RealScalar(0);\
00066 m_colsPermutation.resize(cols); \
00067 m_colsPermutation.indices().setZero(); \
00068 \
00069 lapack_int lda = m_qr.outerStride(), i; \
00070 lapack_int matrix_order = MKLCOLROW; \
00071 LAPACKE_##MKLPREFIX##geqp3( matrix_order, rows, cols, (MKLTYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (MKLTYPE*)m_hCoeffs.data()); \
00072 m_isInitialized = true; \
00073 m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \
00074 m_hCoeffs.adjointInPlace(); \
00075 RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \
00076 lapack_int *perm = m_colsPermutation.indices().data(); \
00077 for(i=0;i<size;i++) { \
00078 m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\
00079 } \
00080 for(i=0;i<cols;i++) perm[i]--;\
00081 \
00082 \
00083 \
00084 return *this; \
00085 }
00086
00087 EIGEN_MKL_QR_COLPIV(double, double, d, ColMajor, LAPACK_COL_MAJOR)
00088 EIGEN_MKL_QR_COLPIV(float, float, s, ColMajor, LAPACK_COL_MAJOR)
00089 EIGEN_MKL_QR_COLPIV(dcomplex, MKL_Complex16, z, ColMajor, LAPACK_COL_MAJOR)
00090 EIGEN_MKL_QR_COLPIV(scomplex, MKL_Complex8, c, ColMajor, LAPACK_COL_MAJOR)
00091
00092 EIGEN_MKL_QR_COLPIV(double, double, d, RowMajor, LAPACK_ROW_MAJOR)
00093 EIGEN_MKL_QR_COLPIV(float, float, s, RowMajor, LAPACK_ROW_MAJOR)
00094 EIGEN_MKL_QR_COLPIV(dcomplex, MKL_Complex16, z, RowMajor, LAPACK_ROW_MAJOR)
00095 EIGEN_MKL_QR_COLPIV(scomplex, MKL_Complex8, c, RowMajor, LAPACK_ROW_MAJOR)
00096
00097 }
00098
00099 #endif // EIGEN_COLPIVOTINGHOUSEHOLDERQR_MKL_H