mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-09-25 15:53:19 +08:00
Sparse: more fixes regarding long int as index type
This commit is contained in:
parent
421ece38e1
commit
91fe1507d1
@ -328,9 +328,9 @@ class DynamicSparseMatrix
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename Scalar, int _Options, typename _Index>
|
template<typename Scalar, int _Options, typename _Index>
|
||||||
class DynamicSparseMatrix<Scalar,_Options,_Index>::InnerIterator : public SparseVector<Scalar,_Options>::InnerIterator
|
class DynamicSparseMatrix<Scalar,_Options,_Index>::InnerIterator : public SparseVector<Scalar,_Options,_Index>::InnerIterator
|
||||||
{
|
{
|
||||||
typedef typename SparseVector<Scalar,_Options>::InnerIterator Base;
|
typedef typename SparseVector<Scalar,_Options,_Index>::InnerIterator Base;
|
||||||
public:
|
public:
|
||||||
InnerIterator(const DynamicSparseMatrix& mat, Index outer)
|
InnerIterator(const DynamicSparseMatrix& mat, Index outer)
|
||||||
: Base(mat.m_data[outer]), m_outer(outer)
|
: Base(mat.m_data[outer]), m_outer(outer)
|
||||||
|
@ -105,11 +105,11 @@ class SparseInnerVectorSet : internal::no_assignment_operator,
|
|||||||
* specialisation for DynamicSparseMatrix
|
* specialisation for DynamicSparseMatrix
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
template<typename _Scalar, int _Options, int Size>
|
template<typename _Scalar, int _Options, typename _Index, int Size>
|
||||||
class SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options>, Size>
|
class SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options, _Index>, Size>
|
||||||
: public SparseMatrixBase<SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options>, Size> >
|
: public SparseMatrixBase<SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options, _Index>, Size> >
|
||||||
{
|
{
|
||||||
typedef DynamicSparseMatrix<_Scalar, _Options> MatrixType;
|
typedef DynamicSparseMatrix<_Scalar, _Options, _Index> MatrixType;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum { IsRowMajor = internal::traits<SparseInnerVectorSet>::IsRowMajor };
|
enum { IsRowMajor = internal::traits<SparseInnerVectorSet>::IsRowMajor };
|
||||||
@ -205,9 +205,9 @@ class SparseInnerVectorSet<DynamicSparseMatrix<_Scalar, _Options>, Size>
|
|||||||
|
|
||||||
template<typename _Scalar, int _Options, typename _Index, int Size>
|
template<typename _Scalar, int _Options, typename _Index, int Size>
|
||||||
class SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size>
|
class SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size>
|
||||||
: public SparseMatrixBase<SparseInnerVectorSet<SparseMatrix<_Scalar, _Options>, Size> >
|
: public SparseMatrixBase<SparseInnerVectorSet<SparseMatrix<_Scalar, _Options, _Index>, Size> >
|
||||||
{
|
{
|
||||||
typedef SparseMatrix<_Scalar, _Options> MatrixType;
|
typedef SparseMatrix<_Scalar, _Options, _Index> MatrixType;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum { IsRowMajor = internal::traits<SparseInnerVectorSet>::IsRowMajor };
|
enum { IsRowMajor = internal::traits<SparseInnerVectorSet>::IsRowMajor };
|
||||||
|
@ -191,8 +191,8 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
|
DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
|
||||||
SparseMatrixType m2(rows, rows);
|
SparseMatrixType m2(rows, rows);
|
||||||
initSparse<Scalar>(density, refMat2, m2);
|
initSparse<Scalar>(density, refMat2, m2);
|
||||||
int j0 = internal::random(0,rows-1);
|
int j0 = internal::random<int>(0,rows-1);
|
||||||
int j1 = internal::random(0,rows-1);
|
int j1 = internal::random<int>(0,rows-1);
|
||||||
VERIFY_IS_APPROX(m2.innerVector(j0), refMat2.col(j0));
|
VERIFY_IS_APPROX(m2.innerVector(j0), refMat2.col(j0));
|
||||||
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
|
VERIFY_IS_APPROX(m2.innerVector(j0)+m2.innerVector(j1), refMat2.col(j0)+refMat2.col(j1));
|
||||||
//m2.innerVector(j0) = 2*m2.innerVector(j1);
|
//m2.innerVector(j0) = 2*m2.innerVector(j1);
|
||||||
@ -205,8 +205,8 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
|
DenseMatrix refMat2 = DenseMatrix::Zero(rows, rows);
|
||||||
SparseMatrixType m2(rows, rows);
|
SparseMatrixType m2(rows, rows);
|
||||||
initSparse<Scalar>(density, refMat2, m2);
|
initSparse<Scalar>(density, refMat2, m2);
|
||||||
int j0 = internal::random(0,rows-2);
|
int j0 = internal::random<int>(0,rows-2);
|
||||||
int j1 = internal::random(0,rows-2);
|
int j1 = internal::random<int>(0,rows-2);
|
||||||
int n0 = internal::random<int>(1,rows-std::max(j0,j1));
|
int n0 = internal::random<int>(1,rows-std::max(j0,j1));
|
||||||
VERIFY_IS_APPROX(m2.innerVectors(j0,n0), refMat2.block(0,j0,rows,n0));
|
VERIFY_IS_APPROX(m2.innerVectors(j0,n0), refMat2.block(0,j0,rows,n0));
|
||||||
VERIFY_IS_APPROX(m2.innerVectors(j0,n0)+m2.innerVectors(j1,n0),
|
VERIFY_IS_APPROX(m2.innerVectors(j0,n0)+m2.innerVectors(j1,n0),
|
||||||
@ -274,10 +274,13 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
|||||||
void test_sparse_basic()
|
void test_sparse_basic()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
for(int i = 0; i < g_repeat; i++) {
|
||||||
CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(8, 8)) );
|
int s = Eigen::internal::random<int>(1,50);
|
||||||
CALL_SUBTEST_2( sparse_basic(SparseMatrix<std::complex<double> >(16, 16)) );
|
CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(8, 8)) ));
|
||||||
CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(33, 33)) );
|
CALL_SUBTEST_2(( sparse_basic(SparseMatrix<std::complex<double> >(s, s)) ));
|
||||||
|
CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double>(s, s)) ));
|
||||||
|
CALL_SUBTEST_1(( sparse_basic(SparseMatrix<double,ColMajor,long int>(s, s)) ));
|
||||||
|
|
||||||
CALL_SUBTEST_3( sparse_basic(DynamicSparseMatrix<double>(8, 8)) );
|
CALL_SUBTEST_3(( sparse_basic(DynamicSparseMatrix<double>(s, s)) ));
|
||||||
|
CALL_SUBTEST_3(( sparse_basic(DynamicSparseMatrix<double,ColMajor,long int>(s, s)) ));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user