mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
norm2() renamed to squaredNorm(), kept as deprecated for now.
This commit is contained in:
@@ -248,10 +248,10 @@ struct ei_dot_impl<Derived1, Derived2, LinearVectorization, CompleteUnrolling>
|
||||
* \only_for_vectors
|
||||
*
|
||||
* \note If the scalar type is complex numbers, then this function returns the hermitian
|
||||
* (sesquilinear) dot product, linear in the first variable and anti-linear in the
|
||||
* (sesquilinear) dot product, linear in the first variable and conjugate-linear in the
|
||||
* second variable.
|
||||
*
|
||||
* \sa norm2(), norm()
|
||||
* \sa squaredNorm(), norm()
|
||||
*/
|
||||
template<typename Derived>
|
||||
template<typename OtherDerived>
|
||||
@@ -275,6 +275,8 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
*
|
||||
* \note This is \em not the \em l2 norm.
|
||||
*
|
||||
* \deprecated Use squaredNorm() instead. This norm2() function is kept only for compatibility and will be removed in Eigen 2.0.
|
||||
*
|
||||
* \only_for_vectors
|
||||
*
|
||||
* \sa dot(), norm()
|
||||
@@ -285,16 +287,28 @@ inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<
|
||||
return ei_real(dot(*this));
|
||||
}
|
||||
|
||||
/** \returns the squared norm of *this, i.e. the dot product of *this with itself.
|
||||
*
|
||||
* \only_for_vectors
|
||||
*
|
||||
* \sa dot(), norm()
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::squaredNorm() const
|
||||
{
|
||||
return ei_real(dot(*this));
|
||||
}
|
||||
|
||||
/** \returns the \em l2 norm of *this, i.e. the square root of the dot product of *this with itself.
|
||||
*
|
||||
* \only_for_vectors
|
||||
*
|
||||
* \sa dot(), norm2()
|
||||
* \sa dot(), normSquared()
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline typename NumTraits<typename ei_traits<Derived>::Scalar>::Real MatrixBase<Derived>::norm() const
|
||||
{
|
||||
return ei_sqrt(norm2());
|
||||
return ei_sqrt(squaredNorm());
|
||||
}
|
||||
|
||||
/** \returns an expression of the quotient of *this by its own norm.
|
||||
@@ -338,7 +352,7 @@ bool MatrixBase<Derived>::isOrthogonal
|
||||
{
|
||||
typename ei_nested<Derived,2>::type nested(derived());
|
||||
typename ei_nested<OtherDerived,2>::type otherNested(other.derived());
|
||||
return ei_abs2(nested.dot(otherNested)) <= prec * prec * nested.norm2() * otherNested.norm2();
|
||||
return ei_abs2(nested.dot(otherNested)) <= prec * prec * nested.squaredNorm() * otherNested.squaredNorm();
|
||||
}
|
||||
|
||||
/** \returns true if *this is approximately an unitary matrix,
|
||||
@@ -358,7 +372,7 @@ bool MatrixBase<Derived>::isUnitary(RealScalar prec) const
|
||||
typename Derived::Nested nested(derived());
|
||||
for(int i = 0; i < cols(); i++)
|
||||
{
|
||||
if(!ei_isApprox(nested.col(i).norm2(), static_cast<Scalar>(1), prec))
|
||||
if(!ei_isApprox(nested.col(i).squaredNorm(), static_cast<Scalar>(1), prec))
|
||||
return false;
|
||||
for(int j = 0; j < i; j++)
|
||||
if(!ei_isMuchSmallerThan(nested.col(i).dot(nested.col(j)), static_cast<Scalar>(1), prec))
|
||||
|
||||
@@ -178,17 +178,17 @@ struct ei_fuzzy_selector<Derived,OtherDerived,true>
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
|
||||
ei_assert(self.size() == other.size());
|
||||
return((self - other).norm2() <= std::min(self.norm2(), other.norm2()) * prec * prec);
|
||||
return((self - other).squaredNorm() <= std::min(self.squaredNorm(), other.squaredNorm()) * prec * prec);
|
||||
}
|
||||
static bool isMuchSmallerThan(const Derived& self, const RealScalar& other, RealScalar prec)
|
||||
{
|
||||
return(self.norm2() <= ei_abs2(other * prec));
|
||||
return(self.squaredNorm() <= ei_abs2(other * prec));
|
||||
}
|
||||
static bool isMuchSmallerThan(const Derived& self, const OtherDerived& other, RealScalar prec)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_SAME_VECTOR_SIZE(Derived,OtherDerived);
|
||||
ei_assert(self.size() == other.size());
|
||||
return(self.norm2() <= other.norm2() * prec * prec);
|
||||
return(self.squaredNorm() <= other.squaredNorm() * prec * prec);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -203,8 +203,8 @@ struct ei_fuzzy_selector<Derived,OtherDerived,false>
|
||||
typename Derived::Nested nested(self);
|
||||
typename OtherDerived::Nested otherNested(other);
|
||||
for(int i = 0; i < self.cols(); i++)
|
||||
if((nested.col(i) - otherNested.col(i)).norm2()
|
||||
> std::min(nested.col(i).norm2(), otherNested.col(i).norm2()) * prec * prec)
|
||||
if((nested.col(i) - otherNested.col(i)).squaredNorm()
|
||||
> std::min(nested.col(i).squaredNorm(), otherNested.col(i).squaredNorm()) * prec * prec)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -212,7 +212,7 @@ struct ei_fuzzy_selector<Derived,OtherDerived,false>
|
||||
{
|
||||
typename Derived::Nested nested(self);
|
||||
for(int i = 0; i < self.cols(); i++)
|
||||
if(nested.col(i).norm2() > ei_abs2(other * prec))
|
||||
if(nested.col(i).squaredNorm() > ei_abs2(other * prec))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -223,7 +223,7 @@ struct ei_fuzzy_selector<Derived,OtherDerived,false>
|
||||
typename Derived::Nested nested(self);
|
||||
typename OtherDerived::Nested otherNested(other);
|
||||
for(int i = 0; i < self.cols(); i++)
|
||||
if(nested.col(i).norm2() > otherNested.col(i).norm2() * prec * prec)
|
||||
if(nested.col(i).squaredNorm() > otherNested.col(i).squaredNorm() * prec * prec)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -330,6 +330,7 @@ template<typename Derived> class MatrixBase
|
||||
|
||||
template<typename OtherDerived>
|
||||
Scalar dot(const MatrixBase<OtherDerived>& other) const;
|
||||
RealScalar squaredNorm() const;
|
||||
RealScalar norm2() const;
|
||||
RealScalar norm() const;
|
||||
const EvalType normalized() const;
|
||||
|
||||
Reference in New Issue
Block a user