mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-18 10:54:26 +08:00
implicit conversion to scalar for inner product
This commit is contained in:
parent
314bfa1375
commit
4ebb80490a
@ -182,6 +182,11 @@ class GeneralProduct<Lhs, Rhs, InnerProduct>
|
||||
}
|
||||
|
||||
typename Base::Scalar value() const { return Base::coeff(0,0); }
|
||||
|
||||
/** Convertion to scalar */
|
||||
operator const typename Base::Scalar() const {
|
||||
return Base::coeff(0,0);
|
||||
}
|
||||
};
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -72,7 +72,8 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
Scalar s1 = ei_random<Scalar>();
|
||||
|
||||
int r = ei_random<int>(0, rows-1),
|
||||
c = ei_random<int>(0, cols-1);
|
||||
c = ei_random<int>(0, cols-1),
|
||||
c2 = ei_random<int>(0, cols-1);
|
||||
|
||||
// begin testing Product.h: only associativity for now
|
||||
// (we use Transpose.h but this doesn't count as a test for it)
|
||||
@ -150,4 +151,8 @@ template<typename MatrixType> void product(const MatrixType& m)
|
||||
{
|
||||
VERIFY(areNotApprox(res2,square2 + m2.transpose() * m1));
|
||||
}
|
||||
|
||||
// inner product
|
||||
Scalar x = square2.row(c) * square2.col(c2);
|
||||
VERIFY_IS_APPROX(x, square2.row(c).transpose().cwiseProduct(square2.col(c2)).sum());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user