diff options
-rw-r--r-- | Eigen/src/Sparse/SparseMatrix.h | 1 | ||||
-rw-r--r-- | test/cholesky.cpp | 2 | ||||
-rw-r--r-- | test/mixingtypes.cpp | 6 | ||||
-rw-r--r-- | test/sparse_basic.cpp | 28 |
4 files changed, 21 insertions, 16 deletions
diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index 6bc566153..4f077424a 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -244,6 +244,7 @@ class SparseMatrix delete[] m_outerIndex; m_outerIndex = new int [outerSize+1]; m_outerSize = outerSize; + memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int)); } } void resizeNonZeros(int size) diff --git a/test/cholesky.cpp b/test/cholesky.cpp index eb613cd6a..04f97bcea 100644 --- a/test/cholesky.cpp +++ b/test/cholesky.cpp @@ -21,7 +21,7 @@ // You should have received a copy of the GNU Lesser General Public // License and a copy of the GNU General Public License along with // Eigen. If not, see <http://www.gnu.org/licenses/>. -#define EIGEN_DONT_VECTORIZE + #include "main.h" #include <Eigen/Cholesky> #include <Eigen/LU> diff --git a/test/mixingtypes.cpp b/test/mixingtypes.cpp index 686839161..ad03639a9 100644 --- a/test/mixingtypes.cpp +++ b/test/mixingtypes.cpp @@ -23,8 +23,14 @@ // License and a copy of the GNU General Public License along with // 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 +#endif + +#ifndef EIGEN_DONT_VECTORIZE #define EIGEN_DONT_VECTORIZE // SSE intrinsics aren't designed to allow mixing types +#endif + #include "main.h" diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp index 84cf4cd16..d57c66465 100644 --- a/test/sparse_basic.cpp +++ b/test/sparse_basic.cpp @@ -174,21 +174,19 @@ template<typename Scalar> void sparse_basic(int rows, int cols) std::cerr << m1 << "\n\n" << m2 << "\n"; VERIFY_IS_APPROX(m2,m1); } -// { -// m.setZero(); -// VERIFY_IS_NOT_APPROX(m, refMat); -// // RandomSetter<SparseMatrix<Scalar> > w(m); -// RandomSetter<SparseMatrix<Scalar>, GoogleDenseHashMapTraits > w(m); -// // RandomSetter<SparseMatrix<Scalar>, GnuHashMapTraits > w(m); -// std::vector<Vector2i> remaining = nonzeroCoords; -// while(!remaining.empty()) -// { -// int i = ei_random<int>(0,remaining.size()-1); -// w(remaining[i].x(),remaining[i].y()) = refMat.coeff(remaining[i].x(),remaining[i].y()); -// remaining[i] = remaining.back(); -// remaining.pop_back(); -// } -// } + // test RandomSetter + { + SparseMatrix<Scalar> m1(rows,cols), m2(rows,cols); + DenseMatrix refM1 = DenseMatrix::Zero(rows, rows); + initSparse<Scalar>(density, refM1, m1); + { + Eigen::RandomSetter<SparseMatrix<Scalar> > setter(m2); + for (int j=0; j<m1.outerSize(); ++j) + for (typename SparseMatrix<Scalar>::InnerIterator i(m1,j); i; ++i) + setter(i.index(), j) = i.value(); + } + VERIFY_IS_APPROX(m1, m2); + } // std::cerr << m.transpose() << "\n\n" << refMat.transpose() << "\n\n"; // VERIFY_IS_APPROX(m, refMat); |