aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-05-07 18:38:07 +0000
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-05-07 18:38:07 +0000
commitc8a22dbc08ebe8bcde7bf7717b09736bd3e1b46f (patch)
treecea9a76a550b240c66884f3768183926ea9b4101
parent159ab4a043cb82642a589a6c833d26e55d355a54 (diff)
CREDIT Hauke Heibel, more std::vector::insert fixes
-rw-r--r--Eigen/StdVector12
-rw-r--r--Eigen/src/Core/MathFunctions.h4
-rw-r--r--Eigen/src/LU/LU.h12
3 files changed, 15 insertions, 13 deletions
diff --git a/Eigen/StdVector b/Eigen/StdVector
index 3213afeaa..055295939 100644
--- a/Eigen/StdVector
+++ b/Eigen/StdVector
@@ -95,6 +95,7 @@ namespace std {
typedef typename vector_base::allocator_type allocator_type; \
typedef typename vector_base::size_type size_type; \
typedef typename vector_base::iterator iterator; \
+ typedef typename vector_base::const_iterator const_iterator; \
explicit vector(const allocator_type& a = allocator_type()) : vector_base(a) {} \
template<typename InputIterator> \
vector(InputIterator first, InputIterator last, const allocator_type& a = allocator_type()) \
@@ -129,13 +130,12 @@ class vector<T,Eigen::aligned_allocator<T> >
vector_base::erase(vector_base::begin() + new_size, vector_base::end());
}
void push_back(const value_type& x)
- { vector_base::push_back(x); }
- template<class _Iter> void insert(const_iterator position, _Iter first, _Iter last)
- { return vector_base::insert(position, first, last); }
- iterator insert(iterator position, const value_type& x)
+ { vector_base::push_back(x); }
+ using vector_base::insert;
+ iterator insert(const_iterator position, const value_type& x)
{ return vector_base::insert(position,x); }
- iterator insert(iterator position, size_type new_size, const value_type& x)
- { return vector_base::insert(position, new_size, x); }
+ void insert(const_iterator position, size_type new_size, const value_type& x)
+ { vector_base::insert(position, new_size, x); }
#elif defined(_GLIBCXX_VECTOR) && EIGEN_GNUC_AT_LEAST(4,1)
// workaround GCC std::vector implementation
// Note that before gcc-4.1 we already have: std::vector::resize(size_type,const T&),
diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
index e201f98b2..3f2adf866 100644
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -103,7 +103,7 @@ inline bool ei_isApproxOrLessThan(int a, int b, int = precision<int>())
*** float ***
**************/
-template<> inline float precision<float>() { return 1e-5f; }
+template<> inline float precision<float>() { return 1e-4f; }
template<> inline float machine_epsilon<float>() { return 1.192e-07f; }
inline float ei_real(float x) { return x; }
inline float ei_imag(float) { return 0.f; }
@@ -149,7 +149,7 @@ inline bool ei_isApproxOrLessThan(float a, float b, float prec = precision<float
*** double ***
**************/
-template<> inline double precision<double>() { return 1e-11; }
+template<> inline double precision<double>() { return 1e-13; }
template<> inline double machine_epsilon<double>() { return 2.220e-16; }
inline double ei_real(double x) { return x; }
diff --git a/Eigen/src/LU/LU.h b/Eigen/src/LU/LU.h
index a9d046c24..d08224f34 100644
--- a/Eigen/src/LU/LU.h
+++ b/Eigen/src/LU/LU.h
@@ -96,7 +96,7 @@ template<typename MatrixType> class LU
*
* \param matrix the matrix of which to compute the LU decomposition.
*/
- LU(const MatrixType& matrix);
+ LU(const MatrixType& matrix, const RealScalar& precision = precision<Scalar>());
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
* unit-lower-triangular part is L (at least for square matrices; in the non-square
@@ -323,14 +323,16 @@ template<typename MatrixType> class LU
IntRowVectorType m_q;
int m_det_pq;
int m_rank;
+ RealScalar m_precision;
};
template<typename MatrixType>
-LU<MatrixType>::LU(const MatrixType& matrix)
+LU<MatrixType>::LU(const MatrixType& matrix, const RealScalar& precision)
: m_originalMatrix(matrix),
m_lu(matrix),
m_p(matrix.rows()),
- m_q(matrix.cols())
+ m_q(matrix.cols()),
+ m_precision(precision)
{
const int size = matrix.diagonal().size();
const int rows = matrix.rows();
@@ -355,7 +357,7 @@ LU<MatrixType>::LU(const MatrixType& matrix)
if(k==0) biggest = biggest_in_corner;
// if the corner is negligible, then we have less than full rank, and we can finish early
- if(ei_isMuchSmallerThan(biggest_in_corner, biggest))
+ if(ei_isMuchSmallerThan(biggest_in_corner, biggest, m_precision))
{
m_rank = k;
for(int i = k; i < size; i++)
@@ -506,7 +508,7 @@ bool LU<MatrixType>::solve(
RealScalar biggest_in_c = c.corner(TopLeft, m_rank, c.cols()).cwise().abs().maxCoeff();
for(int col = 0; col < c.cols(); ++col)
for(int row = m_rank; row < c.rows(); ++row)
- if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c))
+ if(!ei_isMuchSmallerThan(c.coeff(row,col), biggest_in_c, m_precision))
return false;
}
m_lu.corner(TopLeft, m_rank, m_rank)