aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-12 12:39:22 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-11-12 12:39:22 -0500
commit8132ee39089a47efa477599b81eaf571f4af3c45 (patch)
treedbb80a38ecef07299918b113ab177d1b0124fc30
parent358452bbe6a3fcc8290969dbd531e30701a4c1f2 (diff)
* add non-default option to initialize matrices by 0
(useful for porting) * maketests really has to be in test/
-rw-r--r--Eigen/src/Core/Matrix.h11
-rw-r--r--scripts/CMakeLists.txt1
-rw-r--r--test/CMakeLists.txt2
-rwxr-xr-xtest/maketests.in (renamed from scripts/maketests.in)0
4 files changed, 12 insertions, 2 deletions
diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h
index 17d2f2836..3cd7edfd6 100644
--- a/Eigen/src/Core/Matrix.h
+++ b/Eigen/src/Core/Matrix.h
@@ -25,6 +25,12 @@
#ifndef EIGEN_MATRIX_H
#define EIGEN_MATRIX_H
+#ifdef EIGEN_INITIALIZE_MATRICES_BY_ZERO
+# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED setZero();
+#else
+# define EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
+#endif
+
template <typename Derived, typename OtherDerived, bool IsVector = static_cast<bool>(Derived::IsVectorAtCompileTime)> struct ei_conservative_resize_like_impl;
/** \class Matrix
@@ -427,13 +433,14 @@ class Matrix
EIGEN_STRONG_INLINE explicit Matrix() : m_storage()
{
_check_template_params();
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
/** \internal */
Matrix(ei_constructor_without_unaligned_array_assert)
: m_storage(ei_constructor_without_unaligned_array_assert())
- { _check_template_params(); }
+ { _check_template_params(); EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED }
#endif
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
@@ -449,6 +456,7 @@ class Matrix
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Matrix)
ei_assert(dim > 0);
ei_assert(SizeAtCompileTime == Dynamic || SizeAtCompileTime == dim);
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
}
#ifndef EIGEN_PARSED_BY_DOXYGEN
@@ -692,6 +700,7 @@ class Matrix
ei_assert(rows > 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows)
&& cols > 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols));
m_storage.resize(rows*cols,rows,cols);
+ EIGEN_INITIALIZE_BY_ZERO_IF_THAT_OPTION_IS_ENABLED
}
template<typename T0, typename T1>
EIGEN_STRONG_INLINE void _init2(const Scalar& x, const Scalar& y, typename ei_enable_if<Base::SizeAtCompileTime==2,T0>::type* = 0)
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index e373d3188..2d40e32ae 100644
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -1,4 +1,3 @@
-configure_file(maketests.in ${CMAKE_BINARY_DIR}/maketests)
configure_file(mctestr.in ${CMAKE_BINARY_DIR}/mctestr)
configure_file(debug.in ${CMAKE_BINARY_DIR}/debug)
configure_file(release.in ${CMAKE_BINARY_DIR}/release)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d0938302f..5cea1a582 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -162,3 +162,5 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif(CMAKE_COMPILER_IS_GNUCXX)
ei_add_property(EIGEN_TESTING_SUMMARY "CXX_FLAGS: ${CMAKE_CXX_FLAGS}\n")
ei_add_property(EIGEN_TESTING_SUMMARY "Sparse lib flags: ${SPARSE_LIBS}\n")
+
+configure_file(maketests.in ${CMAKE_BINARY_DIR}/maketests)
diff --git a/scripts/maketests.in b/test/maketests.in
index f9cafed26..f9cafed26 100755
--- a/scripts/maketests.in
+++ b/test/maketests.in