mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix bug #314: move remaining math functions from internal to numext namespace
This commit is contained in:
@@ -26,22 +26,22 @@ template<typename MatrixType> void matrixRedux(const MatrixType& m)
|
||||
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(MatrixType::Zero(rows, cols).sum(), Scalar(1));
|
||||
VERIFY_IS_APPROX(MatrixType::Ones(rows, cols).sum(), Scalar(float(rows*cols))); // the float() here to shut up excessive MSVC warning about int->complex conversion being lossy
|
||||
Scalar s(0), p(1), minc(internal::real(m1.coeff(0))), maxc(internal::real(m1.coeff(0)));
|
||||
Scalar s(0), p(1), minc(numext::real(m1.coeff(0))), maxc(numext::real(m1.coeff(0)));
|
||||
for(int j = 0; j < cols; j++)
|
||||
for(int i = 0; i < rows; i++)
|
||||
{
|
||||
s += m1(i,j);
|
||||
p *= m1_for_prod(i,j);
|
||||
minc = (std::min)(internal::real(minc), internal::real(m1(i,j)));
|
||||
maxc = (std::max)(internal::real(maxc), internal::real(m1(i,j)));
|
||||
minc = (std::min)(numext::real(minc), numext::real(m1(i,j)));
|
||||
maxc = (std::max)(numext::real(maxc), numext::real(m1(i,j)));
|
||||
}
|
||||
const Scalar mean = s/Scalar(RealScalar(rows*cols));
|
||||
|
||||
VERIFY_IS_APPROX(m1.sum(), s);
|
||||
VERIFY_IS_APPROX(m1.mean(), mean);
|
||||
VERIFY_IS_APPROX(m1_for_prod.prod(), p);
|
||||
VERIFY_IS_APPROX(m1.real().minCoeff(), internal::real(minc));
|
||||
VERIFY_IS_APPROX(m1.real().maxCoeff(), internal::real(maxc));
|
||||
VERIFY_IS_APPROX(m1.real().minCoeff(), numext::real(minc));
|
||||
VERIFY_IS_APPROX(m1.real().maxCoeff(), numext::real(maxc));
|
||||
|
||||
// test slice vectorization assuming assign is ok
|
||||
Index r0 = internal::random<Index>(0,rows-1);
|
||||
@@ -73,13 +73,13 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
for(int i = 1; i < size; i++)
|
||||
{
|
||||
Scalar s(0), p(1);
|
||||
RealScalar minc(internal::real(v.coeff(0))), maxc(internal::real(v.coeff(0)));
|
||||
RealScalar minc(numext::real(v.coeff(0))), maxc(numext::real(v.coeff(0)));
|
||||
for(int j = 0; j < i; j++)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v_for_prod[j];
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, numext::real(v[j]));
|
||||
maxc = (std::max)(maxc, numext::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.head(i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v_for_prod.head(i).prod());
|
||||
@@ -90,13 +90,13 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
for(int i = 0; i < size-1; i++)
|
||||
{
|
||||
Scalar s(0), p(1);
|
||||
RealScalar minc(internal::real(v.coeff(i))), maxc(internal::real(v.coeff(i)));
|
||||
RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i)));
|
||||
for(int j = i; j < size; j++)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v_for_prod[j];
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, numext::real(v[j]));
|
||||
maxc = (std::max)(maxc, numext::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.tail(size-i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v_for_prod.tail(size-i).prod());
|
||||
@@ -107,13 +107,13 @@ template<typename VectorType> void vectorRedux(const VectorType& w)
|
||||
for(int i = 0; i < size/2; i++)
|
||||
{
|
||||
Scalar s(0), p(1);
|
||||
RealScalar minc(internal::real(v.coeff(i))), maxc(internal::real(v.coeff(i)));
|
||||
RealScalar minc(numext::real(v.coeff(i))), maxc(numext::real(v.coeff(i)));
|
||||
for(int j = i; j < size-i; j++)
|
||||
{
|
||||
s += v[j];
|
||||
p *= v_for_prod[j];
|
||||
minc = (std::min)(minc, internal::real(v[j]));
|
||||
maxc = (std::max)(maxc, internal::real(v[j]));
|
||||
minc = (std::min)(minc, numext::real(v[j]));
|
||||
maxc = (std::max)(maxc, numext::real(v[j]));
|
||||
}
|
||||
VERIFY_IS_MUCH_SMALLER_THAN(abs(s - v.segment(i, size-2*i).sum()), Scalar(1));
|
||||
VERIFY_IS_APPROX(p, v_for_prod.segment(i, size-2*i).prod());
|
||||
|
||||
Reference in New Issue
Block a user