diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | Eigen/Sparse | 2 | ||||
-rw-r--r-- | Eigen/src/Sparse/SparseMatrix.h | 33 | ||||
-rw-r--r-- | test/CMakeLists.txt | 11 | ||||
-rw-r--r-- | test/main.h | 2 |
5 files changed, 38 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b407d78d4..840ba6f53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,7 +31,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_SYSTEM_NAME MATCHES Linux) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -fno-exceptions -fno-check-new -fno-common -fstrict-aliasing") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wextra -fno-exceptions -fno-check-new -fno-common -fstrict-aliasing") if(NOT EIGEN_TEST_LIB) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") endif(NOT EIGEN_TEST_LIB) diff --git a/Eigen/Sparse b/Eigen/Sparse index b8a10c9e0..b48f0c093 100644 --- a/Eigen/Sparse +++ b/Eigen/Sparse @@ -100,6 +100,8 @@ namespace Eigen { # include "src/Sparse/UmfPackSupport.h" #endif +#include "src/Sparse/ConstrainedCG.h" + } // namespace Eigen #endif // EIGEN_SPARSE_MODULE_H diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h index d58d910e8..5a6b2e0d4 100644 --- a/Eigen/src/Sparse/SparseMatrix.h +++ b/Eigen/src/Sparse/SparseMatrix.h @@ -128,6 +128,17 @@ class SparseMatrix class InnerIterator; + inline void setZero() + { + m_data.clear(); + //if (m_outerSize) + memset(m_outerIndex, 0, (m_outerSize+1)*sizeof(int)); +// for (int i=0; i<m_outerSize; ++i) +// m_outerIndex[i] = 0; +// if (m_outerSize) +// m_outerIndex[i] = 0; + } + /** \returns the number of non zero coefficients */ inline int nonZeros() const { return m_data.size(); } @@ -137,10 +148,9 @@ class SparseMatrix */ inline void startFill(int reserveSize = 1000) { - m_data.clear(); + std::cerr << this << " startFill\n"; + setZero(); m_data.reserve(reserveSize); - for (int i=0; i<=m_outerSize; ++i) - m_outerIndex[i] = 0; } /** @@ -188,7 +198,7 @@ class SparseMatrix } m_outerIndex[outer+1] = m_outerIndex[outer]; } - // +// std::cerr << this << " " << outer << " " << inner << " - " << m_outerIndex[outer] << " " << m_outerIndex[outer+1] << "\n"; assert(m_outerIndex[outer+1] == m_data.size() && "invalid outer index"); int startId = m_outerIndex[outer]; int id = m_outerIndex[outer+1]-1; @@ -202,11 +212,17 @@ class SparseMatrix --id; } m_data.index(id+1) = inner; - return (m_data.value(id+1) = 0); + //return (m_data.value(id+1) = 0); + m_data.value(id+1) = 0; + std::cerr << m_outerIndex[outer] << " " << m_outerIndex[outer+1] << "\n"; + return m_data.value(id+1); } +// inline void + inline void endFill() { + std::cerr << this << " endFill\n"; int size = m_data.size(); int i = m_outerSize; // find the last filled column @@ -222,6 +238,7 @@ class SparseMatrix void resize(int rows, int cols) { + std::cerr << this << " resize " << rows << "x" << cols << "\n"; const int outerSize = RowMajor ? rows : cols; m_innerSize = RowMajor ? cols : rows; m_data.clear(); @@ -238,8 +255,10 @@ class SparseMatrix } inline SparseMatrix() - : m_outerSize(0), m_innerSize(0), m_outerIndex(0) - {} + : m_outerSize(-1), m_innerSize(0), m_outerIndex(0) + { + resize(0, 0); + } inline SparseMatrix(int rows, int cols) : m_outerSize(0), m_innerSize(0), m_outerIndex(0) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e9a5eb14d..58ab73525 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,9 +26,9 @@ else(CHOLMOD_FOUND) message("CHOLMOD not found, this optional backend won't be tested") endif(CHOLMOD_FOUND) -if(NOT WIN32) +if(NOT MSVC) enable_language(Fortran OPTIONAL) -endif(NOT WIN32) +endif(NOT MSVC) find_package(Umfpack) if(UMFPACK_FOUND) @@ -102,7 +102,12 @@ macro(ei_add_test testname) if(NOT EIGEN_NO_ASSERTION_CHECKING) - set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions") + if(MSVC) + set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "/EHsc") + else(MSVC) + set_target_properties(${targetname} PROPERTIES COMPILE_FLAGS "-fexceptions") + endif(MSVC) + option(EIGEN_DEBUG_ASSERTS "Enable debuging of assertions" OFF) if(EIGEN_DEBUG_ASSERTS) set_target_properties(${targetname} PROPERTIES COMPILE_DEFINITIONS "-DEIGEN_DEBUG_ASSERTS=1") diff --git a/test/main.h b/test/main.h index 4c8b443d3..0476df3cc 100644 --- a/test/main.h +++ b/test/main.h @@ -47,7 +47,7 @@ namespace Eigen #define EI_PP_CAT2(a,b) a ## b #define EI_PP_CAT(a,b) EI_PP_CAT2(a,b) -#define EIGEN_NO_EXCEPTIONS // disabling throwing assertions on bad alloc -- somehow makes the tests crawl +//#define EIGEN_NO_EXCEPTIONS // disabling throwing assertions on bad alloc -- somehow makes the tests crawl #ifndef EIGEN_NO_ASSERTION_CHECKING |