mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-08-14 04:35:57 +08:00
add norm() and norm2(); some polishing
This commit is contained in:
parent
ac6ff5efd6
commit
7f0a546a81
@ -29,16 +29,17 @@
|
|||||||
template<typename Scalar, typename Derived> class EiObject
|
template<typename Scalar, typename Derived> class EiObject
|
||||||
{
|
{
|
||||||
static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
|
static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
|
||||||
ColsAtCompileTime = Derived::ColsAtCompileTime,
|
ColsAtCompileTime = Derived::ColsAtCompileTime;
|
||||||
SizeAtCompileTime
|
|
||||||
= RowsAtCompileTime == EiDynamic || ColsAtCompileTime == EiDynamic
|
|
||||||
? EiDynamic : RowsAtCompileTime * ColsAtCompileTime;
|
|
||||||
static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1;
|
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
void _copy_helper(const EiObject<Scalar, OtherDerived>& other);
|
void _copy_helper(const EiObject<Scalar, OtherDerived>& other);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static const int SizeAtCompileTime
|
||||||
|
= RowsAtCompileTime == EiDynamic || ColsAtCompileTime == EiDynamic
|
||||||
|
? EiDynamic : RowsAtCompileTime * ColsAtCompileTime;
|
||||||
|
static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1;
|
||||||
|
|
||||||
typedef typename EiForwardDecl<Derived>::Ref Ref;
|
typedef typename EiForwardDecl<Derived>::Ref Ref;
|
||||||
typedef typename EiForwardDecl<Derived>::ConstRef ConstRef;
|
typedef typename EiForwardDecl<Derived>::ConstRef ConstRef;
|
||||||
|
|
||||||
@ -91,6 +92,9 @@ template<typename Scalar, typename Derived> class EiObject
|
|||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
Scalar dot(const OtherDerived& other) const;
|
Scalar dot(const OtherDerived& other) const;
|
||||||
|
|
||||||
|
Scalar norm2() const { assert(IsVector); return dot(*this); }
|
||||||
|
Scalar norm() const { assert(IsVector); return EiSqrt(dot(*this)); }
|
||||||
|
|
||||||
template<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
EiMatrixProduct<Derived, OtherDerived>
|
EiMatrixProduct<Derived, OtherDerived>
|
||||||
lazyMul(const EiObject<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE;
|
lazyMul(const EiObject<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE;
|
||||||
|
@ -83,7 +83,8 @@ EiScalarProduct<Derived> \
|
|||||||
operator/(const EiObject<Scalar, Derived>& matrix, \
|
operator/(const EiObject<Scalar, Derived>& matrix, \
|
||||||
OtherScalar scalar) \
|
OtherScalar scalar) \
|
||||||
{ \
|
{ \
|
||||||
return matrix * (static_cast<typename Derived::Scalar>(1) / scalar); \
|
assert(EiTraits<Scalar>::HasFloatingPoint); \
|
||||||
|
return matrix * (static_cast<Scalar>(1) / scalar); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
template<typename Scalar, typename Derived> \
|
template<typename Scalar, typename Derived> \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user