mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-15 10:53:50 +08:00
Fix StorageIndex FIXME in dense LU solvers
This commit is contained in:
parent
9005f0111f
commit
f566724023
@ -18,6 +18,7 @@ template<typename _MatrixType> struct traits<FullPivLU<_MatrixType> >
|
|||||||
{
|
{
|
||||||
typedef MatrixXpr XprKind;
|
typedef MatrixXpr XprKind;
|
||||||
typedef SolverStorage StorageKind;
|
typedef SolverStorage StorageKind;
|
||||||
|
typedef int StorageIndex;
|
||||||
enum { Flags = 0 };
|
enum { Flags = 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +65,6 @@ template<typename _MatrixType> class FullPivLU
|
|||||||
typedef SolverBase<FullPivLU> Base;
|
typedef SolverBase<FullPivLU> Base;
|
||||||
|
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(FullPivLU)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(FullPivLU)
|
||||||
// FIXME StorageIndex defined in EIGEN_GENERIC_PUBLIC_INTERFACE should be int
|
|
||||||
enum {
|
enum {
|
||||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||||
@ -529,8 +529,8 @@ void FullPivLU<MatrixType>::computeInPlace()
|
|||||||
m_nonzero_pivots = k;
|
m_nonzero_pivots = k;
|
||||||
for(Index i = k; i < size; ++i)
|
for(Index i = k; i < size; ++i)
|
||||||
{
|
{
|
||||||
m_rowsTranspositions.coeffRef(i) = i;
|
m_rowsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
|
||||||
m_colsTranspositions.coeffRef(i) = i;
|
m_colsTranspositions.coeffRef(i) = internal::convert_index<StorageIndex>(i);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -541,8 +541,8 @@ void FullPivLU<MatrixType>::computeInPlace()
|
|||||||
// Now that we've found the pivot, we need to apply the row/col swaps to
|
// Now that we've found the pivot, we need to apply the row/col swaps to
|
||||||
// bring it to the location (k,k).
|
// bring it to the location (k,k).
|
||||||
|
|
||||||
m_rowsTranspositions.coeffRef(k) = row_of_biggest_in_corner;
|
m_rowsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(row_of_biggest_in_corner);
|
||||||
m_colsTranspositions.coeffRef(k) = col_of_biggest_in_corner;
|
m_colsTranspositions.coeffRef(k) = internal::convert_index<StorageIndex>(col_of_biggest_in_corner);
|
||||||
if(k != row_of_biggest_in_corner) {
|
if(k != row_of_biggest_in_corner) {
|
||||||
m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
|
m_lu.row(k).swap(m_lu.row(row_of_biggest_in_corner));
|
||||||
++number_of_transpositions;
|
++number_of_transpositions;
|
||||||
|
@ -19,6 +19,7 @@ template<typename _MatrixType> struct traits<PartialPivLU<_MatrixType> >
|
|||||||
{
|
{
|
||||||
typedef MatrixXpr XprKind;
|
typedef MatrixXpr XprKind;
|
||||||
typedef SolverStorage StorageKind;
|
typedef SolverStorage StorageKind;
|
||||||
|
typedef int StorageIndex;
|
||||||
typedef traits<_MatrixType> BaseTraits;
|
typedef traits<_MatrixType> BaseTraits;
|
||||||
enum {
|
enum {
|
||||||
Flags = BaseTraits::Flags & RowMajorBit,
|
Flags = BaseTraits::Flags & RowMajorBit,
|
||||||
@ -80,7 +81,6 @@ template<typename _MatrixType> class PartialPivLU
|
|||||||
typedef _MatrixType MatrixType;
|
typedef _MatrixType MatrixType;
|
||||||
typedef SolverBase<PartialPivLU> Base;
|
typedef SolverBase<PartialPivLU> Base;
|
||||||
EIGEN_GENERIC_PUBLIC_INTERFACE(PartialPivLU)
|
EIGEN_GENERIC_PUBLIC_INTERFACE(PartialPivLU)
|
||||||
// FIXME StorageIndex defined in EIGEN_GENERIC_PUBLIC_INTERFACE should be int
|
|
||||||
enum {
|
enum {
|
||||||
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
MaxRowsAtCompileTime = MatrixType::MaxRowsAtCompileTime,
|
||||||
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
MaxColsAtCompileTime = MatrixType::MaxColsAtCompileTime
|
||||||
|
@ -18,6 +18,8 @@ typename MatrixType::RealScalar matrix_l1_norm(const MatrixType& m) {
|
|||||||
|
|
||||||
template<typename MatrixType> void lu_non_invertible()
|
template<typename MatrixType> void lu_non_invertible()
|
||||||
{
|
{
|
||||||
|
STATIC_CHECK(( internal::is_same<typename FullPivLU<MatrixType>::StorageIndex,int>::value ));
|
||||||
|
|
||||||
typedef typename MatrixType::RealScalar RealScalar;
|
typedef typename MatrixType::RealScalar RealScalar;
|
||||||
/* this test covers the following files:
|
/* this test covers the following files:
|
||||||
LU.h
|
LU.h
|
||||||
@ -191,6 +193,8 @@ template<typename MatrixType> void lu_partial_piv()
|
|||||||
m1.setRandom();
|
m1.setRandom();
|
||||||
PartialPivLU<MatrixType> plu(m1);
|
PartialPivLU<MatrixType> plu(m1);
|
||||||
|
|
||||||
|
STATIC_CHECK(( internal::is_same<typename PartialPivLU<MatrixType>::StorageIndex,int>::value ));
|
||||||
|
|
||||||
VERIFY_IS_APPROX(m1, plu.reconstructedMatrix());
|
VERIFY_IS_APPROX(m1, plu.reconstructedMatrix());
|
||||||
|
|
||||||
m3 = MatrixType::Random(size,size);
|
m3 = MatrixType::Random(size,size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user