mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-11 19:29:02 +08:00
merge
This commit is contained in:
commit
98285ba81c
@ -67,16 +67,16 @@ namespace Eigen {
|
||||
EIGEN_USING_MATRIX_TYPEDEFS \
|
||||
using Eigen::Matrix; \
|
||||
using Eigen::MatrixBase; \
|
||||
namespace ei_random = Eigen::internal::random; \
|
||||
namespace ei_real = Eigen::internal::real; \
|
||||
namespace ei_imag = Eigen::internal::imag; \
|
||||
namespace ei_conj = Eigen::internal::conj; \
|
||||
namespace ei_abs = Eigen::internal::abs; \
|
||||
namespace ei_abs2 = Eigen::internal::abs2; \
|
||||
namespace ei_sqrt = Eigen::internal::sqrt; \
|
||||
namespace ei_exp = Eigen::internal::exp; \
|
||||
namespace ei_log = Eigen::internal::log; \
|
||||
namespace ei_sin = Eigen::internal::sin; \
|
||||
namespace ei_cos = Eigen::internal::cos;
|
||||
using Eigen::ei_random; \
|
||||
using Eigen::ei_real; \
|
||||
using Eigen::ei_imag; \
|
||||
using Eigen::ei_conj; \
|
||||
using Eigen::ei_abs; \
|
||||
using Eigen::ei_abs2; \
|
||||
using Eigen::ei_sqrt; \
|
||||
using Eigen::ei_exp; \
|
||||
using Eigen::ei_log; \
|
||||
using Eigen::ei_sin; \
|
||||
using Eigen::ei_cos;
|
||||
|
||||
#endif // EIGEN2SUPPORT_H
|
||||
|
4
Eigen/LU
4
Eigen/LU
@ -30,6 +30,10 @@ namespace Eigen {
|
||||
#include "src/LU/arch/Inverse_SSE.h"
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
#include "src/Eigen2Support/LU.h"
|
||||
#endif
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||
|
6
Eigen/QR
6
Eigen/QR
@ -29,13 +29,17 @@ namespace Eigen {
|
||||
#include "src/QR/FullPivHouseholderQR.h"
|
||||
#include "src/QR/ColPivHouseholderQR.h"
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
#include "src/Eigen2Support/QR.h"
|
||||
#endif
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||
|
||||
// FIXME for compatibility we include Eigenvalues here:
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
#include "Eigenvalues"
|
||||
#endif
|
||||
|
||||
#endif // EIGEN_QR_MODULE_H
|
||||
/* vim: set filetype=cpp et sw=2 ts=2 ai: */
|
||||
|
@ -26,6 +26,10 @@ namespace Eigen {
|
||||
#include "src/SVD/JacobiSVD.h"
|
||||
#include "src/SVD/UpperBidiagonalization.h"
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
#include "src/Eigen2Support/SVD.h"
|
||||
#endif
|
||||
|
||||
} // namespace Eigen
|
||||
|
||||
#include "src/Core/util/EnableMSVCWarnings.h"
|
||||
|
@ -415,17 +415,14 @@ template<typename Derived> class DenseBase
|
||||
typename internal::traits<Derived>::Scalar minCoeff() const;
|
||||
typename internal::traits<Derived>::Scalar maxCoeff() const;
|
||||
|
||||
typename internal::traits<Derived>::Scalar minCoeff(Index* row, Index* col) const;
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(Index* row, Index* col) const;
|
||||
typename internal::traits<Derived>::Scalar minCoeff(Index* index) const;
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(Index* index) const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
typename internal::traits<Derived>::Scalar minCoeff(int* row, int* col) const;
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(int* row, int* col) const;
|
||||
typename internal::traits<Derived>::Scalar minCoeff(int* index) const;
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(int* index) const;
|
||||
#endif
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar minCoeff(IndexType* row, IndexType* col) const;
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(IndexType* row, IndexType* col) const;
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar minCoeff(IndexType* index) const;
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar maxCoeff(IndexType* index) const;
|
||||
|
||||
template<typename BinaryOp>
|
||||
typename internal::result_of<BinaryOp(typename internal::traits<Derived>::Scalar)>::type
|
||||
|
@ -243,8 +243,8 @@ template<typename Derived> class MatrixBase
|
||||
typename MatrixBase::template ConstDiagonalIndexReturnType<Dynamic>::Type diagonal(Index index) const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<unsigned int Mode> TriangularView<Derived, Mode> part();
|
||||
template<unsigned int Mode> const TriangularView<Derived, Mode> part() const;
|
||||
template<unsigned int Mode> typename internal::eigen2_part_return_type<Derived, Mode>::type part();
|
||||
template<unsigned int Mode> const typename internal::eigen2_part_return_type<Derived, Mode>::type part() const;
|
||||
|
||||
// huuuge hack. make Eigen2's matrix.part<Diagonal>() work in eigen3. Problem: Diagonal is now a class template instead
|
||||
// of an integer constant. Solution: overload the part() method template wrt template parameters list.
|
||||
@ -334,7 +334,26 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
const FullPivLU<PlainObject> fullPivLu() const;
|
||||
const PartialPivLU<PlainObject> partialPivLu() const;
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
|
||||
const LU<PlainObject> lu() const;
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
const LU<PlainObject> eigen2_lu() const;
|
||||
#endif
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
|
||||
const PartialPivLU<PlainObject> lu() const;
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<typename ResultType>
|
||||
void computeInverse(MatrixBase<ResultType> *result) const {
|
||||
*result = this->inverse();
|
||||
}
|
||||
#endif
|
||||
|
||||
const internal::inverse_impl<Derived> inverse() const;
|
||||
template<typename ResultType>
|
||||
void computeInverseAndDetWithCheck(
|
||||
@ -361,6 +380,10 @@ template<typename Derived> class MatrixBase
|
||||
const HouseholderQR<PlainObject> householderQr() const;
|
||||
const ColPivHouseholderQR<PlainObject> colPivHouseholderQr() const;
|
||||
const FullPivHouseholderQR<PlainObject> fullPivHouseholderQr() const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
const QR<PlainObject> qr() const;
|
||||
#endif
|
||||
|
||||
EigenvaluesReturnType eigenvalues() const;
|
||||
RealScalar operatorNorm() const;
|
||||
@ -369,6 +392,10 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
JacobiSVD<PlainObject> jacobiSvd(unsigned int computationOptions = 0) const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
SVD<PlainObject> svd() const;
|
||||
#endif
|
||||
|
||||
/////////// Geometry module ///////////
|
||||
|
||||
template<typename OtherDerived>
|
||||
|
@ -46,13 +46,14 @@ template<typename MatrixType, unsigned int UpLo>
|
||||
struct traits<SelfAdjointView<MatrixType, UpLo> > : traits<MatrixType>
|
||||
{
|
||||
typedef typename nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
|
||||
typedef MatrixType ExpressionType;
|
||||
typedef typename MatrixType::PlainObject DenseMatrixType;
|
||||
enum {
|
||||
Mode = UpLo | SelfAdjoint,
|
||||
Flags = _MatrixTypeNested::Flags & (HereditaryBits)
|
||||
Flags = MatrixTypeNestedCleaned::Flags & (HereditaryBits)
|
||||
& (~(PacketAccessBit | DirectAccessBit | LinearAccessBit)), // FIXME these flags should be preserved
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -68,6 +69,8 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView
|
||||
public:
|
||||
|
||||
typedef TriangularBase<SelfAdjointView> Base;
|
||||
typedef typename internal::traits<SelfAdjointView>::MatrixTypeNested MatrixTypeNested;
|
||||
typedef typename internal::traits<SelfAdjointView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
|
||||
|
||||
/** \brief The type of coefficients in this matrix */
|
||||
typedef typename internal::traits<SelfAdjointView>::Scalar Scalar;
|
||||
@ -106,10 +109,10 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView
|
||||
}
|
||||
|
||||
/** \internal */
|
||||
const MatrixType& _expression() const { return m_matrix; }
|
||||
const MatrixTypeNestedCleaned& _expression() const { return m_matrix; }
|
||||
|
||||
const MatrixType& nestedExpression() const { return m_matrix; }
|
||||
MatrixType& nestedExpression() { return const_cast<MatrixType&>(m_matrix); }
|
||||
const MatrixTypeNestedCleaned& nestedExpression() const { return m_matrix; }
|
||||
MatrixTypeNestedCleaned& nestedExpression() { return *const_cast<MatrixTypeNestedCleaned*>(&m_matrix); }
|
||||
|
||||
/** Efficient self-adjoint matrix times vector/matrix product */
|
||||
template<typename OtherDerived>
|
||||
@ -171,9 +174,32 @@ template<typename MatrixType, unsigned int UpLo> class SelfAdjointView
|
||||
|
||||
EigenvaluesReturnType eigenvalues() const;
|
||||
RealScalar operatorNorm() const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<typename OtherDerived>
|
||||
SelfAdjointView& operator=(const MatrixBase<OtherDerived>& other)
|
||||
{
|
||||
enum {
|
||||
OtherPart = UpLo == Upper ? StrictlyLower : StrictlyUpper
|
||||
};
|
||||
m_matrix.const_cast_derived().template triangularView<UpLo>() = other;
|
||||
m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.adjoint();
|
||||
return *this;
|
||||
}
|
||||
template<typename OtherMatrixType, unsigned int OtherMode>
|
||||
SelfAdjointView& operator=(const TriangularView<OtherMatrixType, OtherMode>& other)
|
||||
{
|
||||
enum {
|
||||
OtherPart = UpLo == Upper ? StrictlyLower : StrictlyUpper
|
||||
};
|
||||
m_matrix.const_cast_derived().template triangularView<UpLo>() = other.toDenseMatrix();
|
||||
m_matrix.const_cast_derived().template triangularView<OtherPart>() = other.toDenseMatrix().adjoint();
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
const typename MatrixType::Nested m_matrix;
|
||||
const MatrixTypeNested m_matrix;
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,6 +48,7 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived>
|
||||
typedef typename internal::traits<Derived>::Scalar Scalar;
|
||||
typedef typename internal::traits<Derived>::StorageKind StorageKind;
|
||||
typedef typename internal::traits<Derived>::Index Index;
|
||||
typedef typename internal::traits<Derived>::DenseMatrixType DenseMatrixType;
|
||||
|
||||
inline TriangularBase() { eigen_assert(!((Mode&UnitDiag) && (Mode&ZeroDiag))); }
|
||||
|
||||
@ -88,6 +89,13 @@ template<typename Derived> class TriangularBase : public EigenBase<Derived>
|
||||
template<typename DenseDerived>
|
||||
void evalToLazy(MatrixBase<DenseDerived> &other) const;
|
||||
|
||||
DenseMatrixType toDenseMatrix() const
|
||||
{
|
||||
DenseMatrixType res(rows(), cols());
|
||||
evalToLazy(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void check_coordinates(Index row, Index col) const
|
||||
@ -135,12 +143,14 @@ template<typename MatrixType, unsigned int _Mode>
|
||||
struct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType>
|
||||
{
|
||||
typedef typename nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename remove_reference<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
typedef typename remove_reference<MatrixTypeNested>::type MatrixTypeNestedNonRef;
|
||||
typedef typename remove_all<MatrixTypeNested>::type MatrixTypeNestedCleaned;
|
||||
typedef MatrixType ExpressionType;
|
||||
typedef typename MatrixType::PlainObject DenseMatrixType;
|
||||
enum {
|
||||
Mode = _Mode,
|
||||
Flags = (_MatrixTypeNested::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode,
|
||||
CoeffReadCost = _MatrixTypeNested::CoeffReadCost
|
||||
Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) | Mode,
|
||||
CoeffReadCost = MatrixTypeNestedCleaned::CoeffReadCost
|
||||
};
|
||||
};
|
||||
}
|
||||
@ -159,11 +169,13 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
typedef typename internal::traits<TriangularView>::Scalar Scalar;
|
||||
|
||||
typedef _MatrixType MatrixType;
|
||||
typedef typename MatrixType::PlainObject DenseMatrixType;
|
||||
typedef typename internal::traits<TriangularView>::DenseMatrixType DenseMatrixType;
|
||||
|
||||
protected:
|
||||
typedef typename MatrixType::Nested MatrixTypeNested;
|
||||
typedef typename internal::remove_all<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
typedef typename internal::traits<TriangularView>::MatrixTypeNested MatrixTypeNested;
|
||||
typedef typename internal::traits<TriangularView>::MatrixTypeNestedNonRef MatrixTypeNestedNonRef;
|
||||
typedef typename internal::traits<TriangularView>::MatrixTypeNestedCleaned MatrixTypeNestedCleaned;
|
||||
|
||||
typedef typename internal::remove_all<typename MatrixType::ConjugateReturnType>::type MatrixConjugateReturnType;
|
||||
|
||||
public:
|
||||
@ -226,8 +238,8 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
return m_matrix.const_cast_derived().coeffRef(row, col);
|
||||
}
|
||||
|
||||
const MatrixType& nestedExpression() const { return m_matrix; }
|
||||
MatrixType& nestedExpression() { return const_cast<MatrixType&>(m_matrix); }
|
||||
const MatrixTypeNestedCleaned& nestedExpression() const { return m_matrix; }
|
||||
MatrixTypeNestedCleaned& nestedExpression() { return *const_cast<MatrixTypeNestedCleaned*>(&m_matrix); }
|
||||
|
||||
/** Assigns a triangular matrix to a triangular part of a dense matrix */
|
||||
template<typename OtherDerived>
|
||||
@ -269,13 +281,6 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
inline const TriangularView<Transpose<MatrixType>,TransposeMode> transpose() const
|
||||
{ return m_matrix.transpose(); }
|
||||
|
||||
DenseMatrixType toDenseMatrix() const
|
||||
{
|
||||
DenseMatrixType res(rows(), cols());
|
||||
evalToLazy(res);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Efficient triangular matrix times vector/matrix product */
|
||||
template<typename OtherDerived>
|
||||
TriangularProduct<Mode,true,MatrixType,false,OtherDerived,OtherDerived::IsVectorAtCompileTime>
|
||||
@ -310,18 +315,18 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
const typename eigen2_product_return_type<OtherMatrixType>::type
|
||||
operator*(const TriangularView<OtherMatrixType, Mode>& rhs) const
|
||||
{
|
||||
return toDenseMatrix() * rhs.toDenseMatrix();
|
||||
return this->toDenseMatrix() * rhs.toDenseMatrix();
|
||||
}
|
||||
|
||||
template<typename OtherMatrixType>
|
||||
bool isApprox(const TriangularView<OtherMatrixType, Mode>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
|
||||
{
|
||||
return toDenseMatrix().isApprox(other.toDenseMatrix(), precision);
|
||||
return this->toDenseMatrix().isApprox(other.toDenseMatrix(), precision);
|
||||
}
|
||||
template<typename OtherDerived>
|
||||
bool isApprox(const MatrixBase<OtherDerived>& other, typename NumTraits<Scalar>::Real precision = NumTraits<Scalar>::dummy_precision()) const
|
||||
{
|
||||
return toDenseMatrix().isApprox(other, precision);
|
||||
return this->toDenseMatrix().isApprox(other, precision);
|
||||
}
|
||||
|
||||
#endif // EIGEN2_SUPPORT
|
||||
@ -342,15 +347,15 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
|
||||
void solveInPlace(const MatrixBase<OtherDerived>& other) const
|
||||
{ return solveInPlace<OnTheLeft>(other); }
|
||||
|
||||
const SelfAdjointView<_MatrixTypeNested,Mode> selfadjointView() const
|
||||
const SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((Mode&UnitDiag)==0,PROGRAMMING_ERROR);
|
||||
return SelfAdjointView<_MatrixTypeNested,Mode>(m_matrix);
|
||||
return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
|
||||
}
|
||||
SelfAdjointView<_MatrixTypeNested,Mode> selfadjointView()
|
||||
SelfAdjointView<MatrixTypeNestedNonRef,Mode> selfadjointView()
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((Mode&UnitDiag)==0,PROGRAMMING_ERROR);
|
||||
return SelfAdjointView<_MatrixTypeNested,Mode>(m_matrix);
|
||||
return SelfAdjointView<MatrixTypeNestedNonRef,Mode>(m_matrix);
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
@ -692,7 +697,7 @@ void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const
|
||||
eigen_assert(this->rows() == other.rows() && this->cols() == other.cols());
|
||||
|
||||
internal::triangular_assignment_selector
|
||||
<DenseDerived, typename internal::traits<Derived>::ExpressionType, Derived::Mode,
|
||||
<DenseDerived, typename internal::traits<Derived>::MatrixTypeNestedCleaned, Derived::Mode,
|
||||
unroll ? int(DenseDerived::SizeAtCompileTime) : Dynamic,
|
||||
true // clear the opposite triangular part
|
||||
>::run(other.derived(), derived().nestedExpression());
|
||||
@ -707,10 +712,27 @@ void TriangularBase<Derived>::evalToLazy(MatrixBase<DenseDerived> &other) const
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
|
||||
// implementation of part<>(), including the SelfAdjoint case.
|
||||
|
||||
namespace internal {
|
||||
template<typename MatrixType, unsigned int Mode>
|
||||
struct eigen2_part_return_type
|
||||
{
|
||||
typedef TriangularView<MatrixType, Mode> type;
|
||||
};
|
||||
|
||||
template<typename MatrixType>
|
||||
struct eigen2_part_return_type<MatrixType, SelfAdjoint>
|
||||
{
|
||||
typedef SelfAdjointView<MatrixType, Upper> type;
|
||||
};
|
||||
}
|
||||
|
||||
/** \deprecated use MatrixBase::triangularView() */
|
||||
template<typename Derived>
|
||||
template<unsigned int Mode>
|
||||
const TriangularView<Derived, Mode> MatrixBase<Derived>::part() const
|
||||
const typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part() const
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
@ -718,7 +740,7 @@ const TriangularView<Derived, Mode> MatrixBase<Derived>::part() const
|
||||
/** \deprecated use MatrixBase::triangularView() */
|
||||
template<typename Derived>
|
||||
template<unsigned int Mode>
|
||||
TriangularView<Derived, Mode> MatrixBase<Derived>::part()
|
||||
typename internal::eigen2_part_return_type<Derived, Mode>::type MatrixBase<Derived>::part()
|
||||
{
|
||||
return derived();
|
||||
}
|
||||
|
@ -183,8 +183,9 @@ struct functor_traits<max_coeff_visitor<Scalar> > {
|
||||
* \sa DenseBase::minCoeff(Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::minCoeff()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::minCoeff(Index* row, Index* col) const
|
||||
DenseBase<Derived>::minCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
internal::min_coeff_visitor<Derived> minVisitor;
|
||||
this->visit(minVisitor);
|
||||
@ -196,11 +197,12 @@ DenseBase<Derived>::minCoeff(Index* row, Index* col) const
|
||||
/** \returns the minimum of all coefficients of *this
|
||||
* and puts in *index its location.
|
||||
*
|
||||
* \sa DenseBase::minCoeff(Index*,Index*), DenseBase::maxCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::minCoeff()
|
||||
* \sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::visitor(), DenseBase::minCoeff()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::minCoeff(Index* index) const
|
||||
DenseBase<Derived>::minCoeff(IndexType* index) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
internal::min_coeff_visitor<Derived> minVisitor;
|
||||
@ -212,11 +214,12 @@ DenseBase<Derived>::minCoeff(Index* index) const
|
||||
/** \returns the maximum of all coefficients of *this
|
||||
* and puts in *row and *col its location.
|
||||
*
|
||||
* \sa DenseBase::minCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::maxCoeff()
|
||||
* \sa DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visitor(), DenseBase::maxCoeff()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::maxCoeff(Index* row, Index* col) const
|
||||
DenseBase<Derived>::maxCoeff(IndexType* row, IndexType* col) const
|
||||
{
|
||||
internal::max_coeff_visitor<Derived> maxVisitor;
|
||||
this->visit(maxVisitor);
|
||||
@ -228,11 +231,12 @@ DenseBase<Derived>::maxCoeff(Index* row, Index* col) const
|
||||
/** \returns the maximum of all coefficients of *this
|
||||
* and puts in *index its location.
|
||||
*
|
||||
* \sa DenseBase::maxCoeff(Index*,Index*), DenseBase::minCoeff(Index*,Index*), DenseBase::visitor(), DenseBase::maxCoeff()
|
||||
* \sa DenseBase::maxCoeff(IndexType*,IndexType*), DenseBase::minCoeff(IndexType*,IndexType*), DenseBase::visitor(), DenseBase::maxCoeff()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename IndexType>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::maxCoeff(Index* index) const
|
||||
DenseBase<Derived>::maxCoeff(IndexType* index) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
internal::max_coeff_visitor<Derived> maxVisitor;
|
||||
@ -241,51 +245,4 @@ DenseBase<Derived>::maxCoeff(Index* index) const
|
||||
return maxVisitor.res;
|
||||
}
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
|
||||
template<typename Derived>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::minCoeff(int* row, int* col) const
|
||||
{
|
||||
Index r, c;
|
||||
Scalar result = this->minCoeff(&r, &c);
|
||||
*row = int(r);
|
||||
*col = int(c);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::minCoeff(int* index) const
|
||||
{
|
||||
Index i;
|
||||
Scalar result = this->minCoeff(&i);
|
||||
*index = int(i);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::maxCoeff(int* row, int* col) const
|
||||
{
|
||||
Index r, c;
|
||||
Scalar result = this->maxCoeff(&r, &c);
|
||||
*row = int(r);
|
||||
*col = int(c);
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename Derived>
|
||||
typename internal::traits<Derived>::Scalar
|
||||
DenseBase<Derived>::maxCoeff(int* index) const
|
||||
{
|
||||
Index i;
|
||||
Scalar result = this->maxCoeff(&i);
|
||||
*index = int(i);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // EIGEN2_SUPPORT
|
||||
|
||||
|
||||
#endif // EIGEN_VISITOR_H
|
||||
|
@ -270,6 +270,12 @@ struct stem_function
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<typename ExpressionType> class Cwise;
|
||||
template<typename MatrixType> class Minor;
|
||||
template<typename MatrixType> class LU;
|
||||
template<typename MatrixType> class QR;
|
||||
template<typename MatrixType> class SVD;
|
||||
namespace internal {
|
||||
template<typename MatrixType, unsigned int Mode> struct eigen2_part_return_type;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // EIGEN_FORWARDDECLARATIONS_H
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
~Hyperplane() {}
|
||||
|
||||
/** \returns the dimension in which the plane holds */
|
||||
inline int dim() const { return AmbientDimAtCompileTime==Dynamic ? m_coeffs.size()-1 : AmbientDimAtCompileTime; }
|
||||
inline int dim() const { return int(AmbientDimAtCompileTime)==Dynamic ? m_coeffs.size()-1 : int(AmbientDimAtCompileTime); }
|
||||
|
||||
/** normalizes \c *this */
|
||||
void normalize(void)
|
||||
@ -147,7 +147,7 @@ public:
|
||||
/** \returns a constant reference to the unit normal vector of the plane, which corresponds
|
||||
* to the linear part of the implicit equation.
|
||||
*/
|
||||
inline const NormalReturnType normal() const { return NormalReturnType(m_coeffs,0,0,dim(),1); }
|
||||
inline const NormalReturnType normal() const { return NormalReturnType(*const_cast<Coefficients*>(&m_coeffs),0,0,dim(),1); }
|
||||
|
||||
/** \returns a non-constant reference to the unit normal vector of the plane, which corresponds
|
||||
* to the linear part of the implicit equation.
|
||||
|
133
Eigen/src/Eigen2Support/LU.h
Normal file
133
Eigen/src/Eigen2Support/LU.h
Normal file
@ -0,0 +1,133 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2011 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 EIGEN2_LU_H
|
||||
#define EIGEN2_LU_H
|
||||
|
||||
template<typename MatrixType>
|
||||
class LU : public FullPivLU<MatrixType>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
|
||||
typedef Matrix<int, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> IntRowVectorType;
|
||||
typedef Matrix<int, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> IntColVectorType;
|
||||
typedef Matrix<Scalar, 1, MatrixType::ColsAtCompileTime, MatrixType::Options, 1, MatrixType::MaxColsAtCompileTime> RowVectorType;
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1, MatrixType::Options, MatrixType::MaxRowsAtCompileTime, 1> ColVectorType;
|
||||
|
||||
typedef Matrix<typename MatrixType::Scalar,
|
||||
MatrixType::ColsAtCompileTime, // the number of rows in the "kernel matrix" is the number of cols of the original matrix
|
||||
// so that the product "matrix * kernel = zero" makes sense
|
||||
Dynamic, // we don't know at compile-time the dimension of the kernel
|
||||
MatrixType::Options,
|
||||
MatrixType::MaxColsAtCompileTime, // see explanation for 2nd template parameter
|
||||
MatrixType::MaxColsAtCompileTime // the kernel is a subspace of the domain space, whose dimension is the number
|
||||
// of columns of the original matrix
|
||||
> KernelResultType;
|
||||
|
||||
typedef Matrix<typename MatrixType::Scalar,
|
||||
MatrixType::RowsAtCompileTime, // the image is a subspace of the destination space, whose dimension is the number
|
||||
// of rows of the original matrix
|
||||
Dynamic, // we don't know at compile time the dimension of the image (the rank)
|
||||
MatrixType::Options,
|
||||
MatrixType::MaxRowsAtCompileTime, // the image matrix will consist of columns from the original matrix,
|
||||
MatrixType::MaxColsAtCompileTime // so it has the same number of rows and at most as many columns.
|
||||
> ImageResultType;
|
||||
|
||||
typedef FullPivLU<MatrixType> Base;
|
||||
LU() : Base() {}
|
||||
|
||||
template<typename T>
|
||||
explicit LU(const T& t) : Base(t), m_originalMatrix(t) {}
|
||||
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
|
||||
{
|
||||
*result = static_cast<const Base*>(this)->solve(b);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename ResultType>
|
||||
inline void computeInverse(ResultType *result) const
|
||||
{
|
||||
solve(MatrixType::Identity(this->rows(), this->cols()), result);
|
||||
}
|
||||
|
||||
template<typename KernelMatrixType>
|
||||
void computeKernel(KernelMatrixType *result) const
|
||||
{
|
||||
*result = static_cast<const Base*>(this)->kernel();
|
||||
}
|
||||
|
||||
template<typename ImageMatrixType>
|
||||
void computeImage(ImageMatrixType *result) const
|
||||
{
|
||||
*result = static_cast<const Base*>(this)->image(m_originalMatrix);
|
||||
}
|
||||
|
||||
const ImageResultType image() const
|
||||
{
|
||||
return static_cast<const Base*>(this)->image(m_originalMatrix);
|
||||
}
|
||||
|
||||
const MatrixType& m_originalMatrix;
|
||||
};
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE < STAGE20_RESOLVE_API_CONFLICTS
|
||||
/** \lu_module
|
||||
*
|
||||
* Synonym of partialPivLu().
|
||||
*
|
||||
* \return the partial-pivoting LU decomposition of \c *this.
|
||||
*
|
||||
* \sa class PartialPivLU
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline const LU<typename MatrixBase<Derived>::PlainObject>
|
||||
MatrixBase<Derived>::lu() const
|
||||
{
|
||||
return LU<PlainObject>(eval());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
/** \lu_module
|
||||
*
|
||||
* Synonym of partialPivLu().
|
||||
*
|
||||
* \return the partial-pivoting LU decomposition of \c *this.
|
||||
*
|
||||
* \sa class PartialPivLU
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline const LU<typename MatrixBase<Derived>::PlainObject>
|
||||
MatrixBase<Derived>::eigen2_lu() const
|
||||
{
|
||||
return LU<PlainObject>(eval());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif // EIGEN2_LU_H
|
79
Eigen/src/Eigen2Support/QR.h
Normal file
79
Eigen/src/Eigen2Support/QR.h
Normal file
@ -0,0 +1,79 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra.
|
||||
//
|
||||
// Copyright (C) 2008 Gael Guennebaud <g.gael@free.fr>
|
||||
// Copyright (C) 2011 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 EIGEN2_QR_H
|
||||
#define EIGEN2_QR_H
|
||||
|
||||
template<typename MatrixType>
|
||||
class QR : public HouseholderQR<MatrixType>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef HouseholderQR<MatrixType> Base;
|
||||
typedef Block<const MatrixType, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixRBlockType;
|
||||
|
||||
QR() : Base() {}
|
||||
|
||||
template<typename T>
|
||||
explicit QR(const T& t) : Base(t) {}
|
||||
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
bool solve(const MatrixBase<OtherDerived>& b, ResultType *result) const
|
||||
{
|
||||
*result = static_cast<const Base*>(this)->solve(b);
|
||||
return true;
|
||||
}
|
||||
|
||||
MatrixType matrixQ(void) const {
|
||||
MatrixType ret = MatrixType::Identity(this->rows(), this->cols());
|
||||
ret = this->householderQ() * ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool isFullRank() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
const TriangularView<MatrixRBlockType, UpperTriangular>
|
||||
matrixR(void) const
|
||||
{
|
||||
int cols = this->cols();
|
||||
return MatrixRBlockType(this->matrixQR(), 0, 0, cols, cols).template triangularView<UpperTriangular>();
|
||||
}
|
||||
};
|
||||
|
||||
/** \return the QR decomposition of \c *this.
|
||||
*
|
||||
* \sa class QR
|
||||
*/
|
||||
template<typename Derived>
|
||||
const QR<typename MatrixBase<Derived>::PlainObject>
|
||||
MatrixBase<Derived>::qr() const
|
||||
{
|
||||
return QR<PlainObject>(eval());
|
||||
}
|
||||
|
||||
|
||||
#endif // EIGEN2_QR_H
|
649
Eigen/src/Eigen2Support/SVD.h
Normal file
649
Eigen/src/Eigen2Support/SVD.h
Normal file
@ -0,0 +1,649 @@
|
||||
// This file is part of Eigen, a lightweight C++ template library
|
||||
// for linear algebra. Eigen itself is part of the KDE project.
|
||||
//
|
||||
// Copyright (C) 2008 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_SVD_H
|
||||
#define EIGEN_SVD_H
|
||||
|
||||
/** \ingroup SVD_Module
|
||||
* \nonstableyet
|
||||
*
|
||||
* \class SVD
|
||||
*
|
||||
* \brief Standard SVD decomposition of a matrix and associated features
|
||||
*
|
||||
* \param MatrixType the type of the matrix of which we are computing the SVD decomposition
|
||||
*
|
||||
* This class performs a standard SVD decomposition of a real matrix A of size \c M x \c N
|
||||
* with \c M \>= \c N.
|
||||
*
|
||||
*
|
||||
* \sa MatrixBase::SVD()
|
||||
*/
|
||||
template<typename MatrixType> class SVD
|
||||
{
|
||||
private:
|
||||
typedef typename MatrixType::Scalar Scalar;
|
||||
typedef typename NumTraits<typename MatrixType::Scalar>::Real RealScalar;
|
||||
|
||||
enum {
|
||||
PacketSize = internal::packet_traits<Scalar>::size,
|
||||
AlignmentMask = int(PacketSize)-1,
|
||||
MinSize = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, MatrixType::ColsAtCompileTime)
|
||||
};
|
||||
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> ColVector;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, 1> RowVector;
|
||||
|
||||
typedef Matrix<Scalar, MatrixType::RowsAtCompileTime, MinSize> MatrixUType;
|
||||
typedef Matrix<Scalar, MatrixType::ColsAtCompileTime, MatrixType::ColsAtCompileTime> MatrixVType;
|
||||
typedef Matrix<Scalar, MinSize, 1> SingularValuesType;
|
||||
|
||||
public:
|
||||
|
||||
SVD() {} // a user who relied on compiler-generated default compiler reported problems with MSVC in 2.0.7
|
||||
|
||||
SVD(const MatrixType& matrix)
|
||||
: m_matU(matrix.rows(), std::min(matrix.rows(), matrix.cols())),
|
||||
m_matV(matrix.cols(),matrix.cols()),
|
||||
m_sigma(std::min(matrix.rows(),matrix.cols()))
|
||||
{
|
||||
compute(matrix);
|
||||
}
|
||||
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
bool solve(const MatrixBase<OtherDerived> &b, ResultType* result) const;
|
||||
|
||||
const MatrixUType& matrixU() const { return m_matU; }
|
||||
const SingularValuesType& singularValues() const { return m_sigma; }
|
||||
const MatrixVType& matrixV() const { return m_matV; }
|
||||
|
||||
void compute(const MatrixType& matrix);
|
||||
SVD& sort();
|
||||
|
||||
template<typename UnitaryType, typename PositiveType>
|
||||
void computeUnitaryPositive(UnitaryType *unitary, PositiveType *positive) const;
|
||||
template<typename PositiveType, typename UnitaryType>
|
||||
void computePositiveUnitary(PositiveType *positive, UnitaryType *unitary) const;
|
||||
template<typename RotationType, typename ScalingType>
|
||||
void computeRotationScaling(RotationType *unitary, ScalingType *positive) const;
|
||||
template<typename ScalingType, typename RotationType>
|
||||
void computeScalingRotation(ScalingType *positive, RotationType *unitary) const;
|
||||
|
||||
protected:
|
||||
/** \internal */
|
||||
MatrixUType m_matU;
|
||||
/** \internal */
|
||||
MatrixVType m_matV;
|
||||
/** \internal */
|
||||
SingularValuesType m_sigma;
|
||||
};
|
||||
|
||||
/** Computes / recomputes the SVD decomposition A = U S V^* of \a matrix
|
||||
*
|
||||
* \note this code has been adapted from JAMA (public domain)
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
void SVD<MatrixType>::compute(const MatrixType& matrix)
|
||||
{
|
||||
const int m = matrix.rows();
|
||||
const int n = matrix.cols();
|
||||
const int nu = std::min(m,n);
|
||||
ei_assert(m>=n && "In Eigen 2.0, SVD only works for MxN matrices with M>=N. Sorry!");
|
||||
ei_assert(m>1 && "In Eigen 2.0, SVD doesn't work on 1x1 matrices");
|
||||
|
||||
m_matU.resize(m, nu);
|
||||
m_matU.setZero();
|
||||
m_sigma.resize(std::min(m,n));
|
||||
m_matV.resize(n,n);
|
||||
|
||||
RowVector e(n);
|
||||
ColVector work(m);
|
||||
MatrixType matA(matrix);
|
||||
const bool wantu = true;
|
||||
const bool wantv = true;
|
||||
int i=0, j=0, k=0;
|
||||
|
||||
// Reduce A to bidiagonal form, storing the diagonal elements
|
||||
// in s and the super-diagonal elements in e.
|
||||
int nct = std::min(m-1,n);
|
||||
int nrt = std::max(0,std::min(n-2,m));
|
||||
for (k = 0; k < std::max(nct,nrt); ++k)
|
||||
{
|
||||
if (k < nct)
|
||||
{
|
||||
// Compute the transformation for the k-th column and
|
||||
// place the k-th diagonal in m_sigma[k].
|
||||
m_sigma[k] = matA.col(k).end(m-k).norm();
|
||||
if (m_sigma[k] != 0.0) // FIXME
|
||||
{
|
||||
if (matA(k,k) < 0.0)
|
||||
m_sigma[k] = -m_sigma[k];
|
||||
matA.col(k).end(m-k) /= m_sigma[k];
|
||||
matA(k,k) += 1.0;
|
||||
}
|
||||
m_sigma[k] = -m_sigma[k];
|
||||
}
|
||||
|
||||
for (j = k+1; j < n; ++j)
|
||||
{
|
||||
if ((k < nct) && (m_sigma[k] != 0.0))
|
||||
{
|
||||
// Apply the transformation.
|
||||
Scalar t = matA.col(k).end(m-k).dot(matA.col(j).end(m-k)); // FIXME dot product or cwise prod + .sum() ??
|
||||
t = -t/matA(k,k);
|
||||
matA.col(j).end(m-k) += t * matA.col(k).end(m-k);
|
||||
}
|
||||
|
||||
// Place the k-th row of A into e for the
|
||||
// subsequent calculation of the row transformation.
|
||||
e[j] = matA(k,j);
|
||||
}
|
||||
|
||||
// Place the transformation in U for subsequent back multiplication.
|
||||
if (wantu & (k < nct))
|
||||
m_matU.col(k).end(m-k) = matA.col(k).end(m-k);
|
||||
|
||||
if (k < nrt)
|
||||
{
|
||||
// Compute the k-th row transformation and place the
|
||||
// k-th super-diagonal in e[k].
|
||||
e[k] = e.end(n-k-1).norm();
|
||||
if (e[k] != 0.0)
|
||||
{
|
||||
if (e[k+1] < 0.0)
|
||||
e[k] = -e[k];
|
||||
e.end(n-k-1) /= e[k];
|
||||
e[k+1] += 1.0;
|
||||
}
|
||||
e[k] = -e[k];
|
||||
if ((k+1 < m) & (e[k] != 0.0))
|
||||
{
|
||||
// Apply the transformation.
|
||||
work.end(m-k-1) = matA.corner(BottomRight,m-k-1,n-k-1) * e.end(n-k-1);
|
||||
for (j = k+1; j < n; ++j)
|
||||
matA.col(j).end(m-k-1) += (-e[j]/e[k+1]) * work.end(m-k-1);
|
||||
}
|
||||
|
||||
// Place the transformation in V for subsequent back multiplication.
|
||||
if (wantv)
|
||||
m_matV.col(k).end(n-k-1) = e.end(n-k-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set up the final bidiagonal matrix or order p.
|
||||
int p = std::min(n,m+1);
|
||||
if (nct < n)
|
||||
m_sigma[nct] = matA(nct,nct);
|
||||
if (m < p)
|
||||
m_sigma[p-1] = 0.0;
|
||||
if (nrt+1 < p)
|
||||
e[nrt] = matA(nrt,p-1);
|
||||
e[p-1] = 0.0;
|
||||
|
||||
// If required, generate U.
|
||||
if (wantu)
|
||||
{
|
||||
for (j = nct; j < nu; ++j)
|
||||
{
|
||||
m_matU.col(j).setZero();
|
||||
m_matU(j,j) = 1.0;
|
||||
}
|
||||
for (k = nct-1; k >= 0; k--)
|
||||
{
|
||||
if (m_sigma[k] != 0.0)
|
||||
{
|
||||
for (j = k+1; j < nu; ++j)
|
||||
{
|
||||
Scalar t = m_matU.col(k).end(m-k).dot(m_matU.col(j).end(m-k)); // FIXME is it really a dot product we want ?
|
||||
t = -t/m_matU(k,k);
|
||||
m_matU.col(j).end(m-k) += t * m_matU.col(k).end(m-k);
|
||||
}
|
||||
m_matU.col(k).end(m-k) = - m_matU.col(k).end(m-k);
|
||||
m_matU(k,k) = Scalar(1) + m_matU(k,k);
|
||||
if (k-1>0)
|
||||
m_matU.col(k).start(k-1).setZero();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_matU.col(k).setZero();
|
||||
m_matU(k,k) = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If required, generate V.
|
||||
if (wantv)
|
||||
{
|
||||
for (k = n-1; k >= 0; k--)
|
||||
{
|
||||
if ((k < nrt) & (e[k] != 0.0))
|
||||
{
|
||||
for (j = k+1; j < nu; ++j)
|
||||
{
|
||||
Scalar t = m_matV.col(k).end(n-k-1).dot(m_matV.col(j).end(n-k-1)); // FIXME is it really a dot product we want ?
|
||||
t = -t/m_matV(k+1,k);
|
||||
m_matV.col(j).end(n-k-1) += t * m_matV.col(k).end(n-k-1);
|
||||
}
|
||||
}
|
||||
m_matV.col(k).setZero();
|
||||
m_matV(k,k) = 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// Main iteration loop for the singular values.
|
||||
int pp = p-1;
|
||||
int iter = 0;
|
||||
Scalar eps = ei_pow(Scalar(2),ei_is_same_type<Scalar,float>::ret ? Scalar(-23) : Scalar(-52));
|
||||
while (p > 0)
|
||||
{
|
||||
int k=0;
|
||||
int kase=0;
|
||||
|
||||
// Here is where a test for too many iterations would go.
|
||||
|
||||
// This section of the program inspects for
|
||||
// negligible elements in the s and e arrays. On
|
||||
// completion the variables kase and k are set as follows.
|
||||
|
||||
// kase = 1 if s(p) and e[k-1] are negligible and k<p
|
||||
// kase = 2 if s(k) is negligible and k<p
|
||||
// kase = 3 if e[k-1] is negligible, k<p, and
|
||||
// s(k), ..., s(p) are not negligible (qr step).
|
||||
// kase = 4 if e(p-1) is negligible (convergence).
|
||||
|
||||
for (k = p-2; k >= -1; --k)
|
||||
{
|
||||
if (k == -1)
|
||||
break;
|
||||
if (ei_abs(e[k]) <= eps*(ei_abs(m_sigma[k]) + ei_abs(m_sigma[k+1])))
|
||||
{
|
||||
e[k] = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (k == p-2)
|
||||
{
|
||||
kase = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
int ks;
|
||||
for (ks = p-1; ks >= k; --ks)
|
||||
{
|
||||
if (ks == k)
|
||||
break;
|
||||
Scalar t = (ks != p ? ei_abs(e[ks]) : Scalar(0)) + (ks != k+1 ? ei_abs(e[ks-1]) : Scalar(0));
|
||||
if (ei_abs(m_sigma[ks]) <= eps*t)
|
||||
{
|
||||
m_sigma[ks] = 0.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ks == k)
|
||||
{
|
||||
kase = 3;
|
||||
}
|
||||
else if (ks == p-1)
|
||||
{
|
||||
kase = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
kase = 2;
|
||||
k = ks;
|
||||
}
|
||||
}
|
||||
++k;
|
||||
|
||||
// Perform the task indicated by kase.
|
||||
switch (kase)
|
||||
{
|
||||
|
||||
// Deflate negligible s(p).
|
||||
case 1:
|
||||
{
|
||||
Scalar f(e[p-2]);
|
||||
e[p-2] = 0.0;
|
||||
for (j = p-2; j >= k; --j)
|
||||
{
|
||||
Scalar t(internal::hypot(m_sigma[j],f));
|
||||
Scalar cs(m_sigma[j]/t);
|
||||
Scalar sn(f/t);
|
||||
m_sigma[j] = t;
|
||||
if (j != k)
|
||||
{
|
||||
f = -sn*e[j-1];
|
||||
e[j-1] = cs*e[j-1];
|
||||
}
|
||||
if (wantv)
|
||||
{
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
t = cs*m_matV(i,j) + sn*m_matV(i,p-1);
|
||||
m_matV(i,p-1) = -sn*m_matV(i,j) + cs*m_matV(i,p-1);
|
||||
m_matV(i,j) = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Split at negligible s(k).
|
||||
case 2:
|
||||
{
|
||||
Scalar f(e[k-1]);
|
||||
e[k-1] = 0.0;
|
||||
for (j = k; j < p; ++j)
|
||||
{
|
||||
Scalar t(internal::hypot(m_sigma[j],f));
|
||||
Scalar cs( m_sigma[j]/t);
|
||||
Scalar sn(f/t);
|
||||
m_sigma[j] = t;
|
||||
f = -sn*e[j];
|
||||
e[j] = cs*e[j];
|
||||
if (wantu)
|
||||
{
|
||||
for (i = 0; i < m; ++i)
|
||||
{
|
||||
t = cs*m_matU(i,j) + sn*m_matU(i,k-1);
|
||||
m_matU(i,k-1) = -sn*m_matU(i,j) + cs*m_matU(i,k-1);
|
||||
m_matU(i,j) = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
// Perform one qr step.
|
||||
case 3:
|
||||
{
|
||||
// Calculate the shift.
|
||||
Scalar scale = std::max(std::max(std::max(std::max(
|
||||
ei_abs(m_sigma[p-1]),ei_abs(m_sigma[p-2])),ei_abs(e[p-2])),
|
||||
ei_abs(m_sigma[k])),ei_abs(e[k]));
|
||||
Scalar sp = m_sigma[p-1]/scale;
|
||||
Scalar spm1 = m_sigma[p-2]/scale;
|
||||
Scalar epm1 = e[p-2]/scale;
|
||||
Scalar sk = m_sigma[k]/scale;
|
||||
Scalar ek = e[k]/scale;
|
||||
Scalar b = ((spm1 + sp)*(spm1 - sp) + epm1*epm1)/Scalar(2);
|
||||
Scalar c = (sp*epm1)*(sp*epm1);
|
||||
Scalar shift = 0.0;
|
||||
if ((b != 0.0) || (c != 0.0))
|
||||
{
|
||||
shift = ei_sqrt(b*b + c);
|
||||
if (b < 0.0)
|
||||
shift = -shift;
|
||||
shift = c/(b + shift);
|
||||
}
|
||||
Scalar f = (sk + sp)*(sk - sp) + shift;
|
||||
Scalar g = sk*ek;
|
||||
|
||||
// Chase zeros.
|
||||
|
||||
for (j = k; j < p-1; ++j)
|
||||
{
|
||||
Scalar t = internal::hypot(f,g);
|
||||
Scalar cs = f/t;
|
||||
Scalar sn = g/t;
|
||||
if (j != k)
|
||||
e[j-1] = t;
|
||||
f = cs*m_sigma[j] + sn*e[j];
|
||||
e[j] = cs*e[j] - sn*m_sigma[j];
|
||||
g = sn*m_sigma[j+1];
|
||||
m_sigma[j+1] = cs*m_sigma[j+1];
|
||||
if (wantv)
|
||||
{
|
||||
for (i = 0; i < n; ++i)
|
||||
{
|
||||
t = cs*m_matV(i,j) + sn*m_matV(i,j+1);
|
||||
m_matV(i,j+1) = -sn*m_matV(i,j) + cs*m_matV(i,j+1);
|
||||
m_matV(i,j) = t;
|
||||
}
|
||||
}
|
||||
t = internal::hypot(f,g);
|
||||
cs = f/t;
|
||||
sn = g/t;
|
||||
m_sigma[j] = t;
|
||||
f = cs*e[j] + sn*m_sigma[j+1];
|
||||
m_sigma[j+1] = -sn*e[j] + cs*m_sigma[j+1];
|
||||
g = sn*e[j+1];
|
||||
e[j+1] = cs*e[j+1];
|
||||
if (wantu && (j < m-1))
|
||||
{
|
||||
for (i = 0; i < m; ++i)
|
||||
{
|
||||
t = cs*m_matU(i,j) + sn*m_matU(i,j+1);
|
||||
m_matU(i,j+1) = -sn*m_matU(i,j) + cs*m_matU(i,j+1);
|
||||
m_matU(i,j) = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
e[p-2] = f;
|
||||
iter = iter + 1;
|
||||
}
|
||||
break;
|
||||
|
||||
// Convergence.
|
||||
case 4:
|
||||
{
|
||||
// Make the singular values positive.
|
||||
if (m_sigma[k] <= 0.0)
|
||||
{
|
||||
m_sigma[k] = m_sigma[k] < Scalar(0) ? -m_sigma[k] : Scalar(0);
|
||||
if (wantv)
|
||||
m_matV.col(k).start(pp+1) = -m_matV.col(k).start(pp+1);
|
||||
}
|
||||
|
||||
// Order the singular values.
|
||||
while (k < pp)
|
||||
{
|
||||
if (m_sigma[k] >= m_sigma[k+1])
|
||||
break;
|
||||
Scalar t = m_sigma[k];
|
||||
m_sigma[k] = m_sigma[k+1];
|
||||
m_sigma[k+1] = t;
|
||||
if (wantv && (k < n-1))
|
||||
m_matV.col(k).swap(m_matV.col(k+1));
|
||||
if (wantu && (k < m-1))
|
||||
m_matU.col(k).swap(m_matU.col(k+1));
|
||||
++k;
|
||||
}
|
||||
iter = 0;
|
||||
p--;
|
||||
}
|
||||
break;
|
||||
} // end big switch
|
||||
} // end iterations
|
||||
}
|
||||
|
||||
template<typename MatrixType>
|
||||
SVD<MatrixType>& SVD<MatrixType>::sort()
|
||||
{
|
||||
int mu = m_matU.rows();
|
||||
int mv = m_matV.rows();
|
||||
int n = m_matU.cols();
|
||||
|
||||
for (int i=0; i<n; ++i)
|
||||
{
|
||||
int k = i;
|
||||
Scalar p = m_sigma.coeff(i);
|
||||
|
||||
for (int j=i+1; j<n; ++j)
|
||||
{
|
||||
if (m_sigma.coeff(j) > p)
|
||||
{
|
||||
k = j;
|
||||
p = m_sigma.coeff(j);
|
||||
}
|
||||
}
|
||||
if (k != i)
|
||||
{
|
||||
m_sigma.coeffRef(k) = m_sigma.coeff(i); // i.e.
|
||||
m_sigma.coeffRef(i) = p; // swaps the i-th and the k-th elements
|
||||
|
||||
int j = mu;
|
||||
for(int s=0; j!=0; ++s, --j)
|
||||
std::swap(m_matU.coeffRef(s,i), m_matU.coeffRef(s,k));
|
||||
|
||||
j = mv;
|
||||
for (int s=0; j!=0; ++s, --j)
|
||||
std::swap(m_matV.coeffRef(s,i), m_matV.coeffRef(s,k));
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/** \returns the solution of \f$ A x = b \f$ using the current SVD decomposition of A.
|
||||
* The parts of the solution corresponding to zero singular values are ignored.
|
||||
*
|
||||
* \sa MatrixBase::svd(), LU::solve(), LLT::solve()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
template<typename OtherDerived, typename ResultType>
|
||||
bool SVD<MatrixType>::solve(const MatrixBase<OtherDerived> &b, ResultType* result) const
|
||||
{
|
||||
const int rows = m_matU.rows();
|
||||
ei_assert(b.rows() == rows);
|
||||
|
||||
Scalar maxVal = m_sigma.cwise().abs().maxCoeff();
|
||||
for (int j=0; j<b.cols(); ++j)
|
||||
{
|
||||
Matrix<Scalar,MatrixUType::RowsAtCompileTime,1> aux = m_matU.transpose() * b.col(j);
|
||||
|
||||
for (int i = 0; i <m_matU.cols(); ++i)
|
||||
{
|
||||
Scalar si = m_sigma.coeff(i);
|
||||
if (ei_isMuchSmallerThan(ei_abs(si),maxVal))
|
||||
aux.coeffRef(i) = 0;
|
||||
else
|
||||
aux.coeffRef(i) /= si;
|
||||
}
|
||||
|
||||
result->col(j) = m_matV * aux;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Computes the polar decomposition of the matrix, as a product unitary x positive.
|
||||
*
|
||||
* If either pointer is zero, the corresponding computation is skipped.
|
||||
*
|
||||
* Only for square matrices.
|
||||
*
|
||||
* \sa computePositiveUnitary(), computeRotationScaling()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
template<typename UnitaryType, typename PositiveType>
|
||||
void SVD<MatrixType>::computeUnitaryPositive(UnitaryType *unitary,
|
||||
PositiveType *positive) const
|
||||
{
|
||||
ei_assert(m_matU.cols() == m_matV.cols() && "Polar decomposition is only for square matrices");
|
||||
if(unitary) *unitary = m_matU * m_matV.adjoint();
|
||||
if(positive) *positive = m_matV * m_sigma.asDiagonal() * m_matV.adjoint();
|
||||
}
|
||||
|
||||
/** Computes the polar decomposition of the matrix, as a product positive x unitary.
|
||||
*
|
||||
* If either pointer is zero, the corresponding computation is skipped.
|
||||
*
|
||||
* Only for square matrices.
|
||||
*
|
||||
* \sa computeUnitaryPositive(), computeRotationScaling()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
template<typename UnitaryType, typename PositiveType>
|
||||
void SVD<MatrixType>::computePositiveUnitary(UnitaryType *positive,
|
||||
PositiveType *unitary) const
|
||||
{
|
||||
ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
|
||||
if(unitary) *unitary = m_matU * m_matV.adjoint();
|
||||
if(positive) *positive = m_matU * m_sigma.asDiagonal() * m_matU.adjoint();
|
||||
}
|
||||
|
||||
/** decomposes the matrix as a product rotation x scaling, the scaling being
|
||||
* not necessarily positive.
|
||||
*
|
||||
* If either pointer is zero, the corresponding computation is skipped.
|
||||
*
|
||||
* This method requires the Geometry module.
|
||||
*
|
||||
* \sa computeScalingRotation(), computeUnitaryPositive()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
template<typename RotationType, typename ScalingType>
|
||||
void SVD<MatrixType>::computeRotationScaling(RotationType *rotation, ScalingType *scaling) const
|
||||
{
|
||||
ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
|
||||
Scalar x = (m_matU * m_matV.adjoint()).determinant(); // so x has absolute value 1
|
||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> sv(m_sigma);
|
||||
sv.coeffRef(0) *= x;
|
||||
if(scaling) scaling->lazyAssign(m_matV * sv.asDiagonal() * m_matV.adjoint());
|
||||
if(rotation)
|
||||
{
|
||||
MatrixType m(m_matU);
|
||||
m.col(0) /= x;
|
||||
rotation->lazyAssign(m * m_matV.adjoint());
|
||||
}
|
||||
}
|
||||
|
||||
/** decomposes the matrix as a product scaling x rotation, the scaling being
|
||||
* not necessarily positive.
|
||||
*
|
||||
* If either pointer is zero, the corresponding computation is skipped.
|
||||
*
|
||||
* This method requires the Geometry module.
|
||||
*
|
||||
* \sa computeRotationScaling(), computeUnitaryPositive()
|
||||
*/
|
||||
template<typename MatrixType>
|
||||
template<typename ScalingType, typename RotationType>
|
||||
void SVD<MatrixType>::computeScalingRotation(ScalingType *scaling, RotationType *rotation) const
|
||||
{
|
||||
ei_assert(m_matU.rows() == m_matV.rows() && "Polar decomposition is only for square matrices");
|
||||
Scalar x = (m_matU * m_matV.adjoint()).determinant(); // so x has absolute value 1
|
||||
Matrix<Scalar, MatrixType::RowsAtCompileTime, 1> sv(m_sigma);
|
||||
sv.coeffRef(0) *= x;
|
||||
if(scaling) scaling->lazyAssign(m_matU * sv.asDiagonal() * m_matU.adjoint());
|
||||
if(rotation)
|
||||
{
|
||||
MatrixType m(m_matU);
|
||||
m.col(0) /= x;
|
||||
rotation->lazyAssign(m * m_matV.adjoint());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** \svd_module
|
||||
* \returns the SVD decomposition of \c *this
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline SVD<typename MatrixBase<Derived>::PlainObject>
|
||||
MatrixBase<Derived>::svd() const
|
||||
{
|
||||
return SVD<PlainObject>(derived());
|
||||
}
|
||||
|
||||
#endif // EIGEN_SVD_H
|
@ -489,6 +489,7 @@ MatrixBase<Derived>::partialPivLu() const
|
||||
return PartialPivLU<PlainObject>(eval());
|
||||
}
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE > STAGE20_RESOLVE_API_CONFLICTS
|
||||
/** \lu_module
|
||||
*
|
||||
* Synonym of partialPivLu().
|
||||
@ -503,5 +504,6 @@ MatrixBase<Derived>::lu() const
|
||||
{
|
||||
return PartialPivLU<PlainObject>(eval());
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // EIGEN_PARTIALLU_H
|
||||
|
@ -49,7 +49,7 @@ template<typename _MatrixType> class UpperBidiagonalization
|
||||
typedef Matrix<Scalar, ColsAtCompileTimeMinusOne, 1> SuperDiagVectorType;
|
||||
typedef HouseholderSequence<
|
||||
const MatrixType,
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, Diagonal<const MatrixType,0> >
|
||||
CwiseUnaryOp<internal::scalar_conjugate_op<Scalar>, const Diagonal<const MatrixType,0> >
|
||||
> HouseholderUSequenceType;
|
||||
typedef HouseholderSequence<
|
||||
const MatrixType,
|
||||
|
@ -115,9 +115,9 @@ namespace internal {
|
||||
template<typename Lhs, typename Rhs, typename SparseDiagonalProductType>
|
||||
class sparse_diagonal_product_inner_iterator_selector
|
||||
<Lhs,Rhs,SparseDiagonalProductType,SDP_IsDiagonal,SDP_IsSparseRowMajor>
|
||||
: public CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,Rhs>::InnerIterator
|
||||
: public CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,const Rhs>::InnerIterator
|
||||
{
|
||||
typedef typename CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,Rhs>::InnerIterator Base;
|
||||
typedef typename CwiseUnaryOp<scalar_multiple_op<typename Lhs::Scalar>,const Rhs>::InnerIterator Base;
|
||||
typedef typename Lhs::Index Index;
|
||||
public:
|
||||
inline sparse_diagonal_product_inner_iterator_selector(
|
||||
@ -149,9 +149,9 @@ class sparse_diagonal_product_inner_iterator_selector
|
||||
template<typename Lhs, typename Rhs, typename SparseDiagonalProductType>
|
||||
class sparse_diagonal_product_inner_iterator_selector
|
||||
<Lhs,Rhs,SparseDiagonalProductType,SDP_IsSparseColMajor,SDP_IsDiagonal>
|
||||
: public CwiseUnaryOp<scalar_multiple_op<typename Rhs::Scalar>,Lhs>::InnerIterator
|
||||
: public CwiseUnaryOp<scalar_multiple_op<typename Rhs::Scalar>,const Lhs>::InnerIterator
|
||||
{
|
||||
typedef typename CwiseUnaryOp<scalar_multiple_op<typename Rhs::Scalar>,Lhs>::InnerIterator Base;
|
||||
typedef typename CwiseUnaryOp<scalar_multiple_op<typename Rhs::Scalar>,const Lhs>::InnerIterator Base;
|
||||
typedef typename Lhs::Index Index;
|
||||
public:
|
||||
inline sparse_diagonal_product_inner_iterator_selector(
|
||||
|
@ -12,7 +12,11 @@ macro(ei_add_test_internal testname testname_with_suffix)
|
||||
|
||||
set(filename ${testname}.cpp)
|
||||
add_executable(${targetname} ${filename})
|
||||
add_dependencies(buildtests ${targetname})
|
||||
if (targetname MATCHES "^eigen2_")
|
||||
add_dependencies(eigen2_buildtests ${targetname})
|
||||
else()
|
||||
add_dependencies(buildtests ${targetname})
|
||||
endif()
|
||||
|
||||
if(EIGEN_NO_ASSERTION_CHECKING)
|
||||
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
|
||||
|
@ -1,132 +1,58 @@
|
||||
add_custom_target(buildtests_eigen2)
|
||||
add_custom_target(check_eigen2 COMMAND "ctest")
|
||||
add_dependencies(check_eigen2 buildtests_eigen2)
|
||||
add_custom_target(eigen2_buildtests)
|
||||
add_custom_target(eigen2_check COMMAND "ctest -R eigen2")
|
||||
add_dependencies(eigen2_check eigen2_buildtests)
|
||||
add_dependencies(buildtests eigen2_buildtests)
|
||||
|
||||
add_definitions("-DEIGEN2_SUPPORT_STAGE10_FULL_EIGEN2_API")
|
||||
|
||||
# Macro to add a test
|
||||
#
|
||||
# the unique parameter testname must correspond to a file
|
||||
# <testname>.cpp which follows this pattern:
|
||||
#
|
||||
# #include "main.h"
|
||||
# void test_<testname>() { ... }
|
||||
#
|
||||
# this macro add an executable test_<testname> as well as a ctest test
|
||||
# named <testname>
|
||||
#
|
||||
# On platforms with bash simply run:
|
||||
# "ctest -V" or "ctest -V -R <testname>"
|
||||
# On other platform use ctest as usual
|
||||
#
|
||||
macro(ei_add_test_eigen2 testname)
|
||||
|
||||
set(targetname test_eigen2_${testname})
|
||||
|
||||
set(filename ${testname}.cpp)
|
||||
add_executable(${targetname} ${filename})
|
||||
add_dependencies(buildtests_eigen2 ${targetname})
|
||||
|
||||
if(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
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 "EIGEN_DEBUG_ASSERTS=1")
|
||||
endif(EIGEN_DEBUG_ASSERTS)
|
||||
|
||||
endif(NOT EIGEN_NO_ASSERTION_CHECKING)
|
||||
|
||||
if(${ARGC} GREATER 1)
|
||||
ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV1}")
|
||||
endif(${ARGC} GREATER 1)
|
||||
|
||||
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
||||
|
||||
if(TEST_LIB)
|
||||
target_link_libraries(${targetname} Eigen2)
|
||||
endif(TEST_LIB)
|
||||
|
||||
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
||||
target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${targetname} ${EXTERNAL_LIBS})
|
||||
if(${ARGC} GREATER 2)
|
||||
string(STRIP "${ARGV2}" ARGV2_stripped)
|
||||
string(LENGTH "${ARGV2_stripped}" ARGV2_stripped_length)
|
||||
if(${ARGV2_stripped_length} GREATER 0)
|
||||
target_link_libraries(${targetname} ${ARGV2})
|
||||
endif(${ARGV2_stripped_length} GREATER 0)
|
||||
endif(${ARGC} GREATER 2)
|
||||
|
||||
if(WIN32)
|
||||
add_test(${testname} "${targetname}")
|
||||
else(WIN32)
|
||||
add_test(${testname} "${CMAKE_CURRENT_SOURCE_DIR}/runtest.sh" "${testname}")
|
||||
endif(WIN32)
|
||||
|
||||
endmacro(ei_add_test_eigen2)
|
||||
|
||||
enable_testing()
|
||||
|
||||
if(TEST_LIB)
|
||||
add_definitions("-DEIGEN_EXTERN_INSTANTIATIONS=1")
|
||||
endif(TEST_LIB)
|
||||
|
||||
ei_add_test_eigen2(meta)
|
||||
ei_add_test_eigen2(sizeof)
|
||||
ei_add_test_eigen2(dynalloc)
|
||||
ei_add_test_eigen2(nomalloc)
|
||||
ei_add_test_eigen2(first_aligned)
|
||||
ei_add_test_eigen2(mixingtypes)
|
||||
ei_add_test_eigen2(packetmath)
|
||||
ei_add_test_eigen2(unalignedassert)
|
||||
#ei_add_test_eigen2(vectorization_logic)
|
||||
ei_add_test_eigen2(basicstuff)
|
||||
ei_add_test_eigen2(linearstructure)
|
||||
ei_add_test_eigen2(cwiseop)
|
||||
ei_add_test_eigen2(sum)
|
||||
ei_add_test_eigen2(product_small)
|
||||
ei_add_test_eigen2(product_large ${EI_OFLAG})
|
||||
ei_add_test_eigen2(adjoint)
|
||||
ei_add_test_eigen2(submatrices)
|
||||
ei_add_test_eigen2(miscmatrices)
|
||||
ei_add_test_eigen2(commainitializer)
|
||||
ei_add_test_eigen2(smallvectors)
|
||||
ei_add_test_eigen2(map)
|
||||
ei_add_test_eigen2(array)
|
||||
ei_add_test_eigen2(triangular)
|
||||
ei_add_test_eigen2(cholesky " " "${GSL_LIBRARIES}")
|
||||
ei_add_test_eigen2(lu ${EI_OFLAG})
|
||||
ei_add_test_eigen2(determinant ${EI_OFLAG})
|
||||
ei_add_test_eigen2(inverse)
|
||||
ei_add_test_eigen2(qr)
|
||||
ei_add_test_eigen2(eigensolver " " "${GSL_LIBRARIES}")
|
||||
ei_add_test_eigen2(svd)
|
||||
ei_add_test_eigen2(geometry)
|
||||
ei_add_test_eigen2(hyperplane)
|
||||
ei_add_test_eigen2(parametrizedline)
|
||||
ei_add_test_eigen2(alignedbox)
|
||||
ei_add_test_eigen2(regression)
|
||||
ei_add_test_eigen2(stdvector)
|
||||
ei_add_test_eigen2(newstdvector)
|
||||
ei_add_test(eigen2_meta)
|
||||
ei_add_test(eigen2_sizeof)
|
||||
ei_add_test(eigen2_dynalloc)
|
||||
ei_add_test(eigen2_nomalloc)
|
||||
#ei_add_test(eigen2_first_aligned)
|
||||
ei_add_test(eigen2_mixingtypes)
|
||||
ei_add_test(eigen2_packetmath)
|
||||
ei_add_test(eigen2_unalignedassert)
|
||||
#ei_add_test(eigen2_vectorization_logic)
|
||||
ei_add_test(eigen2_basicstuff)
|
||||
ei_add_test(eigen2_linearstructure)
|
||||
ei_add_test(eigen2_cwiseop)
|
||||
ei_add_test(eigen2_sum)
|
||||
ei_add_test(eigen2_product_small)
|
||||
ei_add_test(eigen2_product_large ${EI_OFLAG})
|
||||
ei_add_test(eigen2_adjoint)
|
||||
ei_add_test(eigen2_submatrices)
|
||||
ei_add_test(eigen2_miscmatrices)
|
||||
ei_add_test(eigen2_commainitializer)
|
||||
ei_add_test(eigen2_smallvectors)
|
||||
ei_add_test(eigen2_map)
|
||||
ei_add_test(eigen2_array)
|
||||
ei_add_test(eigen2_triangular)
|
||||
ei_add_test(eigen2_cholesky " " "${GSL_LIBRARIES}")
|
||||
ei_add_test(eigen2_lu ${EI_OFLAG})
|
||||
ei_add_test(eigen2_determinant ${EI_OFLAG})
|
||||
ei_add_test(eigen2_inverse)
|
||||
ei_add_test(eigen2_qr)
|
||||
ei_add_test(eigen2_eigensolver " " "${GSL_LIBRARIES}")
|
||||
ei_add_test(eigen2_svd)
|
||||
ei_add_test(eigen2_geometry)
|
||||
ei_add_test(eigen2_hyperplane)
|
||||
ei_add_test(eigen2_parametrizedline)
|
||||
ei_add_test(eigen2_alignedbox)
|
||||
ei_add_test(eigen2_regression)
|
||||
ei_add_test(eigen2_stdvector)
|
||||
ei_add_test(eigen2_newstdvector)
|
||||
if(QT4_FOUND)
|
||||
ei_add_test_eigen2(qtvector " " "${QT_QTCORE_LIBRARY}")
|
||||
ei_add_test(eigen2_qtvector " " "${QT_QTCORE_LIBRARY}")
|
||||
endif(QT4_FOUND)
|
||||
if(NOT EIGEN_DEFAULT_TO_ROW_MAJOR)
|
||||
ei_add_test_eigen2(sparse_vector)
|
||||
ei_add_test_eigen2(sparse_basic)
|
||||
ei_add_test_eigen2(sparse_solvers " " "${SPARSE_LIBS}")
|
||||
ei_add_test_eigen2(sparse_product)
|
||||
ei_add_test(eigen2_sparse_vector)
|
||||
ei_add_test(eigen2_sparse_basic)
|
||||
ei_add_test(eigen2_sparse_solvers " " "${SPARSE_LIBS}")
|
||||
ei_add_test(eigen2_sparse_product)
|
||||
endif()
|
||||
ei_add_test_eigen2(swap)
|
||||
ei_add_test_eigen2(visitor)
|
||||
ei_add_test_eigen2(bug_132)
|
||||
ei_add_test(eigen2_swap)
|
||||
ei_add_test(eigen2_visitor)
|
||||
ei_add_test(eigen2_bug_132)
|
||||
|
||||
ei_add_test_eigen2(prec_inverse_4x4 ${EI_OFLAG})
|
||||
ei_add_test(eigen2_prec_inverse_4x4 ${EI_OFLAG})
|
||||
|
@ -100,17 +100,17 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
|
||||
}
|
||||
|
||||
void test_adjoint()
|
||||
void test_eigen2_adjoint()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( adjoint(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( adjoint(Matrix3d()) );
|
||||
CALL_SUBTEST( adjoint(Matrix4f()) );
|
||||
CALL_SUBTEST( adjoint(MatrixXcf(4, 4)) );
|
||||
CALL_SUBTEST( adjoint(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( adjoint(MatrixXf(21, 21)) );
|
||||
CALL_SUBTEST_1( adjoint(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( adjoint(Matrix3d()) );
|
||||
CALL_SUBTEST_3( adjoint(Matrix4f()) );
|
||||
CALL_SUBTEST_4( adjoint(MatrixXcf(4, 4)) );
|
||||
CALL_SUBTEST_5( adjoint(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_6( adjoint(MatrixXf(21, 21)) );
|
||||
}
|
||||
// test a large matrix only once
|
||||
CALL_SUBTEST( adjoint(Matrix<float, 100, 100>()) );
|
||||
CALL_SUBTEST_7( adjoint(Matrix<float, 100, 100>()) );
|
||||
}
|
||||
|
@ -65,11 +65,11 @@ template<typename BoxType> void alignedbox(const BoxType& _box)
|
||||
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
|
||||
}
|
||||
|
||||
void test_alignedbox()
|
||||
void test_eigen2_alignedbox()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( alignedbox(AlignedBox<float,2>()) );
|
||||
CALL_SUBTEST( alignedbox(AlignedBox<float,3>()) );
|
||||
CALL_SUBTEST( alignedbox(AlignedBox<double,4>()) );
|
||||
CALL_SUBTEST_1( alignedbox(AlignedBox<float,2>()) );
|
||||
CALL_SUBTEST_2( alignedbox(AlignedBox<float,3>()) );
|
||||
CALL_SUBTEST_3( alignedbox(AlignedBox<double,4>()) );
|
||||
}
|
||||
}
|
@ -129,29 +129,29 @@ template<typename VectorType> void lpNorm(const VectorType& v)
|
||||
VERIFY_IS_APPROX(ei_pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.cwise().abs().cwise().pow(5).sum());
|
||||
}
|
||||
|
||||
void test_array()
|
||||
void test_eigen2_array()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( array(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( array(Matrix2f()) );
|
||||
CALL_SUBTEST( array(Matrix4d()) );
|
||||
CALL_SUBTEST( array(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( array(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST( array(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_1( array(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( array(Matrix2f()) );
|
||||
CALL_SUBTEST_3( array(Matrix4d()) );
|
||||
CALL_SUBTEST_4( array(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_5( array(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST_6( array(MatrixXi(8, 12)) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( comparisons(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( comparisons(Matrix2f()) );
|
||||
CALL_SUBTEST( comparisons(Matrix4d()) );
|
||||
CALL_SUBTEST( comparisons(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST( comparisons(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_1( comparisons(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( comparisons(Matrix2f()) );
|
||||
CALL_SUBTEST_3( comparisons(Matrix4d()) );
|
||||
CALL_SUBTEST_5( comparisons(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST_6( comparisons(MatrixXi(8, 12)) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( lpNorm(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( lpNorm(Vector2f()) );
|
||||
CALL_SUBTEST( lpNorm(Vector3d()) );
|
||||
CALL_SUBTEST( lpNorm(Vector4f()) );
|
||||
CALL_SUBTEST( lpNorm(VectorXf(16)) );
|
||||
CALL_SUBTEST( lpNorm(VectorXcd(10)) );
|
||||
CALL_SUBTEST_1( lpNorm(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( lpNorm(Vector2f()) );
|
||||
CALL_SUBTEST_3( lpNorm(Vector3d()) );
|
||||
CALL_SUBTEST_4( lpNorm(Vector4f()) );
|
||||
CALL_SUBTEST_5( lpNorm(VectorXf(16)) );
|
||||
CALL_SUBTEST_7( lpNorm(VectorXcd(10)) );
|
||||
}
|
||||
}
|
@ -109,15 +109,15 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
|
||||
}
|
||||
}
|
||||
|
||||
void test_basicstuff()
|
||||
void test_eigen2_basicstuff()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( basicStuff(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( basicStuff(Matrix4d()) );
|
||||
CALL_SUBTEST( basicStuff(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( basicStuff(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( basicStuff(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST( basicStuff(Matrix<float, 100, 100>()) );
|
||||
CALL_SUBTEST( basicStuff(Matrix<long double,Dynamic,Dynamic>(10,10)) );
|
||||
CALL_SUBTEST_1( basicStuff(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( basicStuff(Matrix4d()) );
|
||||
CALL_SUBTEST_3( basicStuff(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_4( basicStuff(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_5( basicStuff(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST_6( basicStuff(Matrix<float, 100, 100>()) );
|
||||
CALL_SUBTEST_7( basicStuff(Matrix<long double,Dynamic,Dynamic>(10,10)) );
|
||||
}
|
||||
}
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void test_bug_132() {
|
||||
enum { size = 100 };
|
||||
void test_eigen2_bug_132() {
|
||||
int size = 100;
|
||||
MatrixXd A(size, size);
|
||||
VectorXd b(size), c(size);
|
||||
{
|
@ -113,19 +113,21 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_cholesky()
|
||||
void test_eigen2_cholesky()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( cholesky(Matrix<double,1,1>()) );
|
||||
CALL_SUBTEST( cholesky(Matrix2d()) );
|
||||
CALL_SUBTEST( cholesky(Matrix3f()) );
|
||||
CALL_SUBTEST( cholesky(Matrix4d()) );
|
||||
CALL_SUBTEST( cholesky(MatrixXcd(7,7)) );
|
||||
CALL_SUBTEST( cholesky(MatrixXf(17,17)) );
|
||||
CALL_SUBTEST( cholesky(MatrixXd(33,33)) );
|
||||
CALL_SUBTEST_1( cholesky(Matrix<double,1,1>()) );
|
||||
CALL_SUBTEST_2( cholesky(Matrix2d()) );
|
||||
CALL_SUBTEST_3( cholesky(Matrix3f()) );
|
||||
CALL_SUBTEST_4( cholesky(Matrix4d()) );
|
||||
CALL_SUBTEST_5( cholesky(MatrixXcd(7,7)) );
|
||||
CALL_SUBTEST_6( cholesky(MatrixXf(17,17)) );
|
||||
CALL_SUBTEST_7( cholesky(MatrixXd(33,33)) );
|
||||
}
|
||||
|
||||
#ifdef EIGEN_TEST_PART_6
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VERIFY(!m.llt().isPositiveDefinite());
|
||||
#endif
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void test_commainitializer()
|
||||
void test_eigen2_commainitializer()
|
||||
{
|
||||
Matrix3d m3;
|
||||
Matrix4d m4;
|
@ -160,14 +160,14 @@ template<typename MatrixType> void cwiseops(const MatrixType& m)
|
||||
VERIFY( !(m1.cwise()>m1.unaryExpr(bind2nd(plus<Scalar>(), Scalar(1)))).any() );
|
||||
}
|
||||
|
||||
void test_cwiseop()
|
||||
void test_eigen2_cwiseop()
|
||||
{
|
||||
for(int i = 0; i < g_repeat ; i++) {
|
||||
CALL_SUBTEST( cwiseops(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( cwiseops(Matrix4d()) );
|
||||
CALL_SUBTEST( cwiseops(MatrixXf(3, 3)) );
|
||||
CALL_SUBTEST( cwiseops(MatrixXf(22, 22)) );
|
||||
CALL_SUBTEST( cwiseops(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( cwiseops(MatrixXd(20, 20)) );
|
||||
CALL_SUBTEST_1( cwiseops(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( cwiseops(Matrix4d()) );
|
||||
CALL_SUBTEST_3( cwiseops(MatrixXf(3, 3)) );
|
||||
CALL_SUBTEST_3( cwiseops(MatrixXf(22, 22)) );
|
||||
CALL_SUBTEST_4( cwiseops(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_5( cwiseops(MatrixXd(20, 20)) );
|
||||
}
|
||||
}
|
@ -62,15 +62,15 @@ template<typename MatrixType> void determinant(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m2.determinant(), m1.determinant() * x);
|
||||
}
|
||||
|
||||
void test_determinant()
|
||||
void test_eigen2_determinant()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( determinant(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( determinant(Matrix<double, 2, 2>()) );
|
||||
CALL_SUBTEST( determinant(Matrix<double, 3, 3>()) );
|
||||
CALL_SUBTEST( determinant(Matrix<double, 4, 4>()) );
|
||||
CALL_SUBTEST( determinant(Matrix<std::complex<double>, 10, 10>()) );
|
||||
CALL_SUBTEST( determinant(MatrixXd(20, 20)) );
|
||||
CALL_SUBTEST_1( determinant(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( determinant(Matrix<double, 2, 2>()) );
|
||||
CALL_SUBTEST_3( determinant(Matrix<double, 3, 3>()) );
|
||||
CALL_SUBTEST_4( determinant(Matrix<double, 4, 4>()) );
|
||||
CALL_SUBTEST_5( determinant(Matrix<std::complex<double>, 10, 10>()) );
|
||||
CALL_SUBTEST_6( determinant(MatrixXd(20, 20)) );
|
||||
}
|
||||
CALL_SUBTEST( determinant(MatrixXd(200, 200)) );
|
||||
CALL_SUBTEST_6( determinant(MatrixXd(200, 200)) );
|
||||
}
|
@ -102,7 +102,7 @@ template<typename T> void check_dynaligned()
|
||||
delete obj;
|
||||
}
|
||||
|
||||
void test_dynalloc()
|
||||
void test_eigen2_dynalloc()
|
||||
{
|
||||
// low level dynamic memory allocation
|
||||
CALL_SUBTEST(check_handmade_aligned_malloc());
|
@ -145,18 +145,18 @@ template<typename MatrixType> void eigensolver(const MatrixType& m)
|
||||
|
||||
}
|
||||
|
||||
void test_eigensolver()
|
||||
void test_eigen2_eigensolver()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
// very important to test a 3x3 matrix since we provide a special path for it
|
||||
CALL_SUBTEST( selfadjointeigensolver(Matrix3f()) );
|
||||
CALL_SUBTEST( selfadjointeigensolver(Matrix4d()) );
|
||||
CALL_SUBTEST( selfadjointeigensolver(MatrixXf(7,7)) );
|
||||
CALL_SUBTEST( selfadjointeigensolver(MatrixXcd(5,5)) );
|
||||
CALL_SUBTEST( selfadjointeigensolver(MatrixXd(19,19)) );
|
||||
CALL_SUBTEST_1( selfadjointeigensolver(Matrix3f()) );
|
||||
CALL_SUBTEST_2( selfadjointeigensolver(Matrix4d()) );
|
||||
CALL_SUBTEST_3( selfadjointeigensolver(MatrixXf(7,7)) );
|
||||
CALL_SUBTEST_4( selfadjointeigensolver(MatrixXcd(5,5)) );
|
||||
CALL_SUBTEST_5( selfadjointeigensolver(MatrixXd(19,19)) );
|
||||
|
||||
CALL_SUBTEST( eigensolver(Matrix4f()) );
|
||||
CALL_SUBTEST( eigensolver(MatrixXd(17,17)) );
|
||||
CALL_SUBTEST_6( eigensolver(Matrix4f()) );
|
||||
CALL_SUBTEST_5( eigensolver(MatrixXd(17,17)) );
|
||||
}
|
||||
}
|
||||
|
@ -25,21 +25,21 @@
|
||||
#include "main.h"
|
||||
|
||||
template<typename Scalar>
|
||||
void test_first_aligned_helper(Scalar *array, int size)
|
||||
void test_eigen2_first_aligned_helper(Scalar *array, int size)
|
||||
{
|
||||
const int packet_size = sizeof(Scalar) * ei_packet_traits<Scalar>::size;
|
||||
VERIFY(((std::size_t(array) + sizeof(Scalar) * ei_alignmentOffset(array, size)) % packet_size) == 0);
|
||||
}
|
||||
|
||||
template<typename Scalar>
|
||||
void test_none_aligned_helper(Scalar *array, int size)
|
||||
void test_eigen2_none_aligned_helper(Scalar *array, int size)
|
||||
{
|
||||
VERIFY(ei_packet_traits<Scalar>::size == 1 || ei_alignmentOffset(array, size) == size);
|
||||
}
|
||||
|
||||
struct some_non_vectorizable_type { float x; };
|
||||
|
||||
void test_first_aligned()
|
||||
void test_eigen2_first_aligned()
|
||||
{
|
||||
EIGEN_ALIGN_128 float array_float[100];
|
||||
test_first_aligned_helper(array_float, 50);
|
@ -437,10 +437,10 @@ template<typename Scalar> void geometry(void)
|
||||
|
||||
}
|
||||
|
||||
void test_geometry()
|
||||
void test_eigen2_geometry()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( geometry<float>() );
|
||||
CALL_SUBTEST( geometry<double>() );
|
||||
CALL_SUBTEST_1( geometry<float>() );
|
||||
CALL_SUBTEST_2( geometry<double>() );
|
||||
}
|
||||
}
|
@ -128,14 +128,14 @@ template<typename Scalar> void lines()
|
||||
}
|
||||
}
|
||||
|
||||
void test_hyperplane()
|
||||
void test_eigen2_hyperplane()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( hyperplane(Hyperplane<float,2>()) );
|
||||
CALL_SUBTEST( hyperplane(Hyperplane<float,3>()) );
|
||||
CALL_SUBTEST( hyperplane(Hyperplane<double,4>()) );
|
||||
CALL_SUBTEST( hyperplane(Hyperplane<std::complex<double>,5>()) );
|
||||
CALL_SUBTEST( lines<float>() );
|
||||
CALL_SUBTEST( lines<double>() );
|
||||
CALL_SUBTEST_1( hyperplane(Hyperplane<float,2>()) );
|
||||
CALL_SUBTEST_2( hyperplane(Hyperplane<float,3>()) );
|
||||
CALL_SUBTEST_3( hyperplane(Hyperplane<double,4>()) );
|
||||
CALL_SUBTEST_4( hyperplane(Hyperplane<std::complex<double>,5>()) );
|
||||
CALL_SUBTEST_5( lines<float>() );
|
||||
CALL_SUBTEST_6( lines<double>() );
|
||||
}
|
||||
}
|
@ -65,14 +65,14 @@ template<typename MatrixType> void inverse(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m1.transpose().inverse(), m1.inverse().transpose());
|
||||
}
|
||||
|
||||
void test_inverse()
|
||||
void test_eigen2_inverse()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( inverse(Matrix<double,1,1>()) );
|
||||
CALL_SUBTEST( inverse(Matrix2d()) );
|
||||
CALL_SUBTEST( inverse(Matrix3f()) );
|
||||
CALL_SUBTEST( inverse(Matrix4f()) );
|
||||
CALL_SUBTEST( inverse(MatrixXf(8,8)) );
|
||||
CALL_SUBTEST( inverse(MatrixXcd(7,7)) );
|
||||
CALL_SUBTEST_1( inverse(Matrix<double,1,1>()) );
|
||||
CALL_SUBTEST_2( inverse(Matrix2d()) );
|
||||
CALL_SUBTEST_3( inverse(Matrix3f()) );
|
||||
CALL_SUBTEST_4( inverse(Matrix4f()) );
|
||||
CALL_SUBTEST_5( inverse(MatrixXf(8,8)) );
|
||||
CALL_SUBTEST_6( inverse(MatrixXcd(7,7)) );
|
||||
}
|
||||
}
|
@ -84,16 +84,16 @@ template<typename MatrixType> void linearStructure(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m1.block(0,0,rows,cols) * s1, m1 * s1);
|
||||
}
|
||||
|
||||
void test_linearstructure()
|
||||
void test_eigen2_linearstructure()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( linearStructure(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( linearStructure(Matrix2f()) );
|
||||
CALL_SUBTEST( linearStructure(Vector3d()) );
|
||||
CALL_SUBTEST( linearStructure(Matrix4d()) );
|
||||
CALL_SUBTEST( linearStructure(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( linearStructure(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST( linearStructure(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( linearStructure(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST_1( linearStructure(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( linearStructure(Matrix2f()) );
|
||||
CALL_SUBTEST_3( linearStructure(Vector3d()) );
|
||||
CALL_SUBTEST_4( linearStructure(Matrix4d()) );
|
||||
CALL_SUBTEST_5( linearStructure(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_6( linearStructure(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST_7( linearStructure(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_8( linearStructure(MatrixXcd(20, 20)) );
|
||||
}
|
||||
}
|
@ -83,8 +83,10 @@ template<typename MatrixType> void lu_non_invertible()
|
||||
m2 = MatrixType::Random(cols,cols2);
|
||||
lu.solve(m3, &m2);
|
||||
VERIFY_IS_APPROX(m3, m1*m2);
|
||||
/* solve now always returns true
|
||||
m3 = MatrixType::Random(rows,cols2);
|
||||
VERIFY(!lu.solve(m3, &m2));
|
||||
*/
|
||||
}
|
||||
|
||||
template<typename MatrixType> void lu_invertible()
|
||||
@ -120,22 +122,16 @@ template<typename MatrixType> void lu_invertible()
|
||||
VERIFY(lu.solve(m3, &m2));
|
||||
}
|
||||
|
||||
void test_lu()
|
||||
void test_eigen2_lu()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( lu_non_invertible<MatrixXf>() );
|
||||
CALL_SUBTEST( lu_non_invertible<MatrixXd>() );
|
||||
CALL_SUBTEST( lu_non_invertible<MatrixXcf>() );
|
||||
CALL_SUBTEST( lu_non_invertible<MatrixXcd>() );
|
||||
CALL_SUBTEST( lu_invertible<MatrixXf>() );
|
||||
CALL_SUBTEST( lu_invertible<MatrixXd>() );
|
||||
CALL_SUBTEST( lu_invertible<MatrixXcf>() );
|
||||
CALL_SUBTEST( lu_invertible<MatrixXcd>() );
|
||||
CALL_SUBTEST_1( lu_non_invertible<MatrixXf>() );
|
||||
CALL_SUBTEST_2( lu_non_invertible<MatrixXd>() );
|
||||
CALL_SUBTEST_3( lu_non_invertible<MatrixXcf>() );
|
||||
CALL_SUBTEST_4( lu_non_invertible<MatrixXcd>() );
|
||||
CALL_SUBTEST_1( lu_invertible<MatrixXf>() );
|
||||
CALL_SUBTEST_2( lu_invertible<MatrixXd>() );
|
||||
CALL_SUBTEST_3( lu_invertible<MatrixXcf>() );
|
||||
CALL_SUBTEST_4( lu_invertible<MatrixXcd>() );
|
||||
}
|
||||
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VectorXf x = VectorXf::Random(10);
|
||||
VERIFY(m.lu().solve(b,&x));
|
||||
VERIFY(x.isZero());
|
||||
}
|
@ -105,25 +105,25 @@ template<typename VectorType> void map_static_methods(const VectorType& m)
|
||||
}
|
||||
|
||||
|
||||
void test_map()
|
||||
void test_eigen2_map()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( map_class_vector(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( map_class_vector(Vector4d()) );
|
||||
CALL_SUBTEST( map_class_vector(RowVector4f()) );
|
||||
CALL_SUBTEST( map_class_vector(VectorXcf(8)) );
|
||||
CALL_SUBTEST( map_class_vector(VectorXi(12)) );
|
||||
CALL_SUBTEST_1( map_class_vector(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( map_class_vector(Vector4d()) );
|
||||
CALL_SUBTEST_3( map_class_vector(RowVector4f()) );
|
||||
CALL_SUBTEST_4( map_class_vector(VectorXcf(8)) );
|
||||
CALL_SUBTEST_5( map_class_vector(VectorXi(12)) );
|
||||
|
||||
CALL_SUBTEST( map_class_matrix(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( map_class_matrix(Matrix4d()) );
|
||||
CALL_SUBTEST( map_class_matrix(Matrix<float,3,5>()) );
|
||||
CALL_SUBTEST( map_class_matrix(MatrixXcf(ei_random<int>(1,10),ei_random<int>(1,10))) );
|
||||
CALL_SUBTEST( map_class_matrix(MatrixXi(ei_random<int>(1,10),ei_random<int>(1,10))) );
|
||||
CALL_SUBTEST_1( map_class_matrix(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( map_class_matrix(Matrix4d()) );
|
||||
CALL_SUBTEST_6( map_class_matrix(Matrix<float,3,5>()) );
|
||||
CALL_SUBTEST_4( map_class_matrix(MatrixXcf(ei_random<int>(1,10),ei_random<int>(1,10))) );
|
||||
CALL_SUBTEST_5( map_class_matrix(MatrixXi(ei_random<int>(1,10),ei_random<int>(1,10))) );
|
||||
|
||||
CALL_SUBTEST( map_static_methods(Matrix<double, 1, 1>()) );
|
||||
CALL_SUBTEST( map_static_methods(Vector3f()) );
|
||||
CALL_SUBTEST( map_static_methods(RowVector3d()) );
|
||||
CALL_SUBTEST( map_static_methods(VectorXcd(8)) );
|
||||
CALL_SUBTEST( map_static_methods(VectorXf(12)) );
|
||||
CALL_SUBTEST_1( map_static_methods(Matrix<double, 1, 1>()) );
|
||||
CALL_SUBTEST_2( map_static_methods(Vector3f()) );
|
||||
CALL_SUBTEST_7( map_static_methods(RowVector3d()) );
|
||||
CALL_SUBTEST_4( map_static_methods(VectorXcd(8)) );
|
||||
CALL_SUBTEST_5( map_static_methods(VectorXf(12)) );
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void test_meta()
|
||||
void test_eigen2_meta()
|
||||
{
|
||||
typedef float & FloatRef;
|
||||
typedef const float & ConstFloatRef;
|
@ -51,13 +51,13 @@ template<typename MatrixType> void miscMatrices(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(square, MatrixType::Identity(rows, rows));
|
||||
}
|
||||
|
||||
void test_miscmatrices()
|
||||
void test_eigen2_miscmatrices()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( miscMatrices(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( miscMatrices(Matrix4d()) );
|
||||
CALL_SUBTEST( miscMatrices(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( miscMatrices(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( miscMatrices(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST_1( miscMatrices(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( miscMatrices(Matrix4d()) );
|
||||
CALL_SUBTEST_3( miscMatrices(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_4( miscMatrices(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_5( miscMatrices(MatrixXcd(20, 20)) );
|
||||
}
|
||||
}
|
@ -79,10 +79,10 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
|
||||
VERIFY_RAISES_ASSERT(vcf.dot(vf)); // yeah eventually we should allow this but i'm too lazy to make that change now in Dot.h
|
||||
} // especially as that might be rewritten as cwise product .sum() which would make that automatic.
|
||||
|
||||
void test_mixingtypes()
|
||||
void test_eigen2_mixingtypes()
|
||||
{
|
||||
// check that our operator new is indeed called:
|
||||
CALL_SUBTEST(mixingtypes<3>());
|
||||
CALL_SUBTEST(mixingtypes<4>());
|
||||
CALL_SUBTEST(mixingtypes<Dynamic>(20));
|
||||
CALL_SUBTEST_1(mixingtypes<3>());
|
||||
CALL_SUBTEST_2(mixingtypes<4>());
|
||||
CALL_SUBTEST_3(mixingtypes<Dynamic>(20));
|
||||
}
|
@ -133,32 +133,32 @@ void check_stdvector_quaternion(const QuaternionType&)
|
||||
}
|
||||
}
|
||||
|
||||
void test_newstdvector()
|
||||
void test_eigen2_newstdvector()
|
||||
{
|
||||
// some non vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix3d()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Matrix3d()));
|
||||
|
||||
// some vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix4d()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d()));
|
||||
|
||||
// some dynamic sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(MatrixXcf(10,10)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10)));
|
||||
|
||||
// some Transform
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform2f()));
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform3f()));
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform3d()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform2f()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform3f()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform3d()));
|
||||
//CALL_SUBTEST(check_stdvector_transform(Transform4d()));
|
||||
|
||||
// some Quaternion
|
||||
CALL_SUBTEST(check_stdvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST(check_stdvector_quaternion(Quaterniond()));
|
||||
CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST_5(check_stdvector_quaternion(Quaterniond()));
|
||||
}
|
@ -68,11 +68,11 @@ template<typename MatrixType> void nomalloc(const MatrixType& m)
|
||||
VERIFY_IS_APPROX((m1*m1.transpose())*m2, m1*(m1.transpose()*m2));
|
||||
}
|
||||
|
||||
void test_nomalloc()
|
||||
void test_eigen2_nomalloc()
|
||||
{
|
||||
// check that our operator new is indeed called:
|
||||
VERIFY_RAISES_ASSERT(MatrixXd dummy = MatrixXd::Random(3,3));
|
||||
CALL_SUBTEST( nomalloc(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( nomalloc(Matrix4d()) );
|
||||
CALL_SUBTEST( nomalloc(Matrix<float,32,32>()) );
|
||||
CALL_SUBTEST_1( nomalloc(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( nomalloc(Matrix4d()) );
|
||||
CALL_SUBTEST_3( nomalloc(Matrix<float,32,32>()) );
|
||||
}
|
@ -136,12 +136,12 @@ template<typename Scalar> void packetmath()
|
||||
VERIFY(areApprox(ref, data2, PacketSize) && "ei_preduxp");
|
||||
}
|
||||
|
||||
void test_packetmath()
|
||||
void test_eigen2_packetmath()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( packetmath<float>() );
|
||||
CALL_SUBTEST( packetmath<double>() );
|
||||
CALL_SUBTEST( packetmath<int>() );
|
||||
CALL_SUBTEST( packetmath<std::complex<float> >() );
|
||||
CALL_SUBTEST_1( packetmath<float>() );
|
||||
CALL_SUBTEST_2( packetmath<double>() );
|
||||
CALL_SUBTEST_3( packetmath<int>() );
|
||||
CALL_SUBTEST_4( packetmath<std::complex<float> >() );
|
||||
}
|
||||
}
|
@ -66,12 +66,12 @@ template<typename LineType> void parametrizedline(const LineType& _line)
|
||||
VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),l0);
|
||||
}
|
||||
|
||||
void test_parametrizedline()
|
||||
void test_eigen2_parametrizedline()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( parametrizedline(ParametrizedLine<float,2>()) );
|
||||
CALL_SUBTEST( parametrizedline(ParametrizedLine<float,3>()) );
|
||||
CALL_SUBTEST( parametrizedline(ParametrizedLine<double,4>()) );
|
||||
CALL_SUBTEST( parametrizedline(ParametrizedLine<std::complex<double>,5>()) );
|
||||
CALL_SUBTEST_1( parametrizedline(ParametrizedLine<float,2>()) );
|
||||
CALL_SUBTEST_2( parametrizedline(ParametrizedLine<float,3>()) );
|
||||
CALL_SUBTEST_3( parametrizedline(ParametrizedLine<double,4>()) );
|
||||
CALL_SUBTEST_4( parametrizedline(ParametrizedLine<std::complex<double>,5>()) );
|
||||
}
|
||||
}
|
@ -86,14 +86,14 @@ template<typename MatrixType> void inverse_general_4x4(int repeat)
|
||||
VERIFY(error_max < (NumTraits<Scalar>::IsComplex ? 64.0 : 20.0));
|
||||
}
|
||||
|
||||
void test_prec_inverse_4x4()
|
||||
void test_eigen2_prec_inverse_4x4()
|
||||
{
|
||||
CALL_SUBTEST((inverse_permutation_4x4<Matrix4f>()));
|
||||
CALL_SUBTEST(( inverse_general_4x4<Matrix4f>(200000 * g_repeat) ));
|
||||
CALL_SUBTEST_1((inverse_permutation_4x4<Matrix4f>()));
|
||||
CALL_SUBTEST_1(( inverse_general_4x4<Matrix4f>(200000 * g_repeat) ));
|
||||
|
||||
CALL_SUBTEST((inverse_permutation_4x4<Matrix<double,4,4,RowMajor> >()));
|
||||
CALL_SUBTEST(( inverse_general_4x4<Matrix<double,4,4,RowMajor> >(200000 * g_repeat) ));
|
||||
CALL_SUBTEST_2((inverse_permutation_4x4<Matrix<double,4,4,RowMajor> >()));
|
||||
CALL_SUBTEST_2(( inverse_general_4x4<Matrix<double,4,4,RowMajor> >(200000 * g_repeat) ));
|
||||
|
||||
CALL_SUBTEST((inverse_permutation_4x4<Matrix4cf>()));
|
||||
CALL_SUBTEST((inverse_general_4x4<Matrix4cf>(50000 * g_repeat)));
|
||||
CALL_SUBTEST_3((inverse_permutation_4x4<Matrix4cf>()));
|
||||
CALL_SUBTEST_3((inverse_general_4x4<Matrix4cf>(50000 * g_repeat)));
|
||||
}
|
@ -24,16 +24,17 @@
|
||||
|
||||
#include "product.h"
|
||||
|
||||
void test_product_large()
|
||||
void test_eigen2_product_large()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) );
|
||||
CALL_SUBTEST( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST_1( product(MatrixXf(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST_2( product(MatrixXd(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST_3( product(MatrixXi(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
CALL_SUBTEST_4( product(MatrixXcf(ei_random<int>(1,50), ei_random<int>(1,50))) );
|
||||
CALL_SUBTEST_5( product(Matrix<float,Dynamic,Dynamic,RowMajor>(ei_random<int>(1,320), ei_random<int>(1,320))) );
|
||||
}
|
||||
|
||||
#ifdef EIGEN_TEST_PART_6
|
||||
{
|
||||
// test a specific issue in DiagonalProduct
|
||||
int N = 1000000;
|
||||
@ -55,4 +56,5 @@ void test_product_large()
|
||||
MatrixXf result = mat1.row(2)*mat2.transpose();
|
||||
VERIFY_IS_APPROX(result, (mat1.row(2)*mat2.transpose()).eval());
|
||||
}
|
||||
#endif
|
||||
}
|
@ -25,13 +25,13 @@
|
||||
#define EIGEN_NO_STATIC_ASSERT
|
||||
#include "product.h"
|
||||
|
||||
void test_product_small()
|
||||
void test_eigen2_product_small()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( product(Matrix<float, 3, 2>()) );
|
||||
CALL_SUBTEST( product(Matrix<int, 3, 5>()) );
|
||||
CALL_SUBTEST( product(Matrix3d()) );
|
||||
CALL_SUBTEST( product(Matrix4d()) );
|
||||
CALL_SUBTEST( product(Matrix4f()) );
|
||||
CALL_SUBTEST_1( product(Matrix<float, 3, 2>()) );
|
||||
CALL_SUBTEST_2( product(Matrix<int, 3, 5>()) );
|
||||
CALL_SUBTEST_3( product(Matrix3d()) );
|
||||
CALL_SUBTEST_4( product(Matrix4d()) );
|
||||
CALL_SUBTEST_5( product(Matrix4f()) );
|
||||
}
|
||||
}
|
@ -42,6 +42,7 @@ template<typename MatrixType> void qr(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(a, qrOfA.matrixQ() * qrOfA.matrixR());
|
||||
VERIFY_IS_NOT_APPROX(a+MatrixType::Identity(rows, cols), qrOfA.matrixQ() * qrOfA.matrixR());
|
||||
|
||||
#if 0 // eigenvalues module not yet ready
|
||||
SquareMatrixType b = a.adjoint() * a;
|
||||
|
||||
// check tridiagonalization
|
||||
@ -55,31 +56,29 @@ template<typename MatrixType> void qr(const MatrixType& m)
|
||||
b = SquareMatrixType::Random(cols,cols);
|
||||
hess.compute(b);
|
||||
VERIFY_IS_APPROX(b, hess.matrixQ() * hess.matrixH() * hess.matrixQ().adjoint());
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_qr()
|
||||
void test_eigen2_qr()
|
||||
{
|
||||
for(int i = 0; i < 1; i++) {
|
||||
CALL_SUBTEST( qr(Matrix2f()) );
|
||||
CALL_SUBTEST( qr(Matrix4d()) );
|
||||
CALL_SUBTEST( qr(MatrixXf(12,8)) );
|
||||
CALL_SUBTEST( qr(MatrixXcd(5,5)) );
|
||||
CALL_SUBTEST( qr(MatrixXcd(7,3)) );
|
||||
CALL_SUBTEST_1( qr(Matrix2f()) );
|
||||
CALL_SUBTEST_2( qr(Matrix4d()) );
|
||||
CALL_SUBTEST_3( qr(MatrixXf(12,8)) );
|
||||
CALL_SUBTEST_4( qr(MatrixXcd(5,5)) );
|
||||
CALL_SUBTEST_4( qr(MatrixXcd(7,3)) );
|
||||
}
|
||||
|
||||
#ifdef EIGEN_TEST_PART_5
|
||||
// small isFullRank test
|
||||
{
|
||||
Matrix3d mat;
|
||||
mat << 1, 45, 1, 2, 2, 2, 1, 2, 3;
|
||||
VERIFY(mat.qr().isFullRank());
|
||||
mat << 1, 1, 1, 2, 2, 2, 1, 2, 3;
|
||||
VERIFY(!mat.qr().isFullRank());
|
||||
}
|
||||
{
|
||||
MatrixXf m = MatrixXf::Zero(10,10);
|
||||
VectorXf b = VectorXf::Zero(10);
|
||||
VectorXf x = VectorXf::Random(10);
|
||||
VERIFY(m.qr().solve(b,&x));
|
||||
VERIFY(x.isZero());
|
||||
//always returns true in eigen2support
|
||||
//VERIFY(!mat.qr().isFullRank());
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
@ -142,32 +142,32 @@ void check_qtvector_quaternion(const QuaternionType&)
|
||||
}
|
||||
}
|
||||
|
||||
void test_qtvector()
|
||||
void test_eigen2_qtvector()
|
||||
{
|
||||
// some non vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_qtvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST(check_qtvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST(check_qtvector_matrix(Matrix3d()));
|
||||
CALL_SUBTEST_1(check_qtvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST_1(check_qtvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST_1(check_qtvector_matrix(Matrix3d()));
|
||||
|
||||
// some vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_qtvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST(check_qtvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST(check_qtvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST(check_qtvector_matrix(Matrix4d()));
|
||||
CALL_SUBTEST_2(check_qtvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST_2(check_qtvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST_2(check_qtvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST_2(check_qtvector_matrix(Matrix4d()));
|
||||
|
||||
// some dynamic sizes
|
||||
CALL_SUBTEST(check_qtvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST(check_qtvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST(check_qtvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST(check_qtvector_matrix(MatrixXcf(10,10)));
|
||||
CALL_SUBTEST_3(check_qtvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST_3(check_qtvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST_3(check_qtvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST_3(check_qtvector_matrix(MatrixXcf(10,10)));
|
||||
|
||||
// some Transform
|
||||
CALL_SUBTEST(check_qtvector_transform(Transform2f()));
|
||||
CALL_SUBTEST(check_qtvector_transform(Transform3f()));
|
||||
CALL_SUBTEST(check_qtvector_transform(Transform3d()));
|
||||
//CALL_SUBTEST(check_qtvector_transform(Transform4d()));
|
||||
CALL_SUBTEST_4(check_qtvector_transform(Transform2f()));
|
||||
CALL_SUBTEST_4(check_qtvector_transform(Transform3f()));
|
||||
CALL_SUBTEST_4(check_qtvector_transform(Transform3d()));
|
||||
//CALL_SUBTEST_4(check_qtvector_transform(Transform4d()));
|
||||
|
||||
// some Quaternion
|
||||
CALL_SUBTEST(check_qtvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST(check_qtvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST_5(check_qtvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST_5(check_qtvector_quaternion(Quaternionf()));
|
||||
}
|
@ -91,10 +91,11 @@ void check_fitHyperplane(int numPoints,
|
||||
VERIFY(ei_abs(error) < ei_abs(tolerance));
|
||||
}
|
||||
|
||||
void test_regression()
|
||||
void test_eigen2_regression()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++)
|
||||
{
|
||||
#ifdef EIGEN_TEST_PART_1
|
||||
{
|
||||
Vector2f points2f [1000];
|
||||
Vector2f *points2f_ptrs [1000];
|
||||
@ -108,7 +109,8 @@ void test_regression()
|
||||
CALL_SUBTEST(check_linearRegression(100, points2f_ptrs, coeffs2f, 0.01f));
|
||||
CALL_SUBTEST(check_linearRegression(1000, points2f_ptrs, coeffs2f, 0.002f));
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef EIGEN_TEST_PART_2
|
||||
{
|
||||
Vector2f points2f [1000];
|
||||
Vector2f *points2f_ptrs [1000];
|
||||
@ -119,7 +121,8 @@ void test_regression()
|
||||
CALL_SUBTEST(check_fitHyperplane(100, points2f_ptrs, coeffs3f, 0.01f));
|
||||
CALL_SUBTEST(check_fitHyperplane(1000, points2f_ptrs, coeffs3f, 0.002f));
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef EIGEN_TEST_PART_3
|
||||
{
|
||||
Vector4d points4d [1000];
|
||||
Vector4d *points4d_ptrs [1000];
|
||||
@ -130,7 +133,8 @@ void test_regression()
|
||||
CALL_SUBTEST(check_fitHyperplane(100, points4d_ptrs, coeffs5d, 0.01));
|
||||
CALL_SUBTEST(check_fitHyperplane(1000, points4d_ptrs, coeffs5d, 0.002));
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef EIGEN_TEST_PART_4
|
||||
{
|
||||
VectorXcd *points11cd_ptrs[1000];
|
||||
for(int i = 0; i < 1000; i++) points11cd_ptrs[i] = new VectorXcd(11);
|
||||
@ -141,5 +145,6 @@ void test_regression()
|
||||
delete coeffs12cd;
|
||||
for(int i = 0; i < 1000; i++) delete points11cd_ptrs[i];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ template<typename MatrixType> void verifySizeOf(const MatrixType&)
|
||||
VERIFY(sizeof(MatrixType)==sizeof(Scalar*) + 2 * sizeof(typename MatrixType::Index));
|
||||
}
|
||||
|
||||
void test_sizeof()
|
||||
void test_eigen2_sizeof()
|
||||
{
|
||||
CALL_SUBTEST( verifySizeOf(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( verifySizeOf(Matrix4d()) );
|
@ -47,7 +47,7 @@ template<typename Scalar> void smallVectors()
|
||||
VERIFY_IS_APPROX(x4, v4.w());
|
||||
}
|
||||
|
||||
void test_smallvectors()
|
||||
void test_eigen2_smallvectors()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( smallVectors<int>() );
|
@ -320,13 +320,13 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
}
|
||||
}
|
||||
|
||||
void test_sparse_basic()
|
||||
void test_eigen2_sparse_basic()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( sparse_basic(SparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST( sparse_basic(SparseMatrix<std::complex<double> >(16, 16)) );
|
||||
CALL_SUBTEST( sparse_basic(SparseMatrix<double>(33, 33)) );
|
||||
CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST_2( sparse_basic(SparseMatrix<std::complex<double> >(16, 16)) );
|
||||
CALL_SUBTEST_1( sparse_basic(SparseMatrix<double>(33, 33)) );
|
||||
|
||||
CALL_SUBTEST( sparse_basic(DynamicSparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST_3( sparse_basic(DynamicSparseMatrix<double>(8, 8)) );
|
||||
}
|
||||
}
|
@ -118,13 +118,13 @@ template<typename SparseMatrixType> void sparse_product(const SparseMatrixType&
|
||||
|
||||
}
|
||||
|
||||
void test_sparse_product()
|
||||
void test_eigen2_sparse_product()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( sparse_product(SparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST( sparse_product(SparseMatrix<std::complex<double> >(16, 16)) );
|
||||
CALL_SUBTEST( sparse_product(SparseMatrix<double>(33, 33)) );
|
||||
CALL_SUBTEST_1( sparse_product(SparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST_2( sparse_product(SparseMatrix<std::complex<double> >(16, 16)) );
|
||||
CALL_SUBTEST_1( sparse_product(SparseMatrix<double>(33, 33)) );
|
||||
|
||||
CALL_SUBTEST( sparse_product(DynamicSparseMatrix<double>(8, 8)) );
|
||||
CALL_SUBTEST_3( sparse_product(DynamicSparseMatrix<double>(8, 8)) );
|
||||
}
|
||||
}
|
@ -205,11 +205,11 @@ template<typename Scalar> void sparse_solvers(int rows, int cols)
|
||||
|
||||
}
|
||||
|
||||
void test_sparse_solvers()
|
||||
void test_eigen2_sparse_solvers()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( sparse_solvers<double>(8, 8) );
|
||||
CALL_SUBTEST( sparse_solvers<std::complex<double> >(16, 16) );
|
||||
CALL_SUBTEST( sparse_solvers<double>(101, 101) );
|
||||
CALL_SUBTEST_1( sparse_solvers<double>(8, 8) );
|
||||
CALL_SUBTEST_2( sparse_solvers<std::complex<double> >(16, 16) );
|
||||
CALL_SUBTEST_1( sparse_solvers<double>(101, 101) );
|
||||
}
|
||||
}
|
@ -88,12 +88,12 @@ template<typename Scalar> void sparse_vector(int rows, int cols)
|
||||
|
||||
}
|
||||
|
||||
void test_sparse_vector()
|
||||
void test_eigen2_sparse_vector()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( sparse_vector<double>(8, 8) );
|
||||
CALL_SUBTEST( sparse_vector<std::complex<double> >(16, 16) );
|
||||
CALL_SUBTEST( sparse_vector<double>(299, 535) );
|
||||
CALL_SUBTEST_1( sparse_vector<double>(8, 8) );
|
||||
CALL_SUBTEST_2( sparse_vector<std::complex<double> >(16, 16) );
|
||||
CALL_SUBTEST_1( sparse_vector<double>(299, 535) );
|
||||
}
|
||||
}
|
||||
|
@ -132,32 +132,32 @@ void check_stdvector_quaternion(const QuaternionType&)
|
||||
}
|
||||
}
|
||||
|
||||
void test_stdvector()
|
||||
void test_eigen2_stdvector()
|
||||
{
|
||||
// some non vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix3d()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Vector2f()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Matrix3f()));
|
||||
CALL_SUBTEST_1(check_stdvector_matrix(Matrix3d()));
|
||||
|
||||
// some vectorizable fixed sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST(check_stdvector_matrix(Matrix4d()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix2f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Vector4f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix4f()));
|
||||
CALL_SUBTEST_2(check_stdvector_matrix(Matrix4d()));
|
||||
|
||||
// some dynamic sizes
|
||||
CALL_SUBTEST(check_stdvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST(check_stdvector_matrix(MatrixXcf(10,10)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(MatrixXd(1,1)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(VectorXd(20)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(RowVectorXf(20)));
|
||||
CALL_SUBTEST_3(check_stdvector_matrix(MatrixXcf(10,10)));
|
||||
|
||||
// some Transform
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform2f()));
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform3f()));
|
||||
CALL_SUBTEST(check_stdvector_transform(Transform3d()));
|
||||
//CALL_SUBTEST(check_stdvector_transform(Transform4d()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform2f()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform3f()));
|
||||
CALL_SUBTEST_4(check_stdvector_transform(Transform3d()));
|
||||
//CALL_SUBTEST_4(check_stdvector_transform(Transform4d()));
|
||||
|
||||
// some Quaternion
|
||||
CALL_SUBTEST(check_stdvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST(check_stdvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
|
||||
CALL_SUBTEST_5(check_stdvector_quaternion(Quaternionf()));
|
||||
}
|
@ -150,14 +150,14 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
VERIFY(ei_real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols));
|
||||
}
|
||||
|
||||
void test_submatrices()
|
||||
void test_eigen2_submatrices()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( submatrices(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( submatrices(Matrix4d()) );
|
||||
CALL_SUBTEST( submatrices(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( submatrices(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST( submatrices(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST( submatrices(MatrixXf(20, 20)) );
|
||||
CALL_SUBTEST_1( submatrices(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( submatrices(Matrix4d()) );
|
||||
CALL_SUBTEST_3( submatrices(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_4( submatrices(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_5( submatrices(MatrixXcd(20, 20)) );
|
||||
CALL_SUBTEST_6( submatrices(MatrixXf(20, 20)) );
|
||||
}
|
||||
}
|
@ -68,19 +68,19 @@ template<typename VectorType> void vectorSum(const VectorType& w)
|
||||
}
|
||||
}
|
||||
|
||||
void test_sum()
|
||||
void test_eigen2_sum()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( matrixSum(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( matrixSum(Matrix2f()) );
|
||||
CALL_SUBTEST( matrixSum(Matrix4d()) );
|
||||
CALL_SUBTEST( matrixSum(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST( matrixSum(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST( matrixSum(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_1( matrixSum(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( matrixSum(Matrix2f()) );
|
||||
CALL_SUBTEST_3( matrixSum(Matrix4d()) );
|
||||
CALL_SUBTEST_4( matrixSum(MatrixXcf(3, 3)) );
|
||||
CALL_SUBTEST_5( matrixSum(MatrixXf(8, 12)) );
|
||||
CALL_SUBTEST_6( matrixSum(MatrixXi(8, 12)) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( vectorSum(VectorXf(5)) );
|
||||
CALL_SUBTEST( vectorSum(VectorXd(10)) );
|
||||
CALL_SUBTEST( vectorSum(VectorXf(33)) );
|
||||
CALL_SUBTEST_5( vectorSum(VectorXf(5)) );
|
||||
CALL_SUBTEST_7( vectorSum(VectorXd(10)) );
|
||||
CALL_SUBTEST_5( vectorSum(VectorXf(33)) );
|
||||
}
|
||||
}
|
@ -85,13 +85,13 @@ template<typename MatrixType> void svd(const MatrixType& m)
|
||||
}
|
||||
}
|
||||
|
||||
void test_svd()
|
||||
void test_eigen2_svd()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( svd(Matrix3f()) );
|
||||
CALL_SUBTEST( svd(Matrix4d()) );
|
||||
CALL_SUBTEST( svd(MatrixXf(7,7)) );
|
||||
CALL_SUBTEST( svd(MatrixXd(14,7)) );
|
||||
CALL_SUBTEST_1( svd(Matrix3f()) );
|
||||
CALL_SUBTEST_2( svd(Matrix4d()) );
|
||||
CALL_SUBTEST_3( svd(MatrixXf(7,7)) );
|
||||
CALL_SUBTEST_4( svd(MatrixXd(14,7)) );
|
||||
// complex are not implemented yet
|
||||
// CALL_SUBTEST( svd(MatrixXcd(6,6)) );
|
||||
// CALL_SUBTEST( svd(MatrixXcf(3,3)) );
|
@ -89,10 +89,10 @@ template<typename MatrixType> void swap(const MatrixType& m)
|
||||
VERIFY_RAISES_ASSERT(m1.row(0).swap(m1));
|
||||
}
|
||||
|
||||
void test_swap()
|
||||
void test_eigen2_swap()
|
||||
{
|
||||
CALL_SUBTEST( swap(Matrix3f()) ); // fixed size, no vectorization
|
||||
CALL_SUBTEST( swap(Matrix4d()) ); // fixed size, possible vectorization
|
||||
CALL_SUBTEST( swap(MatrixXd(3,3)) ); // dyn size, no vectorization
|
||||
CALL_SUBTEST( swap(MatrixXf(30,30)) ); // dyn size, possible vectorization
|
||||
CALL_SUBTEST( swap_1(Matrix3f()) ); // fixed size, no vectorization
|
||||
CALL_SUBTEST( swap_2(Matrix4d()) ); // fixed size, possible vectorization
|
||||
CALL_SUBTEST( swap_3(MatrixXd(3,3)) ); // dyn size, no vectorization
|
||||
CALL_SUBTEST( swap_4(MatrixXf(30,30)) ); // dyn size, possible vectorization
|
||||
}
|
@ -124,15 +124,50 @@ template<typename MatrixType> void triangular(const MatrixType& m)
|
||||
|
||||
}
|
||||
|
||||
void test_triangular()
|
||||
void selfadjoint()
|
||||
{
|
||||
Matrix2i m;
|
||||
m << 1, 2,
|
||||
3, 4;
|
||||
|
||||
Matrix2i m1 = Matrix2i::Zero();
|
||||
m1.part<SelfAdjoint>() = m;
|
||||
Matrix2i ref1;
|
||||
ref1 << 1, 2,
|
||||
2, 4;
|
||||
VERIFY(m1 == ref1);
|
||||
|
||||
Matrix2i m2 = Matrix2i::Zero();
|
||||
m2.part<SelfAdjoint>() = m.part<UpperTriangular>();
|
||||
Matrix2i ref2;
|
||||
ref2 << 1, 2,
|
||||
2, 4;
|
||||
VERIFY(m2 == ref2);
|
||||
|
||||
Matrix2i m3 = Matrix2i::Zero();
|
||||
m3.part<SelfAdjoint>() = m.part<LowerTriangular>();
|
||||
Matrix2i ref3;
|
||||
ref3 << 1, 0,
|
||||
0, 4;
|
||||
VERIFY(m3 == ref3);
|
||||
|
||||
// example inspired from bug 159
|
||||
int array[] = {1, 2, 3, 4};
|
||||
Matrix2i::Map(array).part<SelfAdjoint>() = Matrix2i::Random().part<LowerTriangular>();
|
||||
|
||||
std::cout << "hello\n" << array << std::endl;
|
||||
}
|
||||
|
||||
void test_eigen2_triangular()
|
||||
{
|
||||
CALL_SUBTEST_8( selfadjoint() );
|
||||
for(int i = 0; i < g_repeat ; i++) {
|
||||
CALL_SUBTEST( triangular(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( triangular(Matrix<float, 2, 2>()) );
|
||||
CALL_SUBTEST( triangular(Matrix3d()) );
|
||||
CALL_SUBTEST( triangular(MatrixXcf(4, 4)) );
|
||||
CALL_SUBTEST( triangular(Matrix<std::complex<float>,8, 8>()) );
|
||||
CALL_SUBTEST( triangular(MatrixXd(17,17)) );
|
||||
CALL_SUBTEST( triangular(Matrix<float,Dynamic,Dynamic,RowMajor>(5, 5)) );
|
||||
CALL_SUBTEST_1( triangular(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( triangular(Matrix<float, 2, 2>()) );
|
||||
CALL_SUBTEST_3( triangular(Matrix3d()) );
|
||||
CALL_SUBTEST_4( triangular(MatrixXcf(4, 4)) );
|
||||
CALL_SUBTEST_5( triangular(Matrix<std::complex<float>,8, 8>()) );
|
||||
CALL_SUBTEST_6( triangular(MatrixXd(17,17)) );
|
||||
CALL_SUBTEST_7( triangular(Matrix<float,Dynamic,Dynamic,RowMajor>(5, 5)) );
|
||||
}
|
||||
}
|
@ -125,7 +125,7 @@ void unalignedassert()
|
||||
#endif
|
||||
}
|
||||
|
||||
void test_unalignedassert()
|
||||
void test_eigen2_unalignedassert()
|
||||
{
|
||||
CALL_SUBTEST(unalignedassert());
|
||||
}
|
@ -112,20 +112,20 @@ template<typename VectorType> void vectorVisitor(const VectorType& w)
|
||||
VERIFY_IS_APPROX(maxc, v.maxCoeff());
|
||||
}
|
||||
|
||||
void test_visitor()
|
||||
void test_eigen2_visitor()
|
||||
{
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( matrixVisitor(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST( matrixVisitor(Matrix2f()) );
|
||||
CALL_SUBTEST( matrixVisitor(Matrix4d()) );
|
||||
CALL_SUBTEST( matrixVisitor(MatrixXd(8, 12)) );
|
||||
CALL_SUBTEST( matrixVisitor(Matrix<double,Dynamic,Dynamic,RowMajor>(20, 20)) );
|
||||
CALL_SUBTEST( matrixVisitor(MatrixXi(8, 12)) );
|
||||
CALL_SUBTEST_1( matrixVisitor(Matrix<float, 1, 1>()) );
|
||||
CALL_SUBTEST_2( matrixVisitor(Matrix2f()) );
|
||||
CALL_SUBTEST_3( matrixVisitor(Matrix4d()) );
|
||||
CALL_SUBTEST_4( matrixVisitor(MatrixXd(8, 12)) );
|
||||
CALL_SUBTEST_5( matrixVisitor(Matrix<double,Dynamic,Dynamic,RowMajor>(20, 20)) );
|
||||
CALL_SUBTEST_6( matrixVisitor(MatrixXi(8, 12)) );
|
||||
}
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
CALL_SUBTEST( vectorVisitor(Vector4f()) );
|
||||
CALL_SUBTEST( vectorVisitor(VectorXd(10)) );
|
||||
CALL_SUBTEST( vectorVisitor(RowVectorXd(10)) );
|
||||
CALL_SUBTEST( vectorVisitor(VectorXf(33)) );
|
||||
CALL_SUBTEST_7( vectorVisitor(Vector4f()) );
|
||||
CALL_SUBTEST_4( vectorVisitor(VectorXd(10)) );
|
||||
CALL_SUBTEST_4( vectorVisitor(RowVectorXd(10)) );
|
||||
CALL_SUBTEST_8( vectorVisitor(VectorXf(33)) );
|
||||
}
|
||||
}
|
@ -240,6 +240,104 @@ void EI_PP_CAT(test_,EIGEN_TEST_FUNC)();
|
||||
|
||||
using namespace Eigen;
|
||||
|
||||
#ifdef EIGEN_TEST_PART_1
|
||||
#define CALL_SUBTEST_1(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_1(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_2
|
||||
#define CALL_SUBTEST_2(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_2(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_3
|
||||
#define CALL_SUBTEST_3(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_3(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_4
|
||||
#define CALL_SUBTEST_4(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_4(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_5
|
||||
#define CALL_SUBTEST_5(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_5(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_6
|
||||
#define CALL_SUBTEST_6(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_6(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_7
|
||||
#define CALL_SUBTEST_7(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_7(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_8
|
||||
#define CALL_SUBTEST_8(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_8(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_9
|
||||
#define CALL_SUBTEST_9(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_9(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_10
|
||||
#define CALL_SUBTEST_10(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_10(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_11
|
||||
#define CALL_SUBTEST_11(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_11(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_12
|
||||
#define CALL_SUBTEST_12(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_12(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_13
|
||||
#define CALL_SUBTEST_13(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_13(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_14
|
||||
#define CALL_SUBTEST_14(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_14(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_15
|
||||
#define CALL_SUBTEST_15(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_15(FUNC)
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_TEST_PART_16
|
||||
#define CALL_SUBTEST_16(FUNC) CALL_SUBTEST(FUNC)
|
||||
#else
|
||||
#define CALL_SUBTEST_16(FUNC)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool has_set_repeat = false;
|
||||
|
@ -52,6 +52,11 @@ template<typename MatrixType> void selfadjoint(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m3, m3.adjoint());
|
||||
}
|
||||
|
||||
void bug_159()
|
||||
{
|
||||
Matrix3d m = Matrix3d::Random().selfadjointView<Lower>();
|
||||
}
|
||||
|
||||
void test_selfadjoint()
|
||||
{
|
||||
for(int i = 0; i < g_repeat ; i++)
|
||||
@ -64,4 +69,6 @@ void test_selfadjoint()
|
||||
CALL_SUBTEST_4( selfadjoint(MatrixXcd(s,s)) );
|
||||
CALL_SUBTEST_5( selfadjoint(Matrix<float,Dynamic,Dynamic,RowMajor>(s, s)) );
|
||||
}
|
||||
|
||||
CALL_SUBTEST_1( bug_159() );
|
||||
}
|
||||
|
@ -235,6 +235,11 @@ template<typename MatrixType> void triangular_rect(const MatrixType& m)
|
||||
VERIFY_IS_APPROX(m2,m3);
|
||||
}
|
||||
|
||||
void bug_159()
|
||||
{
|
||||
Matrix3d m = Matrix3d::Random().triangularView<Lower>();
|
||||
}
|
||||
|
||||
void test_triangular()
|
||||
{
|
||||
for(int i = 0; i < g_repeat ; i++)
|
||||
@ -255,4 +260,6 @@ void test_triangular()
|
||||
CALL_SUBTEST_5( triangular_rect(MatrixXcd(r, c)) );
|
||||
CALL_SUBTEST_6( triangular_rect(Matrix<float,Dynamic,Dynamic,RowMajor>(r, c)) );
|
||||
}
|
||||
|
||||
CALL_SUBTEST_1( bug_159() );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user