mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-05-03 01:04:23 +08:00
Fix SVD for MSVC+CUDA.
This commit is contained in:
parent
bf6726a0c6
commit
b48922cb5c
@ -300,13 +300,13 @@ template<typename T> EIGEN_DEVICE_FUNC inline T* construct_elements_of_array(T *
|
|||||||
EIGEN_TRY
|
EIGEN_TRY
|
||||||
{
|
{
|
||||||
for (i = 0; i < size; ++i) ::new (ptr + i) T;
|
for (i = 0; i < size; ++i) ::new (ptr + i) T;
|
||||||
return ptr;
|
|
||||||
}
|
}
|
||||||
EIGEN_CATCH(...)
|
EIGEN_CATCH(...)
|
||||||
{
|
{
|
||||||
destruct_elements_of_array(ptr, i);
|
destruct_elements_of_array(ptr, i);
|
||||||
EIGEN_THROW;
|
EIGEN_THROW;
|
||||||
}
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -107,7 +107,7 @@ public:
|
|||||||
typedef typename Base::Scalar Scalar;
|
typedef typename Base::Scalar Scalar;
|
||||||
typedef typename Base::RealScalar RealScalar;
|
typedef typename Base::RealScalar RealScalar;
|
||||||
typedef typename NumTraits<RealScalar>::Literal Literal;
|
typedef typename NumTraits<RealScalar>::Literal Literal;
|
||||||
|
typedef typename Base::Index Index;
|
||||||
enum {
|
enum {
|
||||||
Options = Options_,
|
Options = Options_,
|
||||||
RowsAtCompileTime = Base::RowsAtCompileTime,
|
RowsAtCompileTime = Base::RowsAtCompileTime,
|
||||||
@ -271,7 +271,7 @@ private:
|
|||||||
|
|
||||||
// Method to allocate and initialize matrix and attributes
|
// Method to allocate and initialize matrix and attributes
|
||||||
template <typename MatrixType, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::allocate(Eigen::Index rows, Eigen::Index cols, unsigned int computationOptions) {
|
void BDCSVD<MatrixType, Options>::allocate(Index rows, Index cols, unsigned int computationOptions) {
|
||||||
if (Base::allocate(rows, cols, computationOptions))
|
if (Base::allocate(rows, cols, computationOptions))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -477,8 +477,8 @@ void BDCSVD<MatrixType, Options>::computeBaseCase(SVDType& svd, Index n, Index f
|
|||||||
//@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, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::divide(Eigen::Index firstCol, Eigen::Index lastCol, Eigen::Index firstRowW,
|
void BDCSVD<MatrixType, Options>::divide(Index firstCol, Index lastCol, Index firstRowW,
|
||||||
Eigen::Index firstColW, Eigen::Index shift) {
|
Index firstColW, Index shift) {
|
||||||
// requires rows = cols + 1;
|
// requires rows = cols + 1;
|
||||||
using std::pow;
|
using std::pow;
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
@ -655,7 +655,7 @@ void BDCSVD<MatrixType, Options>::divide(Eigen::Index firstCol, Eigen::Index las
|
|||||||
// 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, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::computeSVDofM(Eigen::Index firstCol, Eigen::Index n, MatrixXr& U,
|
void BDCSVD<MatrixType, Options>::computeSVDofM(Index firstCol, Index n, MatrixXr& U,
|
||||||
VectorType& singVals, MatrixXr& V) {
|
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;
|
||||||
@ -1174,8 +1174,8 @@ void BDCSVD<MatrixType, Options>::computeSingVecs(const ArrayRef& zhat, const Ar
|
|||||||
// 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, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::deflation43(Eigen::Index firstCol, Eigen::Index shift, Eigen::Index i,
|
void BDCSVD<MatrixType, Options>::deflation43(Index firstCol, Index shift, Index i,
|
||||||
Eigen::Index size) {
|
Index size) {
|
||||||
using std::abs;
|
using std::abs;
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
using std::pow;
|
using std::pow;
|
||||||
@ -1202,9 +1202,9 @@ void BDCSVD<MatrixType, Options>::deflation43(Eigen::Index firstCol, Eigen::Inde
|
|||||||
// 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, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::deflation44(Eigen::Index firstColu, Eigen::Index firstColm, Eigen::Index firstRowW,
|
void BDCSVD<MatrixType, Options>::deflation44(Index firstColu, Index firstColm, Index firstRowW,
|
||||||
Eigen::Index firstColW, Eigen::Index i, Eigen::Index j,
|
Index firstColW, Index i, Index j,
|
||||||
Eigen::Index size) {
|
Index size) {
|
||||||
using std::abs;
|
using std::abs;
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
using std::conj;
|
using std::conj;
|
||||||
@ -1242,8 +1242,8 @@ void BDCSVD<MatrixType, Options>::deflation44(Eigen::Index firstColu, Eigen::Ind
|
|||||||
|
|
||||||
// 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, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void BDCSVD<MatrixType, Options>::deflation(Eigen::Index firstCol, Eigen::Index lastCol, Eigen::Index k,
|
void BDCSVD<MatrixType, Options>::deflation(Index firstCol, Index lastCol, Index k,
|
||||||
Eigen::Index firstRowW, Eigen::Index firstColW, Eigen::Index shift) {
|
Index firstRowW, Index firstColW, Index shift) {
|
||||||
using std::sqrt;
|
using std::sqrt;
|
||||||
using std::abs;
|
using std::abs;
|
||||||
const Index length = lastCol + 1 - firstCol;
|
const Index length = lastCol + 1 - firstCol;
|
||||||
|
@ -518,6 +518,7 @@ class JacobiSVD : public SVDBase<JacobiSVD<MatrixType_, Options_> > {
|
|||||||
typedef MatrixType_ MatrixType;
|
typedef MatrixType_ MatrixType;
|
||||||
typedef typename Base::Scalar Scalar;
|
typedef typename Base::Scalar Scalar;
|
||||||
typedef typename Base::RealScalar RealScalar;
|
typedef typename Base::RealScalar RealScalar;
|
||||||
|
typedef typename Base::Index Index;
|
||||||
enum {
|
enum {
|
||||||
Options = Options_,
|
Options = Options_,
|
||||||
QRPreconditioner = internal::get_qr_preconditioner(Options),
|
QRPreconditioner = internal::get_qr_preconditioner(Options),
|
||||||
@ -670,7 +671,7 @@ class JacobiSVD : public SVDBase<JacobiSVD<MatrixType_, Options_> > {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <typename MatrixType, int Options>
|
template <typename MatrixType, int Options>
|
||||||
void JacobiSVD<MatrixType, Options>::allocate(Eigen::Index rows, Eigen::Index cols, unsigned int computationOptions) {
|
void JacobiSVD<MatrixType, Options>::allocate(Index rows, Index cols, unsigned int computationOptions) {
|
||||||
if (Base::allocate(rows, cols, computationOptions)) return;
|
if (Base::allocate(rows, cols, computationOptions)) return;
|
||||||
|
|
||||||
eigen_assert(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) &&
|
eigen_assert(!(ShouldComputeThinU && int(QRPreconditioner) == int(FullPivHouseholderQRPreconditioner)) &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user