mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Sparse module: bugfix in SparseMatrix::resize(), now the indices are
correctly initialized to 0.
This commit is contained in:
parent
96e1e582ff
commit
87241089e1
@ -244,6 +244,7 @@ class SparseMatrix
|
|||||||
delete[] m_outerIndex;
|
delete[] m_outerIndex;
|
||||||
m_outerIndex = new int [outerSize+1];
|
m_outerIndex = new int [outerSize+1];
|
||||||
m_outerSize = outerSize;
|
m_outerSize = outerSize;
|
||||||
|
memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void resizeNonZeros(int size)
|
void resizeNonZeros(int size)
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
// You should have received a copy of the GNU Lesser General Public
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#define EIGEN_DONT_VECTORIZE
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include <Eigen/Cholesky>
|
#include <Eigen/Cholesky>
|
||||||
#include <Eigen/LU>
|
#include <Eigen/LU>
|
||||||
|
@ -23,8 +23,14 @@
|
|||||||
// License and a copy of the GNU General Public License along with
|
// License and a copy of the GNU General Public License along with
|
||||||
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
// Eigen. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef EIGEN_NO_STATIC_ASSERT
|
||||||
#define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them
|
#define EIGEN_NO_STATIC_ASSERT // turn static asserts into runtime asserts in order to check them
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef EIGEN_DONT_VECTORIZE
|
||||||
#define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types
|
#define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -174,21 +174,19 @@ template<typename Scalar> void sparse_basic(int rows, int cols)
|
|||||||
std::cerr << m1 << "\n\n" << m2 << "\n";
|
std::cerr << m1 << "\n\n" << m2 << "\n";
|
||||||
VERIFY_IS_APPROX(m2,m1);
|
VERIFY_IS_APPROX(m2,m1);
|
||||||
}
|
}
|
||||||
// {
|
// test RandomSetter
|
||||||
// m.setZero();
|
{
|
||||||
// VERIFY_IS_NOT_APPROX(m, refMat);
|
SparseMatrix<Scalar> m1(rows,cols), m2(rows,cols);
|
||||||
// // RandomSetter<SparseMatrix<Scalar> > w(m);
|
DenseMatrix refM1 = DenseMatrix::Zero(rows, rows);
|
||||||
// RandomSetter<SparseMatrix<Scalar>, GoogleDenseHashMapTraits > w(m);
|
initSparse<Scalar>(density, refM1, m1);
|
||||||
// // RandomSetter<SparseMatrix<Scalar>, GnuHashMapTraits > w(m);
|
{
|
||||||
// std::vector<Vector2i> remaining = nonzeroCoords;
|
Eigen::RandomSetter<SparseMatrix<Scalar> > setter(m2);
|
||||||
// while(!remaining.empty())
|
for (int j=0; j<m1.outerSize(); ++j)
|
||||||
// {
|
for (typename SparseMatrix<Scalar>::InnerIterator i(m1,j); i; ++i)
|
||||||
// int i = ei_random<int>(0,remaining.size()-1);
|
setter(i.index(), j) = i.value();
|
||||||
// w(remaining[i].x(),remaining[i].y()) = refMat.coeff(remaining[i].x(),remaining[i].y());
|
}
|
||||||
// remaining[i] = remaining.back();
|
VERIFY_IS_APPROX(m1, m2);
|
||||||
// remaining.pop_back();
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// std::cerr << m.transpose() << "\n\n" << refMat.transpose() << "\n\n";
|
// std::cerr << m.transpose() << "\n\n" << refMat.transpose() << "\n\n";
|
||||||
// VERIFY_IS_APPROX(m, refMat);
|
// VERIFY_IS_APPROX(m, refMat);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user