bug #1412: fix compilation with nvcc+MSVC

This commit is contained in:
Gael Guennebaud 2018-01-17 23:13:16 +01:00
parent f558ad2955
commit 09a16ba42f
3 changed files with 28 additions and 10 deletions

View File

@ -29,6 +29,22 @@ namespace Eigen {
* *
* \sa Scaling(), class DiagonalMatrix, MatrixBase::asDiagonal(), class Translation, class Transform * \sa Scaling(), class DiagonalMatrix, MatrixBase::asDiagonal(), class Translation, class Transform
*/ */
namespace internal
{
// This helper helps nvcc+MSVC to properly parse this file.
// See bug 1412.
template <typename Scalar, int Dim, int Mode>
struct uniformscaling_times_affine_returntype
{
enum
{
NewMode = int(Mode) == int(Isometry) ? Affine : Mode
};
typedef Transform <Scalar, Dim, NewMode> type;
};
}
template<typename _Scalar> template<typename _Scalar>
class UniformScaling class UniformScaling
{ {
@ -60,9 +76,11 @@ public:
/** Concatenates a uniform scaling and an affine transformation */ /** Concatenates a uniform scaling and an affine transformation */
template<int Dim, int Mode, int Options> template<int Dim, int Mode, int Options>
inline Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Mode)> operator* (const Transform<Scalar,Dim, Mode, Options>& t) const inline typename
internal::uniformscaling_times_affine_returntype <Scalar,Dim,Mode>::type
operator* (const Transform<Scalar, Dim, Mode, Options>& t) const
{ {
Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Mode)> res = t; typename internal::uniformscaling_times_affine_returntype <Scalar,Dim,Mode> res = t;
res.prescale(factor()); res.prescale(factor());
return res; return res;
} }
@ -70,7 +88,7 @@ public:
/** Concatenates a uniform scaling and a linear transformation matrix */ /** Concatenates a uniform scaling and a linear transformation matrix */
// TODO returns an expression // TODO returns an expression
template<typename Derived> template<typename Derived>
inline typename internal::plain_matrix_type<Derived>::type operator* (const MatrixBase<Derived>& other) const inline typename Eigen::internal::plain_matrix_type<Derived>::type operator* (const MatrixBase<Derived>& other) const
{ return other * m_factor; } { return other * m_factor; }
template<typename Derived,int Dim> template<typename Derived,int Dim>

View File

@ -217,7 +217,7 @@ public:
// Method to allocate and initialize matrix and attributes // Method to allocate and initialize matrix and attributes
template<typename MatrixType> template<typename MatrixType>
void BDCSVD<MatrixType>::allocate(Index rows, Index cols, unsigned int computationOptions) void BDCSVD<MatrixType>::allocate(Eigen::Index rows, Eigen::Index cols, unsigned int computationOptions)
{ {
m_isTranspose = (cols > rows); m_isTranspose = (cols > rows);
@ -393,7 +393,7 @@ void BDCSVD<MatrixType>::structured_update(Block<MatrixXr,Dynamic,Dynamic> A, co
//@param shift : Each time one takes the left submatrix, one must add 1 to the shift. Why? Because! We actually want the last column of the U submatrix //@param shift : Each time one takes the left submatrix, one must add 1 to the shift. Why? Because! We actually want the last column of the U submatrix
// to become the first column (*coeff) and to shift all the other columns to the right. There are more details on the reference paper. // to become the first column (*coeff) and to shift all the other columns to the right. There are more details on the reference paper.
template<typename MatrixType> template<typename MatrixType>
void BDCSVD<MatrixType>::divide (Index firstCol, Index lastCol, Index firstRowW, Index firstColW, Index shift) void BDCSVD<MatrixType>::divide (Eigen::Index firstCol, Eigen::Index lastCol, Eigen::Index firstRowW, Eigen::Index firstColW, Eigen::Index shift)
{ {
// requires rows = cols + 1; // requires rows = cols + 1;
using std::pow; using std::pow;
@ -573,7 +573,7 @@ void BDCSVD<MatrixType>::divide (Index firstCol, Index lastCol, Index firstRowW,
// handling of round-off errors, be consistent in ordering // handling of round-off errors, be consistent in ordering
// For instance, to solve the secular equation using FMM, see http://www.stat.uchicago.edu/~lekheng/courses/302/classics/greengard-rokhlin.pdf // For instance, to solve the secular equation using FMM, see http://www.stat.uchicago.edu/~lekheng/courses/302/classics/greengard-rokhlin.pdf
template <typename MatrixType> template <typename MatrixType>
void BDCSVD<MatrixType>::computeSVDofM(Index firstCol, Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V) void BDCSVD<MatrixType>::computeSVDofM(Eigen::Index firstCol, Eigen::Index n, MatrixXr& U, VectorType& singVals, MatrixXr& V)
{ {
const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)(); const RealScalar considerZero = (std::numeric_limits<RealScalar>::min)();
using std::abs; using std::abs;
@ -1059,7 +1059,7 @@ void BDCSVD<MatrixType>::computeSingVecs
// i >= 1, di almost null and zi non null. // i >= 1, di almost null and zi non null.
// We use a rotation to zero out zi applied to the left of M // We use a rotation to zero out zi applied to the left of M
template <typename MatrixType> template <typename MatrixType>
void BDCSVD<MatrixType>::deflation43(Index firstCol, Index shift, Index i, Index size) void BDCSVD<MatrixType>::deflation43(Eigen::Index firstCol, Eigen::Index shift, Eigen::Index i, Eigen::Index size)
{ {
using std::abs; using std::abs;
using std::sqrt; using std::sqrt;
@ -1088,7 +1088,7 @@ void BDCSVD<MatrixType>::deflation43(Index firstCol, Index shift, Index i, Index
// We apply two rotations to have zj = 0; // We apply two rotations to have zj = 0;
// TODO deflation44 is still broken and not properly tested // TODO deflation44 is still broken and not properly tested
template <typename MatrixType> template <typename MatrixType>
void BDCSVD<MatrixType>::deflation44(Index firstColu , Index firstColm, Index firstRowW, Index firstColW, Index i, Index j, Index size) void BDCSVD<MatrixType>::deflation44(Eigen::Index firstColu , Eigen::Index firstColm, Eigen::Index firstRowW, Eigen::Index firstColW, Eigen::Index i, Eigen::Index j, Eigen::Index size)
{ {
using std::abs; using std::abs;
using std::sqrt; using std::sqrt;
@ -1128,7 +1128,7 @@ void BDCSVD<MatrixType>::deflation44(Index firstColu , Index firstColm, Index fi
// acts on block from (firstCol+shift, firstCol+shift) to (lastCol+shift, lastCol+shift) [inclusive] // acts on block from (firstCol+shift, firstCol+shift) to (lastCol+shift, lastCol+shift) [inclusive]
template <typename MatrixType> template <typename MatrixType>
void BDCSVD<MatrixType>::deflation(Index firstCol, Index lastCol, Index k, Index firstRowW, Index firstColW, Index shift) void BDCSVD<MatrixType>::deflation(Eigen::Index firstCol, Eigen::Index lastCol, Eigen::Index k, Eigen::Index firstRowW, Eigen::Index firstColW, Eigen::Index shift)
{ {
using std::sqrt; using std::sqrt;
using std::abs; using std::abs;

View File

@ -610,7 +610,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
}; };
template<typename MatrixType, int QRPreconditioner> template<typename MatrixType, int QRPreconditioner>
void JacobiSVD<MatrixType, QRPreconditioner>::allocate(Index rows, Index cols, unsigned int computationOptions) void JacobiSVD<MatrixType, QRPreconditioner>::allocate(Eigen::Index rows, Eigen::Index cols, unsigned int computationOptions)
{ {
eigen_assert(rows >= 0 && cols >= 0); eigen_assert(rows >= 0 && cols >= 0);