mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +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
|
||||
{
|
||||
static const int RowsAtCompileTime = Derived::RowsAtCompileTime,
|
||||
ColsAtCompileTime = Derived::ColsAtCompileTime,
|
||||
SizeAtCompileTime
|
||||
= RowsAtCompileTime == EiDynamic || ColsAtCompileTime == EiDynamic
|
||||
? EiDynamic : RowsAtCompileTime * ColsAtCompileTime;
|
||||
static const bool IsVector = RowsAtCompileTime == 1 || ColsAtCompileTime == 1;
|
||||
ColsAtCompileTime = Derived::ColsAtCompileTime;
|
||||
|
||||
template<typename OtherDerived>
|
||||
void _copy_helper(const EiObject<Scalar, OtherDerived>& other);
|
||||
|
||||
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>::ConstRef ConstRef;
|
||||
|
||||
@ -91,6 +92,9 @@ template<typename Scalar, typename Derived> class EiObject
|
||||
template<typename OtherDerived>
|
||||
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>
|
||||
EiMatrixProduct<Derived, OtherDerived>
|
||||
lazyMul(const EiObject<Scalar, OtherDerived>& other) const EI_ALWAYS_INLINE;
|
||||
|
@ -83,7 +83,8 @@ EiScalarProduct<Derived> \
|
||||
operator/(const EiObject<Scalar, Derived>& matrix, \
|
||||
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> \
|
||||
|
Loading…
Reference in New Issue
Block a user