mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
merge with default branch
This commit is contained in:
@@ -56,7 +56,8 @@ struct ei_functor_traits<ei_scalar_add_op<Scalar> >
|
||||
*
|
||||
* \sa class CwiseUnaryOp, Cwise::sqrt()
|
||||
*/
|
||||
template<typename Scalar> struct ei_scalar_sqrt_op EIGEN_EMPTY_STRUCT {
|
||||
template<typename Scalar> struct ei_scalar_sqrt_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_sqrt_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return ei_sqrt(a); }
|
||||
typedef typename ei_packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return ei_psqrt(a); }
|
||||
@@ -77,7 +78,8 @@ struct ei_functor_traits<ei_scalar_sqrt_op<Scalar> >
|
||||
*
|
||||
* \sa class CwiseUnaryOp, Cwise::cos()
|
||||
*/
|
||||
template<typename Scalar> struct ei_scalar_cos_op EIGEN_EMPTY_STRUCT {
|
||||
template<typename Scalar> struct ei_scalar_cos_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_cos_op)
|
||||
inline Scalar operator() (const Scalar& a) const { return ei_cos(a); }
|
||||
typedef typename ei_packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return ei_pcos(a); }
|
||||
@@ -87,7 +89,7 @@ struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = ei_packet_traits<Scalar>::HasCos && EIGEN_FAST_MATH
|
||||
PacketAccess = ei_packet_traits<Scalar>::HasCos
|
||||
};
|
||||
};
|
||||
|
||||
@@ -99,7 +101,8 @@ struct ei_functor_traits<ei_scalar_cos_op<Scalar> >
|
||||
*
|
||||
* \sa class CwiseUnaryOp, Cwise::sin()
|
||||
*/
|
||||
template<typename Scalar> struct ei_scalar_sin_op EIGEN_EMPTY_STRUCT {
|
||||
template<typename Scalar> struct ei_scalar_sin_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_sin_op)
|
||||
inline const Scalar operator() (const Scalar& a) const { return ei_sin(a); }
|
||||
typedef typename ei_packet_traits<Scalar>::type Packet;
|
||||
inline Packet packetOp(const Packet& a) const { return ei_psin(a); }
|
||||
@@ -109,7 +112,7 @@ struct ei_functor_traits<ei_scalar_sin_op<Scalar> >
|
||||
{
|
||||
enum {
|
||||
Cost = 5 * NumTraits<Scalar>::MulCost,
|
||||
PacketAccess = ei_packet_traits<Scalar>::HasSin && EIGEN_FAST_MATH
|
||||
PacketAccess = ei_packet_traits<Scalar>::HasSin
|
||||
};
|
||||
};
|
||||
|
||||
@@ -143,6 +146,7 @@ struct ei_functor_traits<ei_scalar_pow_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar>
|
||||
struct ei_scalar_inverse_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_inverse_op)
|
||||
inline Scalar operator() (const Scalar& a) const { return Scalar(1)/a; }
|
||||
template<typename PacketScalar>
|
||||
inline const PacketScalar packetOp(const PacketScalar& a) const
|
||||
@@ -162,6 +166,7 @@ struct ei_functor_traits<ei_scalar_inverse_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar>
|
||||
struct ei_scalar_square_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_square_op)
|
||||
inline Scalar operator() (const Scalar& a) const { return a*a; }
|
||||
template<typename PacketScalar>
|
||||
inline const PacketScalar packetOp(const PacketScalar& a) const
|
||||
@@ -181,6 +186,7 @@ struct ei_functor_traits<ei_scalar_square_op<Scalar> >
|
||||
*/
|
||||
template<typename Scalar>
|
||||
struct ei_scalar_cube_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_cube_op)
|
||||
inline Scalar operator() (const Scalar& a) const { return a*a*a; }
|
||||
template<typename PacketScalar>
|
||||
inline const PacketScalar packetOp(const PacketScalar& a) const
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
#ifndef EIGEN_RANDOM_H
|
||||
#define EIGEN_RANDOM_H
|
||||
|
||||
template<typename Scalar> struct ei_scalar_random_op EIGEN_EMPTY_STRUCT {
|
||||
inline ei_scalar_random_op(void) {}
|
||||
template<typename Scalar> struct ei_scalar_random_op {
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_scalar_random_op)
|
||||
inline const Scalar operator() (int, int) const { return ei_random<Scalar>(); }
|
||||
};
|
||||
template<typename Scalar>
|
||||
|
||||
@@ -97,9 +97,6 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
|
||||
const typename MatrixType::Nested m_matrix;
|
||||
const ei_int_if_dynamic<RowFactor> m_rowFactor;
|
||||
const ei_int_if_dynamic<ColFactor> m_colFactor;
|
||||
|
||||
private:
|
||||
Replicate& operator=(const Replicate&);
|
||||
};
|
||||
|
||||
/** \nonstableyet
|
||||
|
||||
@@ -134,11 +134,11 @@ DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename ThenDerived>
|
||||
inline const Select<Derived,ThenDerived, NestByValue<typename ThenDerived::ConstantReturnType> >
|
||||
inline const Select<Derived,ThenDerived, typename ThenDerived::ConstantReturnType>
|
||||
DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
|
||||
typename ThenDerived::Scalar elseScalar) const
|
||||
{
|
||||
return Select<Derived,ThenDerived,NestByValue<typename ThenDerived::ConstantReturnType> >(
|
||||
return Select<Derived,ThenDerived,typename ThenDerived::ConstantReturnType>(
|
||||
derived(), thenMatrix.derived(), ThenDerived::Constant(rows(),cols(),elseScalar));
|
||||
}
|
||||
|
||||
@@ -151,11 +151,11 @@ DenseBase<Derived>::select(const DenseBase<ThenDerived>& thenMatrix,
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename ElseDerived>
|
||||
inline const Select<Derived, NestByValue<typename ElseDerived::ConstantReturnType>, ElseDerived >
|
||||
inline const Select<Derived, typename ElseDerived::ConstantReturnType, ElseDerived >
|
||||
DenseBase<Derived>::select(typename ElseDerived::Scalar thenScalar,
|
||||
const DenseBase<ElseDerived>& elseMatrix) const
|
||||
{
|
||||
return Select<Derived,NestByValue<typename ElseDerived::ConstantReturnType>,ElseDerived>(
|
||||
return Select<Derived,typename ElseDerived::ConstantReturnType,ElseDerived>(
|
||||
derived(), ElseDerived::Constant(rows(),cols(),thenScalar), elseMatrix.derived());
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,8 @@ class PartialReduxExpr : ei_no_assignment_operator,
|
||||
|
||||
#define EIGEN_MEMBER_FUNCTOR(MEMBER,COST) \
|
||||
template <typename ResultType> \
|
||||
struct ei_member_##MEMBER EIGEN_EMPTY_STRUCT { \
|
||||
struct ei_member_##MEMBER { \
|
||||
EIGEN_EMPTY_STRUCT_CTOR(ei_member_##MEMBER) \
|
||||
typedef ResultType result_type; \
|
||||
template<typename Scalar, int Size> struct Cost \
|
||||
{ enum { value = COST }; }; \
|
||||
@@ -124,6 +125,9 @@ class PartialReduxExpr : ei_no_assignment_operator,
|
||||
|
||||
EIGEN_MEMBER_FUNCTOR(squaredNorm, Size * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
EIGEN_MEMBER_FUNCTOR(norm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
EIGEN_MEMBER_FUNCTOR(stableNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
EIGEN_MEMBER_FUNCTOR(blueNorm, (Size+5) * NumTraits<Scalar>::MulCost + (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
EIGEN_MEMBER_FUNCTOR(hypotNorm, (Size-1) * ei_functor_traits<ei_scalar_hypot_op<Scalar> >::Cost );
|
||||
EIGEN_MEMBER_FUNCTOR(sum, (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
EIGEN_MEMBER_FUNCTOR(mean, (Size-1)*NumTraits<Scalar>::AddCost + NumTraits<Scalar>::MulCost);
|
||||
EIGEN_MEMBER_FUNCTOR(minCoeff, (Size-1)*NumTraits<Scalar>::AddCost);
|
||||
@@ -291,6 +295,33 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
const typename ReturnType<ei_member_norm>::Type norm() const
|
||||
{ return _expression(); }
|
||||
|
||||
|
||||
/** \returns a row (or column) vector expression of the norm
|
||||
* of each column (or row) of the referenced expression, using
|
||||
* blue's algorithm.
|
||||
*
|
||||
* \sa MatrixBase::blueNorm() */
|
||||
const typename ReturnType<ei_member_blueNorm>::Type blueNorm() const
|
||||
{ return _expression(); }
|
||||
|
||||
|
||||
/** \returns a row (or column) vector expression of the norm
|
||||
* of each column (or row) of the referenced expression, avoiding
|
||||
* underflow and overflow.
|
||||
*
|
||||
* \sa MatrixBase::stableNorm() */
|
||||
const typename ReturnType<ei_member_stableNorm>::Type stableNorm() const
|
||||
{ return _expression(); }
|
||||
|
||||
|
||||
/** \returns a row (or column) vector expression of the norm
|
||||
* of each column (or row) of the referenced expression, avoiding
|
||||
* underflow and overflow using a concatenation of hypot() calls.
|
||||
*
|
||||
* \sa MatrixBase::hypotNorm() */
|
||||
const typename ReturnType<ei_member_hypotNorm>::Type hypotNorm() const
|
||||
{ return _expression(); }
|
||||
|
||||
/** \returns a row (or column) vector expression of the sum
|
||||
* of each column (or row) of the referenced expression.
|
||||
*
|
||||
@@ -409,22 +440,22 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
template<typename OtherDerived>
|
||||
CwiseBinaryOp<ei_scalar_sum_op<Scalar>,
|
||||
ExpressionType,
|
||||
NestByValue<typename ExtendedType<OtherDerived>::Type> >
|
||||
typename ExtendedType<OtherDerived>::Type>
|
||||
operator+(const MatrixBase<OtherDerived>& other) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
|
||||
return m_matrix + extendedTo(other).nestByValue();
|
||||
return m_matrix + extendedTo(other);
|
||||
}
|
||||
|
||||
/** Returns the expression of the difference between each subvector of \c *this and the vector \a other */
|
||||
template<typename OtherDerived>
|
||||
CwiseBinaryOp<ei_scalar_difference_op<Scalar>,
|
||||
ExpressionType,
|
||||
NestByValue<typename ExtendedType<OtherDerived>::Type> >
|
||||
typename ExtendedType<OtherDerived>::Type>
|
||||
operator-(const MatrixBase<OtherDerived>& other) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(OtherDerived);
|
||||
return m_matrix - extendedTo(other).nestByValue();
|
||||
return m_matrix - extendedTo(other);
|
||||
}
|
||||
|
||||
/////////// Geometry module ///////////
|
||||
@@ -451,19 +482,16 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
|
||||
Direction==Horizontal ? 1 : int(ei_traits<ExpressionType>::ColsAtCompileTime)>
|
||||
HNormalized_Factors;
|
||||
typedef CwiseBinaryOp<ei_scalar_quotient_op<typename ei_traits<ExpressionType>::Scalar>,
|
||||
NestByValue<HNormalized_Block>,
|
||||
NestByValue<Replicate<NestByValue<HNormalized_Factors>,
|
||||
HNormalized_Block,
|
||||
Replicate<HNormalized_Factors,
|
||||
Direction==Vertical ? HNormalized_SizeMinusOne : 1,
|
||||
Direction==Horizontal ? HNormalized_SizeMinusOne : 1> > >
|
||||
Direction==Horizontal ? HNormalized_SizeMinusOne : 1> >
|
||||
HNormalizedReturnType;
|
||||
|
||||
const HNormalizedReturnType hnormalized() const;
|
||||
|
||||
protected:
|
||||
ExpressionTypeNested m_matrix;
|
||||
|
||||
private:
|
||||
VectorwiseOp& operator=(const VectorwiseOp&);
|
||||
};
|
||||
|
||||
/** \array_module
|
||||
|
||||
Reference in New Issue
Block a user