mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
dot() now always uses eigen3 convention, even in eigen2 support mode, even stage 10. Didn't have a choice as lots of eigen code is using it.
This commit is contained in:
parent
e761ba68f7
commit
b2b8c6a89c
@ -83,14 +83,10 @@ MatrixBase<Derived>::dot(const MatrixBase<OtherDerived>& other) const
|
||||
|
||||
eigen_assert(size() == other.size());
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE >= STAGE30_FULL_EIGEN3_API
|
||||
return internal::dot_nocheck<Derived,OtherDerived>::run(*this, other);
|
||||
#else
|
||||
return internal::dot_nocheck<OtherDerived,Derived>::run(other,*this);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE <= STAGE30_FULL_EIGEN3_API
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
/** \returns the dot product of *this with other, with the Eigen2 convention that the dot product is linear in the first variable
|
||||
* (conjugating the second variable). Of course this only makes a difference in the complex case.
|
||||
*
|
||||
|
@ -200,23 +200,15 @@ template<typename Derived> class MatrixBase
|
||||
const DiagonalProduct<Derived, DiagonalDerived, OnTheRight>
|
||||
operator*(const DiagonalBase<DiagonalDerived> &diagonal) const;
|
||||
|
||||
#if EIGEN2_SUPPORT_STAGE != STAGE20_RESOLVE_API_CONFLICTS
|
||||
template<typename OtherDerived>
|
||||
typename internal::scalar_product_traits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
|
||||
#if EIGEN2_SUPPORT_STAGE == STAGE15_RESOLVE_API_CONFLICTS_WARN
|
||||
EIGEN_DEPRECATED
|
||||
#endif
|
||||
dot(const MatrixBase<OtherDerived>& other) const;
|
||||
#endif
|
||||
|
||||
template<typename OtherDerived>
|
||||
typename internal::scalar_product_traits<typename internal::traits<Derived>::Scalar,typename internal::traits<OtherDerived>::Scalar>::ReturnType
|
||||
dot(const MatrixBase<OtherDerived>& other) const;
|
||||
|
||||
#ifdef EIGEN2_SUPPORT
|
||||
template<typename OtherDerived>
|
||||
#if EIGEN2_SUPPORT_STAGE >= STAGE30_FULL_EIGEN3_API
|
||||
EIGEN_DEPRECATED
|
||||
#endif
|
||||
Scalar eigen2_dot(const MatrixBase<OtherDerived>& other) const;
|
||||
#endif
|
||||
|
||||
|
||||
RealScalar squaredNorm() const;
|
||||
RealScalar norm() const;
|
||||
RealScalar stableNorm() const;
|
||||
|
@ -65,18 +65,18 @@ template<typename MatrixType> void adjoint(const MatrixType& m)
|
||||
|
||||
// check basic properties of dot, norm, norm2
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
VERIFY(ei_isApprox((s1 * v1 + s2 * v2).dot(v3), s1 * v1.dot(v3) + s2 * v2.dot(v3), largerEps));
|
||||
VERIFY(ei_isApprox(v3.dot(s1 * v1 + s2 * v2), ei_conj(s1)*v3.dot(v1)+ei_conj(s2)*v3.dot(v2), largerEps));
|
||||
VERIFY_IS_APPROX(ei_conj(v1.dot(v2)), v2.dot(v1));
|
||||
VERIFY_IS_APPROX(ei_abs(v1.dot(v1)), v1.squaredNorm());
|
||||
VERIFY(ei_isApprox((s1 * v1 + s2 * v2).eigen2_dot(v3), s1 * v1.eigen2_dot(v3) + s2 * v2.eigen2_dot(v3), largerEps));
|
||||
VERIFY(ei_isApprox(v3.eigen2_dot(s1 * v1 + s2 * v2), ei_conj(s1)*v3.eigen2_dot(v1)+ei_conj(s2)*v3.eigen2_dot(v2), largerEps));
|
||||
VERIFY_IS_APPROX(ei_conj(v1.eigen2_dot(v2)), v2.eigen2_dot(v1));
|
||||
VERIFY_IS_APPROX(ei_abs(v1.eigen2_dot(v1)), v1.squaredNorm());
|
||||
if(NumTraits<Scalar>::HasFloatingPoint)
|
||||
VERIFY_IS_APPROX(v1.squaredNorm(), v1.norm() * v1.norm());
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.dot(v1)), static_cast<RealScalar>(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(ei_abs(vzero.eigen2_dot(v1)), static_cast<RealScalar>(1));
|
||||
if(NumTraits<Scalar>::HasFloatingPoint)
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(vzero.norm(), static_cast<RealScalar>(1));
|
||||
|
||||
// check compatibility of dot and adjoint
|
||||
VERIFY(ei_isApprox(v1.dot(square * v2), (square.adjoint() * v1).dot(v2), largerEps));
|
||||
VERIFY(ei_isApprox(v1.eigen2_dot(square * v2), (square.adjoint() * v1).eigen2_dot(v2), largerEps));
|
||||
|
||||
// like in testBasicStuff, test operator() to check const-qualification
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
|
@ -61,7 +61,7 @@ template<typename Scalar> void geometry(void)
|
||||
Scalar a = ei_random<Scalar>(-Scalar(M_PI), Scalar(M_PI));
|
||||
|
||||
// cross product
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).dot(v1), Scalar(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(v1.cross(v2).eigen2_dot(v1), Scalar(1));
|
||||
Matrix3 m;
|
||||
m << v0.normalized(),
|
||||
(v0.cross(v1)).normalized(),
|
||||
@ -76,15 +76,15 @@ template<typename Scalar> void geometry(void)
|
||||
VERIFY_IS_APPROX(q1.coeffs(), (q1*q2).coeffs());
|
||||
|
||||
// unitOrthogonal
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(u0.unitOrthogonal().dot(u0), Scalar(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().dot(v0), Scalar(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(u0.unitOrthogonal().eigen2_dot(u0), Scalar(1));
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(v0.unitOrthogonal().eigen2_dot(v0), Scalar(1));
|
||||
VERIFY_IS_APPROX(u0.unitOrthogonal().norm(), Scalar(1));
|
||||
VERIFY_IS_APPROX(v0.unitOrthogonal().norm(), Scalar(1));
|
||||
|
||||
|
||||
VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
|
||||
VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(M_PI), v0.unitOrthogonal()) * v0);
|
||||
VERIFY_IS_APPROX(ei_cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
|
||||
VERIFY_IS_APPROX(ei_cos(a)*v0.squaredNorm(), v0.eigen2_dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
|
||||
m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
|
||||
VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
|
||||
VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);
|
||||
|
@ -54,7 +54,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
|
||||
Scalar s0 = ei_random<Scalar>();
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
VERIFY_IS_APPROX( n1.dot(n1), Scalar(1) );
|
||||
VERIFY_IS_APPROX( n1.eigen2_dot(n1), Scalar(1) );
|
||||
|
||||
VERIFY_IS_MUCH_SMALLER_THAN( pl0.absDistance(p0), Scalar(1) );
|
||||
VERIFY_IS_APPROX( pl1.signedDistance(p1 + n1 * s0), s0 );
|
||||
|
@ -74,9 +74,9 @@ template<int SizeAtCompileType> void mixingtypes(int size = SizeAtCompileType)
|
||||
VERIFY_RAISES_ASSERT(mcf*vcd);
|
||||
VERIFY_RAISES_ASSERT(vcf = mf*vf);
|
||||
|
||||
vf.dot(vf);
|
||||
VERIFY_RAISES_ASSERT(vd.dot(vf));
|
||||
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
|
||||
vf.eigen2_dot(vf);
|
||||
VERIFY_RAISES_ASSERT(vd.eigen2_dot(vf));
|
||||
VERIFY_RAISES_ASSERT(vcf.eigen2_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_eigen2_mixingtypes()
|
||||
|
@ -238,7 +238,7 @@ template<typename SparseMatrixType> void sparse_basic(const SparseMatrixType& re
|
||||
VERIFY_IS_APPROX(m1+=m2, refM1+=refM2);
|
||||
VERIFY_IS_APPROX(m1-=m2, refM1-=refM2);
|
||||
|
||||
VERIFY_IS_APPROX(m1.col(0).dot(refM2.row(0)), refM1.col(0).dot(refM2.row(0)));
|
||||
VERIFY_IS_APPROX(m1.col(0).eigen2_dot(refM2.row(0)), refM1.col(0).eigen2_dot(refM2.row(0)));
|
||||
|
||||
refM4.setRandom();
|
||||
// sparse cwise* dense
|
||||
|
@ -83,8 +83,8 @@ template<typename Scalar> void sparse_vector(int rows, int cols)
|
||||
VERIFY_IS_APPROX(v1+=v2, refV1+=refV2);
|
||||
VERIFY_IS_APPROX(v1-=v2, refV1-=refV2);
|
||||
|
||||
VERIFY_IS_APPROX(v1.dot(v2), refV1.dot(refV2));
|
||||
VERIFY_IS_APPROX(v1.dot(refV2), refV1.dot(refV2));
|
||||
VERIFY_IS_APPROX(v1.eigen2_dot(v2), refV1.eigen2_dot(refV2));
|
||||
VERIFY_IS_APPROX(v1.eigen2_dot(refV2), refV1.eigen2_dot(refV2));
|
||||
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
|
||||
//check row() and col()
|
||||
VERIFY_IS_APPROX(m1.col(c1).transpose(), m1.transpose().row(c1));
|
||||
VERIFY_IS_APPROX(square.row(r1).dot(m1.col(c1)), (square.lazy() * m1.conjugate())(r1,c1));
|
||||
VERIFY_IS_APPROX(square.row(r1).eigen2_dot(m1.col(c1)), (square.lazy() * m1.conjugate())(r1,c1));
|
||||
//check operator(), both constant and non-constant, on row() and col()
|
||||
m1.row(r1) += s1 * m1.row(r2);
|
||||
m1.col(c1) += s1 * m1.col(c2);
|
||||
@ -146,8 +146,8 @@ template<typename MatrixType> void submatrices(const MatrixType& m)
|
||||
VERIFY(ei_real(ones.col(c1).sum()) == RealScalar(rows));
|
||||
VERIFY(ei_real(ones.row(r1).sum()) == RealScalar(cols));
|
||||
|
||||
VERIFY(ei_real(ones.col(c1).dot(ones.col(c2))) == RealScalar(rows));
|
||||
VERIFY(ei_real(ones.row(r1).dot(ones.row(r2))) == RealScalar(cols));
|
||||
VERIFY(ei_real(ones.col(c1).eigen2_dot(ones.col(c2))) == RealScalar(rows));
|
||||
VERIFY(ei_real(ones.row(r1).eigen2_dot(ones.row(r2))) == RealScalar(cols));
|
||||
}
|
||||
|
||||
void test_eigen2_submatrices()
|
||||
|
Loading…
x
Reference in New Issue
Block a user