This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Bug in cos/unaryExpr with eigen-24d29254152d

Tags: unaryexpr unaryexpr unaryexpr
(comma "," separated)
william.tambellini
Registered Member
Posts
3
Karma
0
cos/unaryExpr dont seem to work any more on master (eigen-24d29254152d) at least in release build (O3) with gcc6.1 :

// T = float
Eigen::Tensor<T, 2> i(2, 5);
i.setValues({{-0.5, -3.0f / 8.0f, -0.25f, 0f, 1.0f / 6.0f}, {0.25f, 1.f / 3.f, 0.5f, 0.7f, 1f}});
std::cout << "input:\n" << i << std::endl;
Eigen::Tensor<T, 2> i2 = i * (T)M_PI;
std::cout << "input*pi:\n" << i2 << std::endl;
std::cout << "cos tensor:\n" << i2.unaryExpr(Eigen::internal::scalar_cos_op<T>()) << std::endl;
using CMMatrix = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor>;
std::cout << "cos matrix:\n" << Eigen::Map<CMMatrix>(i2.data(), 2, 5).array().cos() << std::endl;
std::cout << "expected:\n";
for (unsigned i = 0; i < i2.dimension(0); ++i) {
for (unsigned j = 0; j < i2.dimension(1); ++j)
std::cout << std::setw(4) << std::cos(i2(i, j)) << " ";
std::cout << std::endl;
}

input:
-0.5 -0.375 -0.25 0 0.166667
0.25 0.333333 0.5 0.7 1
input*pi:
-1.5708 -1.1781 -0.785398 0 0.523599
0.785398 1.0472 1.5708 2.19911 3.14159
cos tensor:
-0 -0 1 1 0.866025
1 -0 -0 -0 -1
cos matrix:
-0 -0 1 1 0.866025
1 -0 -0 -0 -1
expected:
-4.37114e-08 0.382683 0.707107 1 0.866025
0.707107 0.5 -4.37114e-08 -0.587785 -1


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot], rblackwell