This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

# Bug 1612

Summary: Product: rowwise().mean() gives wrong results for Scalar = std::complex Eigen Rasmus Munk Larsen Core - general Nobody RESOLVED FIXED Wrong Result chtz, gael.guennebaud, jacob.benoit.1, rmlarsen Normal 3.4 (development) All All

 Rasmus Munk Larsen 2018-10-15 19:06:52 UTC ```Reproducer: TEST(EigenTest, RowWiseMean) { using Scalar = std::complex; using Matrix = Eigen::Array; Matrix input; input.setRandom(10, 2); Matrix mean_output; mean_output = input.rowwise().mean(); Matrix expected_output; expected_output = (input.col(0) + input.col(1)) / 2; VLOG(2) << "\33[0;36m" << std::endl << "ComplexdArrayRowwiseMeanTest:" << std::endl << "input:" << std::endl << input << std::endl << "\33[0;32m" << std::endl << "mean_output:" << std::endl << mean_output << std::endl << "\33[0;33m" << std::endl << "expected_output:" << std::endl << expected_output << std::endl << "\33[0;0m" << std::endl; double max_abs_error = (mean_output - expected_output).abs().maxCoeff(); EXPECT_LT(max_abs_error, 1e-5); } Output: input: 0(0.680375,-0.211234) (-0.967399,-0.514226) 000(0.566198,0.59688) 0(-0.725537,0.608354) 0(0.823295,-0.604897) (-0.686642,-0.198111) 0(-0.329554,0.536459) (-0.740419,-0.782382) 00(-0.444451,0.10794) 0(0.997849,-0.563486) (-0.0452059,0.257742) 0(0.0258648,0.678224) (-0.270431,0.0268018) 00(0.22528,-0.407937) 000(0.904459,0.83239) 0(0.275105,0.0485744) 00(0.271423,0.434594) 00(-0.012834,0.94555) 0(-0.716795,0.213938) 0(-0.414966,0.542715) mean_output: 0(0.340188,-0.105617) 000(0.283099,0.29844) 0(0.411647,-0.302449) 00(-0.164777,0.26823) 00(-0.222225,0.05397) (-0.0226029,0.128871) (-0.135216,0.0134009) 000(0.45223,0.416195) 00(0.135712,0.217297) 0(-0.358397,0.106969) expected_output: 00(-0.143512,-0.36273) 0(-0.0796692,0.602617) 0(0.0683264,-0.401504) 0(-0.534987,-0.122962) 00(0.276699,-0.227773) (-0.00967055,0.467983) (-0.0225757,-0.190567) 000(0.589782,0.440482) 000(0.129295,0.690072) 00(-0.565881,0.378327)``` Rasmus Munk Larsen 2018-10-15 19:11:08 UTC `FYI: I get the same result compiling in optimized and debug mode.` Gael Guennebaud 2018-10-15 22:24:28 UTC `this only occurs with double (fine with complex), and the error is already there with with .sum(). Looks like an issue when vectorizating with PacketSize==1` Gael Guennebaud 2018-10-15 22:47:55 UTC `damn, I've been tricked by bug 416...` Gael Guennebaud 2018-10-15 23:07:36 UTC ```quick fix, by-pass vectorization in this special case: https://bitbucket.org/eigen/eigen/commits/a79aa7f2f56e/ Summary: Bug 1612: fix regression in "outer-vectorization" of partial reductions for PacketSize==1 (aka complex)``` Rasmus Munk Larsen 2018-10-15 23:17:20 UTC `Thanks for the quick fix, Gael!` Nobody 2019-12-04 18:01:57 UTC ```-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/1612.```