Ask Your Question

jnuevo's profile - activity

2017-05-10 19:09:30 -0600 received badge  Scholar (source)
2017-05-09 02:38:24 -0600 received badge  Student (source)
2017-05-08 23:39:25 -0600 received badge  Editor (source)
2017-05-08 23:35:49 -0600 asked a question Different result with fixed size matrices vs dynamic

When multiplying small matrices, I get different results when using a 2x3 fixed sized matrix than a dynamic Mat_<float>.

cv::Mat_<float> B = (cv::Mat_<float>(2, 3) << 658.95428, -21.682049,
                   10.625885, 21.246431, 660.61816, 22.65921);
cv::Mat_<float> H = B.t() * B;
cv::Matx23f Bx (B);
cv::Matx33f Hx = Bx.t() * Bx;
std::cout << cv::norm(H, cv::Mat_<float>(Hx, false)) << "\n";
//0.000410005

Is this really expected?

I'm using 3.2, compiling with Clang++ and -O3, but GCC 5.4 returns the same error.

More results: Doing these operations with Eigen 3.3, the results are the same as with the fixed sized matrices. Using Octave with double precision, the results are very close to the dynamic matrix's result. It looks like the dynamic matrices use doubles inside, irrespectively of the float32 type of the operands.