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 #ifndef EIGEN_JACOBISVD_MKL_H
00034 #define EIGEN_JACOBISVD_MKL_H
00035
00036 #include "Eigen/src/Core/util/MKL_support.h"
00037
00038 namespace Eigen {
00039
00042 #define EIGEN_MKL_SVD(EIGTYPE, MKLTYPE, MKLRTYPE, MKLPREFIX, EIGCOLROW, MKLCOLROW) \
00043 template<> inline \
00044 JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>& \
00045 JacobiSVD<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>, ColPivHouseholderQRPreconditioner>::compute(const Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic>& matrix, unsigned int computationOptions) \
00046 { \
00047 typedef Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynamic> MatrixType; \
00048 typedef MatrixType::Scalar Scalar; \
00049 typedef MatrixType::RealScalar RealScalar; \
00050 allocate(matrix.rows(), matrix.cols(), computationOptions); \
00051 \
00052 \
00053 m_nonzeroSingularValues = m_diagSize; \
00054 \
00055 lapack_int lda = matrix.outerStride(), ldu, ldvt; \
00056 lapack_int matrix_order = MKLCOLROW; \
00057 char jobu, jobvt; \
00058 MKLTYPE *u, *vt, dummy; \
00059 jobu = (m_computeFullU) ? 'A' : (m_computeThinU) ? 'S' : 'N'; \
00060 jobvt = (m_computeFullV) ? 'A' : (m_computeThinV) ? 'S' : 'N'; \
00061 if (computeU()) { \
00062 ldu = m_matrixU.outerStride(); \
00063 u = (MKLTYPE*)m_matrixU.data(); \
00064 } else { ldu=1; u=&dummy; }\
00065 MatrixType localV; \
00066 ldvt = (m_computeFullV) ? m_cols : (m_computeThinV) ? m_diagSize : 1; \
00067 if (computeV()) { \
00068 localV.resize(ldvt, m_cols); \
00069 vt = (MKLTYPE*)localV.data(); \
00070 } else { ldvt=1; vt=&dummy; }\
00071 Matrix<MKLRTYPE, Dynamic, Dynamic> superb; superb.resize(m_diagSize, 1); \
00072 MatrixType m_temp; m_temp = matrix; \
00073 LAPACKE_##MKLPREFIX##gesvd( matrix_order, jobu, jobvt, m_rows, m_cols, (MKLTYPE*)m_temp.data(), lda, (MKLRTYPE*)m_singularValues.data(), u, ldu, vt, ldvt, superb.data()); \
00074 if (computeV()) m_matrixV = localV.adjoint(); \
00075 \
00076 m_isInitialized = true; \
00077 return *this; \
00078 }
00079
00080 EIGEN_MKL_SVD(double, double, double, d, ColMajor, LAPACK_COL_MAJOR)
00081 EIGEN_MKL_SVD(float, float, float , s, ColMajor, LAPACK_COL_MAJOR)
00082 EIGEN_MKL_SVD(dcomplex, MKL_Complex16, double, z, ColMajor, LAPACK_COL_MAJOR)
00083 EIGEN_MKL_SVD(scomplex, MKL_Complex8, float , c, ColMajor, LAPACK_COL_MAJOR)
00084
00085 EIGEN_MKL_SVD(double, double, double, d, RowMajor, LAPACK_ROW_MAJOR)
00086 EIGEN_MKL_SVD(float, float, float , s, RowMajor, LAPACK_ROW_MAJOR)
00087 EIGEN_MKL_SVD(dcomplex, MKL_Complex16, double, z, RowMajor, LAPACK_ROW_MAJOR)
00088 EIGEN_MKL_SVD(scomplex, MKL_Complex8, float , c, RowMajor, LAPACK_ROW_MAJOR)
00089
00090 }
00091
00092 #endif // EIGEN_JACOBISVD_MKL_H