Handle some Index to int conversions in BLAS/LAPACK support.

This commit is contained in:
Gael Guennebaud 2016-05-26 17:29:04 +02:00
parent f253e19296
commit 2a44a70142
7 changed files with 21 additions and 20 deletions

View File

@ -53,11 +53,11 @@ template<> struct mkl_llt<EIGTYPE> \
EIGTYPE* a; \ EIGTYPE* a; \
eigen_assert(m.rows()==m.cols()); \ eigen_assert(m.rows()==m.cols()); \
/* Set up parameters for ?potrf */ \ /* Set up parameters for ?potrf */ \
size = m.rows(); \ size = convert_index<lapack_int>(m.rows()); \
StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \ StorageOrder = MatrixType::Flags&RowMajorBit?RowMajor:ColMajor; \
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
a = &(m.coeffRef(0,0)); \ a = &(m.coeffRef(0,0)); \
lda = m.outerStride(); \ lda = convert_index<lapack_int>(m.outerStride()); \
\ \
info = LAPACKE_##MKLPREFIX##potrf( matrix_order, uplo, size, (MKLTYPE*)a, lda ); \ info = LAPACKE_##MKLPREFIX##potrf( matrix_order, uplo, size, (MKLTYPE*)a, lda ); \
info = (info==0) ? -1 : info>0 ? info-1 : size; \ info = (info==0) ? -1 : info>0 ? info-1 : size; \

View File

@ -122,7 +122,7 @@ struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,true,ConjugateLh
Map<const Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder>, 0, OuterStride<> > lhs(_lhs,m,m,OuterStride<>(lhsStride)); \ Map<const Matrix<EIGTYPE, Dynamic, Dynamic, LhsStorageOrder>, 0, OuterStride<> > lhs(_lhs,m,m,OuterStride<>(lhsStride)); \
a_tmp = lhs.conjugate(); \ a_tmp = lhs.conjugate(); \
a = a_tmp.data(); \ a = a_tmp.data(); \
lda = a_tmp.outerStride(); \ lda = convert_index<BlasIndex>(a_tmp.outerStride()); \
} else a = _lhs; \ } else a = _lhs; \
if (LhsStorageOrder==RowMajor) uplo='U'; \ if (LhsStorageOrder==RowMajor) uplo='U'; \
\ \
@ -256,7 +256,7 @@ struct product_selfadjoint_matrix<EIGTYPE,Index,LhsStorageOrder,false,ConjugateL
b_tmp = lhs.transpose(); \ b_tmp = lhs.transpose(); \
} \ } \
b = b_tmp.data(); \ b = b_tmp.data(); \
ldb = b_tmp.outerStride(); \ ldb = convert_index<BlasIndex>(b_tmp.outerStride()); \
} \ } \
\ \
BLASPREFIX##hemm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \ BLASPREFIX##hemm_(&side, &uplo, &m, &n, &numext::real_ref(alpha), (const BLASTYPE*)a, &lda, (const BLASTYPE*)b, &ldb, &numext::real_ref(beta), (BLASTYPE*)res, &ldc); \

View File

@ -60,15 +60,15 @@ ComplexSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const Eigen
m_matUisUptodate = computeU; \ m_matUisUptodate = computeU; \
return *this; \ return *this; \
} \ } \
lapack_int n = matrix.cols(), sdim, info; \ lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), sdim, info; \
lapack_int matrix_order = MKLCOLROW; \ lapack_int matrix_order = MKLCOLROW; \
char jobvs, sort='N'; \ char jobvs, sort='N'; \
LAPACK_##MKLPREFIX_U##_SELECT1 select = 0; \ LAPACK_##MKLPREFIX_U##_SELECT1 select = 0; \
jobvs = (computeU) ? 'V' : 'N'; \ jobvs = (computeU) ? 'V' : 'N'; \
m_matU.resize(n, n); \ m_matU.resize(n, n); \
lapack_int ldvs = m_matU.outerStride(); \ lapack_int ldvs = internal::convert_index<lapack_int>(m_matU.outerStride()); \
m_matT = matrix; \ m_matT = matrix; \
lapack_int lda = m_matT.outerStride(); \ lapack_int lda = internal::convert_index<lapack_int>(m_matT.outerStride()); \
Matrix<EIGTYPE, Dynamic, Dynamic> w; \ Matrix<EIGTYPE, Dynamic, Dynamic> w; \
w.resize(n, 1);\ w.resize(n, 1);\
info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)w.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)w.data(), (MKLTYPE*)m_matU.data(), ldvs ); \

View File

@ -46,15 +46,15 @@ RealSchur<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(const EigenBas
{ \ { \
eigen_assert(matrix.cols() == matrix.rows()); \ eigen_assert(matrix.cols() == matrix.rows()); \
\ \
lapack_int n = matrix.cols(), sdim, info; \ lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), sdim, info; \
lapack_int matrix_order = MKLCOLROW; \ lapack_int matrix_order = MKLCOLROW; \
char jobvs, sort='N'; \ char jobvs, sort='N'; \
LAPACK_##MKLPREFIX_U##_SELECT2 select = 0; \ LAPACK_##MKLPREFIX_U##_SELECT2 select = 0; \
jobvs = (computeU) ? 'V' : 'N'; \ jobvs = (computeU) ? 'V' : 'N'; \
m_matU.resize(n, n); \ m_matU.resize(n, n); \
lapack_int ldvs = m_matU.outerStride(); \ lapack_int ldvs = internal::convert_index<lapack_int>(m_matU.outerStride()); \
m_matT = matrix; \ m_matT = matrix; \
lapack_int lda = m_matT.outerStride(); \ lapack_int lda = internal::convert_index<lapack_int>(m_matT.outerStride()); \
Matrix<EIGTYPE, Dynamic, Dynamic> wr, wi; \ Matrix<EIGTYPE, Dynamic, Dynamic> wr, wi; \
wr.resize(n, 1); wi.resize(n, 1); \ wr.resize(n, 1); wi.resize(n, 1); \
info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)wr.data(), (MKLTYPE*)wi.data(), (MKLTYPE*)m_matU.data(), ldvs ); \ info = LAPACKE_##MKLPREFIX##gees( matrix_order, jobvs, sort, select, n, (MKLTYPE*)m_matT.data(), lda, &sdim, (MKLTYPE*)wr.data(), (MKLTYPE*)wi.data(), (MKLTYPE*)m_matU.data(), ldvs ); \

View File

@ -49,7 +49,7 @@ SelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(c
&& (options&EigVecMask)!=EigVecMask \ && (options&EigVecMask)!=EigVecMask \
&& "invalid option parameter"); \ && "invalid option parameter"); \
bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors; \ bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors; \
lapack_int n = matrix.cols(), lda, matrix_order, info; \ lapack_int n = internal::convert_index<lapack_int>(matrix.cols()), lda, matrix_order, info; \
m_eivalues.resize(n,1); \ m_eivalues.resize(n,1); \
m_subdiag.resize(n-1); \ m_subdiag.resize(n-1); \
m_eivec = matrix; \ m_eivec = matrix; \
@ -64,7 +64,7 @@ SelfAdjointEigenSolver<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW> >::compute(c
return *this; \ return *this; \
} \ } \
\ \
lda = m_eivec.outerStride(); \ lda = internal::convert_index<lapack_int>(m_eivec.outerStride()); \
matrix_order=MKLCOLROW; \ matrix_order=MKLCOLROW; \
char jobz, uplo='L'/*, range='A'*/; \ char jobz, uplo='L'/*, range='A'*/; \
jobz = computeEigenvectors ? 'V' : 'N'; \ jobz = computeEigenvectors ? 'V' : 'N'; \

View File

@ -46,7 +46,7 @@ template<int StorageOrder> \
struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \ struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \
{ \ { \
/* \internal performs the LU decomposition in-place of the matrix represented */ \ /* \internal performs the LU decomposition in-place of the matrix represented */ \
static lapack_int blocked_lu(lapack_int rows, lapack_int cols, EIGTYPE* lu_data, lapack_int luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \ static lapack_int blocked_lu(Index rows, Index cols, EIGTYPE* lu_data, Index luStride, lapack_int* row_transpositions, lapack_int& nb_transpositions, lapack_int maxBlockSize=256) \
{ \ { \
EIGEN_UNUSED_VARIABLE(maxBlockSize);\ EIGEN_UNUSED_VARIABLE(maxBlockSize);\
lapack_int matrix_order, first_zero_pivot; \ lapack_int matrix_order, first_zero_pivot; \
@ -54,11 +54,11 @@ struct partial_lu_impl<EIGTYPE, StorageOrder, lapack_int> \
EIGTYPE* a; \ EIGTYPE* a; \
/* Set up parameters for ?getrf */ \ /* Set up parameters for ?getrf */ \
matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \ matrix_order = StorageOrder==RowMajor ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
lda = luStride; \ lda = convert_index<lapack_int>(luStride); \
a = lu_data; \ a = lu_data; \
ipiv = row_transpositions; \ ipiv = row_transpositions; \
m = rows; \ m = convert_index<lapack_int>(rows); \
n = cols; \ n = convert_index<lapack_int>(cols); \
nb_transpositions = 0; \ nb_transpositions = 0; \
\ \
info = LAPACKE_##MKLPREFIX##getrf( matrix_order, m, n, (MKLTYPE*)a, lda, ipiv ); \ info = LAPACKE_##MKLPREFIX##getrf( matrix_order, m, n, (MKLTYPE*)a, lda, ipiv ); \

View File

@ -65,18 +65,19 @@ ColPivHouseholderQR<Matrix<EIGTYPE, Dynamic, Dynamic, EIGCOLROW, Dynamic, Dynami
m_colsPermutation.resize(cols); \ m_colsPermutation.resize(cols); \
m_colsPermutation.indices().setZero(); \ m_colsPermutation.indices().setZero(); \
\ \
lapack_int lda = m_qr.outerStride(), i; \ lapack_int lda = internal::convert_index<lapack_int,Index>(m_qr.outerStride()); \
lapack_int matrix_order = MKLCOLROW; \ lapack_int matrix_order = MKLCOLROW; \
LAPACKE_##MKLPREFIX##geqp3( matrix_order, rows, cols, (MKLTYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (MKLTYPE*)m_hCoeffs.data()); \ LAPACKE_##MKLPREFIX##geqp3( matrix_order, internal::convert_index<lapack_int,Index>(rows), internal::convert_index<lapack_int,Index>(cols), \
(MKLTYPE*)m_qr.data(), lda, (lapack_int*)m_colsPermutation.indices().data(), (MKLTYPE*)m_hCoeffs.data()); \
m_isInitialized = true; \ m_isInitialized = true; \
m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \ m_maxpivot=m_qr.diagonal().cwiseAbs().maxCoeff(); \
m_hCoeffs.adjointInPlace(); \ m_hCoeffs.adjointInPlace(); \
RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \ RealScalar premultiplied_threshold = abs(m_maxpivot) * threshold(); \
lapack_int *perm = m_colsPermutation.indices().data(); \ lapack_int *perm = m_colsPermutation.indices().data(); \
for(i=0;i<size;i++) { \ for(Index i=0;i<size;i++) { \
m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\ m_nonzero_pivots += (abs(m_qr.coeff(i,i)) > premultiplied_threshold);\
} \ } \
for(i=0;i<cols;i++) perm[i]--;\ for(Index i=0;i<cols;i++) perm[i]--;\
\ \
/*m_det_pq = (number_of_transpositions%2) ? -1 : 1; // TODO: It's not needed now; fix upon availability in Eigen */ \ /*m_det_pq = (number_of_transpositions%2) ? -1 : 1; // TODO: It's not needed now; fix upon availability in Eigen */ \
\ \