* fix compilation with gcc 3.4
* add an option to disable Qt testing
diff --git a/Eigen/src/Sparse/CompressedStorage.h b/Eigen/src/Sparse/CompressedStorage.h
index 4e8074b..4dbd323 100644
--- a/Eigen/src/Sparse/CompressedStorage.h
+++ b/Eigen/src/Sparse/CompressedStorage.h
@@ -37,7 +37,7 @@
: m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
{}
- CompressedStorage(int size)
+ CompressedStorage(size_t size)
: m_values(0), m_indices(0), m_size(0), m_allocatedSize(0)
{
resize(size);
@@ -71,9 +71,9 @@
delete[] m_indices;
}
- void reserve(int size)
+ void reserve(size_t size)
{
- int newAllocatedSize = m_size + size;
+ size_t newAllocatedSize = m_size + size;
if (newAllocatedSize > m_allocatedSize)
reallocate(newAllocatedSize);
}
@@ -84,10 +84,10 @@
reallocate(m_size);
}
- void resize(int size, float reserveSizeFactor = 0)
+ void resize(size_t size, float reserveSizeFactor = 0)
{
if (m_allocatedSize<size)
- reallocate(size + reserveSizeFactor*size);
+ reallocate(size + size_t(reserveSizeFactor*size));
m_size = size;
}
@@ -99,17 +99,17 @@
m_indices[id] = i;
}
- inline int size() const { return m_size; }
- inline int allocatedSize() const { return m_allocatedSize; }
+ inline size_t size() const { return m_size; }
+ inline size_t allocatedSize() const { return m_allocatedSize; }
inline void clear() { m_size = 0; }
- inline Scalar& value(int i) { return m_values[i]; }
- inline const Scalar& value(int i) const { return m_values[i]; }
+ inline Scalar& value(size_t i) { return m_values[i]; }
+ inline const Scalar& value(size_t i) const { return m_values[i]; }
- inline int& index(int i) { return m_indices[i]; }
- inline const int& index(int i) const { return m_indices[i]; }
+ inline int& index(size_t i) { return m_indices[i]; }
+ inline const int& index(size_t i) const { return m_indices[i]; }
- static CompressedStorage Map(int* indices, Scalar* values, int size)
+ static CompressedStorage Map(int* indices, Scalar* values, size_t size)
{
CompressedStorage res;
res.m_indices = indices;
@@ -125,11 +125,11 @@
}
/** \returns the largest \c k in [start,end) such that for all \c j in [start,k) index[\c j]\<\a key */
- inline int searchLowerIndex(int start, int end, int key) const
+ inline int searchLowerIndex(size_t start, size_t end, int key) const
{
while(end>start)
{
- int mid = (end+start)>>1;
+ size_t mid = (end+start)>>1;
if (m_indices[mid]<key)
start = mid+1;
else
@@ -148,12 +148,12 @@
return m_values[m_size-1];
// ^^ optimization: let's first check if it is the last coefficient
// (very common in high level algorithms)
- const int id = searchLowerIndex(0,m_size-1,key);
+ const size_t id = searchLowerIndex(0,m_size-1,key);
return ((id<m_size) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
}
/** Like at(), but the search is performed in the range [start,end) */
- inline Scalar atInRange(int start, int end, int key, Scalar defaultValue = Scalar(0)) const
+ inline Scalar atInRange(size_t start, size_t end, int key, Scalar defaultValue = Scalar(0)) const
{
if (start==end)
return Scalar(0);
@@ -161,7 +161,7 @@
return m_values[end-1];
// ^^ optimization: let's first check if it is the last coefficient
// (very common in high level algorithms)
- const int id = searchLowerIndex(start,end-1,key);
+ const size_t id = searchLowerIndex(start,end-1,key);
return ((id<end) && (m_indices[id]==key)) ? m_values[id] : defaultValue;
}
@@ -170,11 +170,11 @@
* such that the keys are sorted. */
inline Scalar& atWithInsertion(int key, Scalar defaultValue = Scalar(0))
{
- int id = searchLowerIndex(0,m_size,key);
+ size_t id = searchLowerIndex(0,m_size,key);
if (id>=m_size || m_indices[id]!=key)
{
resize(m_size+1,1);
- for (int j=m_size-1; j>id; --j)
+ for (size_t j=m_size-1; j>id; --j)
{
m_indices[j] = m_indices[j-1];
m_values[j] = m_values[j-1];
@@ -187,9 +187,9 @@
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
{
- int k = 0;
- int n = size();
- for (int i=0; i<n; ++i)
+ size_t k = 0;
+ size_t n = size();
+ for (size_t i=0; i<n; ++i)
{
if (!ei_isMuchSmallerThan(value(i), reference, epsilon))
{
@@ -203,11 +203,11 @@
protected:
- inline void reallocate(int size)
+ inline void reallocate(size_t size)
{
Scalar* newValues = new Scalar[size];
int* newIndices = new int[size];
- int copySize = std::min(size, m_size);
+ size_t copySize = std::min(size, m_size);
// copy
memcpy(newValues, m_values, copySize * sizeof(Scalar));
memcpy(newIndices, m_indices, copySize * sizeof(int));
@@ -222,8 +222,8 @@
protected:
Scalar* m_values;
int* m_indices;
- int m_size;
- int m_allocatedSize;
+ size_t m_size;
+ size_t m_allocatedSize;
};
diff --git a/Eigen/src/Sparse/DynamicSparseMatrix.h b/Eigen/src/Sparse/DynamicSparseMatrix.h
index 5e7ce93..1cd302f 100644
--- a/Eigen/src/Sparse/DynamicSparseMatrix.h
+++ b/Eigen/src/Sparse/DynamicSparseMatrix.h
@@ -231,7 +231,7 @@
}
inline DynamicSparseMatrix(const DynamicSparseMatrix& other)
- : m_innerSize(0)
+ : Base(), m_innerSize(0)
{
*this = other.derived();
}
diff --git a/Eigen/src/Sparse/SparseMatrix.h b/Eigen/src/Sparse/SparseMatrix.h
index e0c56be..5e8ca84 100644
--- a/Eigen/src/Sparse/SparseMatrix.h
+++ b/Eigen/src/Sparse/SparseMatrix.h
@@ -155,7 +155,7 @@
}
m_outerIndex[outer+1] = m_outerIndex[outer];
}
- assert(m_outerIndex[outer+1] == m_data.size());
+ assert(size_t(m_outerIndex[outer+1]) == m_data.size());
int id = m_outerIndex[outer+1];
++m_outerIndex[outer+1];
@@ -183,9 +183,9 @@
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;
+ assert(size_t(m_outerIndex[outer+1]) == m_data.size() && "invalid outer index");
+ size_t startId = m_outerIndex[outer];
+ size_t id = m_outerIndex[outer+1]-1;
++m_outerIndex[outer+1];
float reallocRatio = 1;
@@ -292,7 +292,7 @@
}
inline SparseMatrix(const SparseMatrix& other)
- : m_outerSize(0), m_innerSize(0), m_outerIndex(0)
+ : Base(), m_outerSize(0), m_innerSize(0), m_outerIndex(0)
{
*this = other.derived();
}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 4d29db0..224abe3 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -64,13 +64,16 @@
set(EIGEN_MISSING_BACKENDS ${EIGEN_MISSING_BACKENDS} GoogleHash)
endif(GOOGLEHASH_FOUND)
-find_package(Qt4)
-if(QT4_FOUND)
- include(${QT_USE_FILE})
- set(EIGEN_TESTED_BACKENDS ${EIGEN_TESTED_BACKENDS} "Qt4 support")
-else(QT4_FOUND)
- set(EIGEN_MISSING_BACKENDS ${EIGEN_MISSING_BACKENDS} "Qt4 support")
-endif(QT4_FOUND)
+option(EIGEN_TEST_NOQT "Disable Qt support in unit tests" OFF)
+if(NOT EIGEN_TEST_NOQT)
+ find_package(Qt4)
+ if(QT4_FOUND)
+ include(${QT_USE_FILE})
+ set(EIGEN_TESTED_BACKENDS ${EIGEN_TESTED_BACKENDS} "Qt4 support")
+ else(QT4_FOUND)
+ set(EIGEN_MISSING_BACKENDS ${EIGEN_MISSING_BACKENDS} "Qt4 support")
+ endif(QT4_FOUND)
+endif(NOT EIGEN_TEST_NOQT)
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_SYSTEM_NAME MATCHES Linux)
diff --git a/test/sparse_basic.cpp b/test/sparse_basic.cpp
index 5ae038e..68e3573 100644
--- a/test/sparse_basic.cpp
+++ b/test/sparse_basic.cpp
@@ -24,9 +24,10 @@
#include "sparse.h"
-template<typename SetterType,typename DenseType, typename SparseType>
-bool test_random_setter(SparseType& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords)
+template<typename SetterType,typename DenseType, typename Scalar, int Options>
+bool test_random_setter(SparseMatrix<Scalar,Options>& sm, const DenseType& ref, const std::vector<Vector2i>& nonzeroCoords)
{
+ typedef SparseMatrix<Scalar,Options> SparseType;
{
sm.setZero();
SetterType w(sm);
diff --git a/test/testsuite.cmake b/test/testsuite.cmake
index 6be9031..9bbe01d 100644
--- a/test/testsuite.cmake
+++ b/test/testsuite.cmake
@@ -26,6 +26,7 @@
# default: Nightly
# - EIGEN_WORK_DIR: directory used to download the source files and make the builds
# default: folder which contains this script
+# - EIGEN_CMAKE_ARGS: additional arguments passed to cmake
# - CTEST_SOURCE_DIRECTORY: path to eigen's src (use a new and empty folder, not the one you are working on)
# default: <EIGEN_WORK_DIR>/src
# - CTEST_BINARY_DIRECTORY: build directory
@@ -189,3 +190,7 @@
message(FATAL_ERROR "Invalid value for EIGEN_EXPLICIT_VECTORIZATION (${EIGEN_EXPLICIT_VECTORIZATION}), must be: novec, SSE2, SSE3, Altivec")
endif(EIGEN_EXPLICIT_VECTORIZATION MATCHES SSE2)
endif(DEFINED EIGEN_EXPLICIT_VECTORIZATION)
+
+if(DEFINED EIGEN_CMAKE_ARGS)
+ set(CTEST_CMAKE_COMMAND "${CTEST_CMAKE_COMMAND} ${EIGEN_CMAKE_ARGS}")
+endif(DEFINED EIGEN_CMAKE_ARGS)