merge with default branch

This commit is contained in:
Gael Guennebaud
2009-12-22 22:51:08 +01:00
200 changed files with 3649 additions and 1636 deletions

View File

@@ -126,10 +126,6 @@ template<typename _Scalar> class AmbiVector
int m_llStart;
int m_llCurrent;
int m_llSize;
private:
AmbiVector(const AmbiVector&);
};
/** \returns the number of non zeros in the current sub vector */
@@ -300,7 +296,7 @@ class AmbiVector<_Scalar>::Iterator
* In practice, all coefficients having a magnitude smaller than \a epsilon
* are skipped.
*/
Iterator(const AmbiVector& vec, RealScalar epsilon = RealScalar(0.1)*precision<RealScalar>())
Iterator(const AmbiVector& vec, RealScalar epsilon = RealScalar(0.1)*dummy_precision<RealScalar>())
: m_vector(vec)
{
m_epsilon = epsilon;

View File

@@ -93,7 +93,7 @@ class CompressedStorage
void append(const Scalar& v, int i)
{
int id = m_size;
int id = static_cast<int>(m_size);
resize(m_size+1, 1);
m_values[id] = v;
m_indices[id] = i;
@@ -135,7 +135,7 @@ class CompressedStorage
else
end = mid;
}
return start;
return static_cast<int>(start);
}
/** \returns the stored value at index \a key
@@ -185,7 +185,7 @@ class CompressedStorage
return m_values[id];
}
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>())
{
size_t k = 0;
size_t n = size();

View File

@@ -58,6 +58,13 @@ struct ei_traits<DynamicSparseMatrix<_Scalar, _Flags> >
};
};
template<typename _Scalar, int _Options>
struct ei_ref_selector< DynamicSparseMatrix<_Scalar, _Options> >
{
typedef DynamicSparseMatrix<_Scalar, _Options> MatrixType;
typedef MatrixType const& type;
};
template<typename _Scalar, int _Flags>
class DynamicSparseMatrix
: public SparseMatrixBase<DynamicSparseMatrix<_Scalar, _Flags> >
@@ -82,7 +89,7 @@ class DynamicSparseMatrix
inline int rows() const { return IsRowMajor ? outerSize() : m_innerSize; }
inline int cols() const { return IsRowMajor ? m_innerSize : outerSize(); }
inline int innerSize() const { return m_innerSize; }
inline int outerSize() const { return m_data.size(); }
inline int outerSize() const { return static_cast<int>(m_data.size()); }
inline int innerNonZeros(int j) const { return m_data[j].size(); }
std::vector<CompressedStorage<Scalar> >& _data() { return m_data; }
@@ -122,7 +129,7 @@ class DynamicSparseMatrix
{
int res = 0;
for (int j=0; j<outerSize(); ++j)
res += m_data[j].size();
res += static_cast<int>(m_data[j].size());
return res;
}
@@ -189,7 +196,7 @@ class DynamicSparseMatrix
const int inner = IsRowMajor ? col : row;
int startId = 0;
int id = m_data[outer].size() - 1;
int id = static_cast<int>(m_data[outer].size()) - 1;
m_data[outer].resize(id+2,1);
while ( (id >= startId) && (m_data[outer].index(id) > inner) )
@@ -209,7 +216,7 @@ class DynamicSparseMatrix
inline void finalize() {}
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>())
{
for (int j=0; j<outerSize(); ++j)
m_data[j].prune(reference,epsilon);
@@ -314,7 +321,6 @@ class DynamicSparseMatrix<Scalar,_Flags>::InnerIterator : public SparseVector<Sc
inline int row() const { return IsRowMajor ? m_outer : Base::index(); }
inline int col() const { return IsRowMajor ? Base::index() : m_outer; }
protected:
const int m_outer;
};

View File

@@ -322,7 +322,7 @@ class RandomSetter
{
int nz = 0;
for (int k=0; k<m_outerPackets; ++k)
nz += m_hashmaps[k].size();
nz += static_cast<int>(m_hashmaps[k].size());
return nz;
}

View File

@@ -86,8 +86,7 @@ class SparseDiagonalProduct
typedef ei_sparse_diagonal_product_inner_iterator_selector
<_LhsNested,_RhsNested,SparseDiagonalProduct,LhsMode,RhsMode> InnerIterator;
template<typename _Lhs, typename _Rhs>
EIGEN_STRONG_INLINE SparseDiagonalProduct(const _Lhs& lhs, const _Rhs& rhs)
EIGEN_STRONG_INLINE SparseDiagonalProduct(const Lhs& lhs, const Rhs& rhs)
: m_lhs(lhs), m_rhs(rhs)
{
ei_assert(lhs.cols() == rhs.rows() && "invalid sparse matrix * diagonal matrix product");
@@ -156,16 +155,16 @@ class ei_sparse_diagonal_product_inner_iterator_selector
: public CwiseBinaryOp<
ei_scalar_product_op<typename Rhs::Scalar>,
SparseInnerVectorSet<Lhs,1>,
NestByValue<Transpose<typename Rhs::DiagonalVectorType> > >::InnerIterator
Transpose<typename Rhs::DiagonalVectorType> >::InnerIterator
{
typedef typename CwiseBinaryOp<
ei_scalar_product_op<typename Rhs::Scalar>,
SparseInnerVectorSet<Lhs,1>,
NestByValue<Transpose<typename Rhs::DiagonalVectorType> > >::InnerIterator Base;
Transpose<typename Rhs::DiagonalVectorType> >::InnerIterator Base;
public:
inline ei_sparse_diagonal_product_inner_iterator_selector(
const SparseDiagonalProductType& expr, int outer)
: Base(expr.lhs().innerVector(outer) .cwiseProduct(expr.rhs().diagonal().transpose().nestByValue()), 0)
: Base(expr.lhs().innerVector(outer) .cwiseProduct(expr.rhs().diagonal().transpose()), 0)
{}
};

View File

@@ -0,0 +1,42 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2009 Gael Guennebaud <g.gael@free.fr>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// 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/>.
#ifndef EIGEN_SPARSE_EXPRESSIONMAKER_H
#define EIGEN_SPARSE_EXPRESSIONMAKER_H
template<typename Func, typename XprType>
struct MakeCwiseUnaryOp<Func,XprType,IsSparse>
{
typedef SparseCwiseUnaryOp<Func,XprType> Type;
};
template<typename Func, typename A, typename B>
struct MakeCwiseBinaryOp<Func,A,B,IsSparse>
{
typedef SparseCwiseBinaryOp<Func,A,B> Type;
};
// TODO complete the list
#endif // EIGEN_SPARSE_EXPRESSIONMAKER_H

View File

@@ -94,7 +94,7 @@ class SparseLDLT
: m_flags(flags), m_status(0)
{
ei_assert((MatrixType::Flags&RowMajorBit)==0);
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
}
/** Creates a LDLT object and compute the respective factorization of \a matrix using
@@ -103,7 +103,7 @@ class SparseLDLT
: m_matrix(matrix.rows(), matrix.cols()), m_flags(flags), m_status(0)
{
ei_assert((MatrixType::Flags&RowMajorBit)==0);
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
compute(matrix);
}

View File

@@ -54,7 +54,7 @@ class SparseLLT
SparseLLT(int flags = 0)
: m_flags(flags), m_status(0)
{
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
}
/** Creates a LLT object and compute the respective factorization of \a matrix using
@@ -62,7 +62,7 @@ class SparseLLT
SparseLLT(const MatrixType& matrix, int flags = 0)
: m_matrix(matrix.rows(), matrix.cols()), m_flags(flags), m_status(0)
{
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
compute(matrix);
}

View File

@@ -59,7 +59,7 @@ class SparseLU
SparseLU(int flags = 0)
: m_flags(flags), m_status(0)
{
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
}
/** Creates a LU object and compute the respective factorization of \a matrix using
@@ -67,7 +67,7 @@ class SparseLU
SparseLU(const MatrixType& matrix, int flags = 0)
: /*m_matrix(matrix.rows(), matrix.cols()),*/ m_flags(flags), m_status(0)
{
m_precision = RealScalar(0.1) * Eigen::precision<RealScalar>();
m_precision = RealScalar(0.1) * Eigen::dummy_precision<RealScalar>();
compute(matrix);
}

View File

@@ -57,6 +57,13 @@ struct ei_traits<SparseMatrix<_Scalar, _Options> >
};
};
template<typename _Scalar, int _Options>
struct ei_ref_selector<SparseMatrix<_Scalar, _Options> >
{
typedef SparseMatrix<_Scalar, _Options> MatrixType;
typedef MatrixType const& type;
};
template<typename _Scalar, int _Options>
class SparseMatrix
: public SparseMatrixBase<SparseMatrix<_Scalar, _Options> >
@@ -132,7 +139,7 @@ class SparseMatrix
}
/** \returns the number of non zero coefficients */
inline int nonZeros() const { return m_data.size(); }
inline int nonZeros() const { return static_cast<int>(m_data.size()); }
/** \deprecated use setZero() and reserve()
* Initializes the filling process of \c *this.
@@ -230,7 +237,7 @@ class SparseMatrix
// we start a new inner vector
while (previousOuter>=0 && m_outerIndex[previousOuter]==0)
{
m_outerIndex[previousOuter] = m_data.size();
m_outerIndex[previousOuter] = static_cast<int>(m_data.size());
--previousOuter;
}
m_outerIndex[outer+1] = m_outerIndex[outer];
@@ -329,7 +336,7 @@ class SparseMatrix
*/
inline void finalize()
{
int size = m_data.size();
int size = static_cast<int>(m_data.size());
int i = m_outerSize;
// find the last filled column
while (i>=0 && m_outerIndex[i]==0)
@@ -342,7 +349,7 @@ class SparseMatrix
}
}
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>())
{
int k = 0;
for (int j=0; j<m_outerSize; ++j)

View File

@@ -105,7 +105,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
// typedef SparseCwiseUnaryOp<ei_scalar_imag_op<Scalar>, Derived> ImagReturnType;
/** \internal the return type of MatrixBase::adjoint() */
typedef typename ei_meta_if<NumTraits<Scalar>::IsComplex,
CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, SparseNestByValue<Eigen::Transpose<Derived> > >,
CwiseUnaryOp<ei_scalar_conjugate_op<Scalar>, Eigen::Transpose<Derived> >,
Transpose<Derived>
>::ret AdjointReturnType;
@@ -399,7 +399,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
Transpose<Derived> transpose() { return derived(); }
const Transpose<Derived> transpose() const { return derived(); }
// void transposeInPlace();
const AdjointReturnType adjoint() const { return transpose().nestByValue(); }
const AdjointReturnType adjoint() const { return transpose(); }
// sub-vector
SparseInnerVectorSet<Derived,1> row(int i);
@@ -510,32 +510,32 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
template<typename OtherDerived>
bool isApprox(const SparseMatrixBase<OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const
RealScalar prec = dummy_precision<Scalar>()) const
{ return toDense().isApprox(other.toDense(),prec); }
template<typename OtherDerived>
bool isApprox(const MatrixBase<OtherDerived>& other,
RealScalar prec = precision<Scalar>()) const
RealScalar prec = dummy_precision<Scalar>()) const
{ return toDense().isApprox(other,prec); }
// bool isMuchSmallerThan(const RealScalar& other,
// RealScalar prec = precision<Scalar>()) const;
// RealScalar prec = dummy_precision<Scalar>()) const;
// template<typename OtherDerived>
// bool isMuchSmallerThan(const MatrixBase<OtherDerived>& other,
// RealScalar prec = precision<Scalar>()) const;
// RealScalar prec = dummy_precision<Scalar>()) const;
// bool isApproxToConstant(const Scalar& value, RealScalar prec = precision<Scalar>()) const;
// bool isZero(RealScalar prec = precision<Scalar>()) const;
// bool isOnes(RealScalar prec = precision<Scalar>()) const;
// bool isIdentity(RealScalar prec = precision<Scalar>()) const;
// bool isDiagonal(RealScalar prec = precision<Scalar>()) const;
// bool isApproxToConstant(const Scalar& value, RealScalar prec = dummy_precision<Scalar>()) const;
// bool isZero(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isOnes(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isIdentity(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isDiagonal(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isUpperTriangular(RealScalar prec = precision<Scalar>()) const;
// bool isLowerTriangular(RealScalar prec = precision<Scalar>()) const;
// bool isUpperTriangular(RealScalar prec = dummy_precision<Scalar>()) const;
// bool isLowerTriangular(RealScalar prec = dummy_precision<Scalar>()) const;
// template<typename OtherDerived>
// bool isOrthogonal(const MatrixBase<OtherDerived>& other,
// RealScalar prec = precision<Scalar>()) const;
// bool isUnitary(RealScalar prec = precision<Scalar>()) const;
// RealScalar prec = dummy_precision<Scalar>()) const;
// bool isUnitary(RealScalar prec = dummy_precision<Scalar>()) const;
// template<typename OtherDerived>
// inline bool operator==(const MatrixBase<OtherDerived>& other) const
@@ -571,9 +571,7 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
*/
// inline int stride(void) const { return derived().stride(); }
inline const SparseNestByValue<Derived> nestByValue() const;
// FIXME
// ConjugateReturnType conjugate() const;
// const RealReturnType real() const;
// const ImagReturnType imag() const;
@@ -626,11 +624,11 @@ template<typename Derived> class SparseMatrixBase : public AnyMatrixBase<Derived
const MatrixBase<ElseDerived>& elseMatrix) const;
template<typename ThenDerived>
inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
select(const MatrixBase<ThenDerived>& thenMatrix, typename ThenDerived::Scalar elseScalar) const;
template<typename ElseDerived>
inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
select(typename ElseDerived::Scalar thenScalar, const MatrixBase<ElseDerived>& elseMatrix) const;
template<int p> RealScalar lpNorm() const;

View File

@@ -1,84 +0,0 @@
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008-2009 Gael Guennebaud <g.gael@free.fr>
// Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
//
// Eigen is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 3 of the License, or (at your option) any later version.
//
// Alternatively, you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; either version 2 of
// the License, or (at your option) any later version.
//
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
// GNU General Public License for more details.
//
// 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/>.
#ifndef EIGEN_SPARSENESTBYVALUE_H
#define EIGEN_SPARSENESTBYVALUE_H
/** \class SparseNestByValue
*
* \brief Expression which must be nested by value
*
* \param ExpressionType the type of the object of which we are requiring nesting-by-value
*
* This class is the return type of MatrixBase::nestByValue()
* and most of the time this is the only way it is used.
*
* \sa SparseMatrixBase::nestByValue(), class NestByValue
*/
template<typename ExpressionType>
struct ei_traits<SparseNestByValue<ExpressionType> > : public ei_traits<ExpressionType>
{};
template<typename ExpressionType> class SparseNestByValue
: public SparseMatrixBase<SparseNestByValue<ExpressionType> >
{
public:
typedef typename ExpressionType::InnerIterator InnerIterator;
EIGEN_SPARSE_GENERIC_PUBLIC_INTERFACE(SparseNestByValue)
inline SparseNestByValue(const ExpressionType& matrix) : m_expression(matrix) {}
EIGEN_STRONG_INLINE int rows() const { return m_expression.rows(); }
EIGEN_STRONG_INLINE int cols() const { return m_expression.cols(); }
operator const ExpressionType&() const { return m_expression; }
protected:
const ExpressionType m_expression;
};
/** \returns an expression of the temporary version of *this.
*/
template<typename Derived>
inline const SparseNestByValue<Derived>
SparseMatrixBase<Derived>::nestByValue() const
{
return SparseNestByValue<Derived>(derived());
}
// template<typename MatrixType>
// class SparseNestByValue<MatrixType>::InnerIterator : public MatrixType::InnerIterator
// {
// typedef typename MatrixType::InnerIterator Base;
// public:
//
// EIGEN_STRONG_INLINE InnerIterator(const SparseNestByValue& expr, int outer)
// : Base(expr.m_expression, outer)
// {}
// };
#endif // EIGEN_SPARSENESTBYVALUE_H

View File

@@ -123,11 +123,10 @@ template<typename _Scalar, int _Flags = 0> class DynamicSparseMatrix;
template<typename _Scalar, int _Flags = 0> class SparseVector;
template<typename _Scalar, int _Flags = 0> class MappedSparseMatrix;
template<typename MatrixType> class SparseNestByValue;
template<typename MatrixType, int Size> class SparseInnerVectorSet;
template<typename MatrixType, int Mode> class SparseTriangularView;
template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView;
template<typename Lhs, typename Rhs> class SparseDiagonalProduct;
template<typename MatrixType, int Size> class SparseInnerVectorSet;
template<typename MatrixType, int Mode> class SparseTriangularView;
template<typename MatrixType, unsigned int UpLo> class SparseSelfAdjointView;
template<typename Lhs, typename Rhs> class SparseDiagonalProduct;
template<typename Lhs, typename Rhs> class SparseProduct;
@@ -156,6 +155,4 @@ template<typename T> class ei_eval<T,Sparse>
typedef SparseMatrix<_Scalar, _Flags> type;
};
template<typename T> struct ei_must_nest_by_value<SparseNestByValue<T> > { enum { ret = true }; };
#endif // EIGEN_SPARSEUTIL_H

View File

@@ -52,6 +52,13 @@ struct ei_traits<SparseVector<_Scalar, _Options> >
};
};
template<typename _Scalar, int _Options>
struct ei_ref_selector< SparseVector<_Scalar, _Options> >
{
typedef SparseVector<_Scalar, _Options> MatrixType;
typedef MatrixType const& type;
};
template<typename _Scalar, int _Options>
class SparseVector
: public SparseMatrixBase<SparseVector<_Scalar, _Options> >
@@ -119,7 +126,7 @@ class SparseVector
inline void setZero() { m_data.clear(); }
/** \returns the number of non zero coefficients */
inline int nonZeros() const { return m_data.size(); }
inline int nonZeros() const { return static_cast<int>(m_data.size()); }
inline void startVec(int outer)
{
@@ -202,7 +209,7 @@ class SparseVector
EIGEN_DEPRECATED void endFill() {}
inline void finalize() {}
void prune(Scalar reference, RealScalar epsilon = precision<RealScalar>())
void prune(Scalar reference, RealScalar epsilon = dummy_precision<RealScalar>())
{
m_data.prune(reference,epsilon);
}
@@ -368,13 +375,13 @@ class SparseVector<Scalar,_Options>::InnerIterator
{
public:
InnerIterator(const SparseVector& vec, int outer=0)
: m_data(vec.m_data), m_id(0), m_end(m_data.size())
: m_data(vec.m_data), m_id(0), m_end(static_cast<int>(m_data.size()))
{
ei_assert(outer==0);
}
InnerIterator(const CompressedStorage<Scalar>& data)
: m_data(data), m_id(0), m_end(m_data.size())
: m_data(data), m_id(0), m_end(static_cast<int>(m_data.size()))
{}
template<unsigned int Added, unsigned int Removed>