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

Compare to matrices with GTest

Tags: None
(comma "," separated)
blightzyear
Registered Member
Posts
2
Karma
0

Compare to matrices with GTest

Fri Dec 29, 2017 5:01 pm
Hey everyone,

as mentioned above, I want to compare to matrices which I have calculated with Eigen. One matrix is a MatrixXd with six rows and eight columns and the other one is calculated by a complex algorithm - of course also a MatrixXd with six rows and eight columns. The two matrices are delivering the exact same values, but if i want to compare them with ASSERT_EQ from GoogleTest, the test fails. -.-

The output shows this values:

Actual: 24-byte object <A0-D4 AE-01 00-00 00-00 06-00 00-00 00-00 00-00 08-00 00-00 00-00 00-00>
Expected: resultMatrix
Which is: 24-byte object <F0-24 AE-01 00-00 00-00 06-00 00-00 00-00 00-00 08-00 00-00 00-00 00-00>

Can someone tell me how I should compare this two matrices?

Thx & GB
buzzzzzz
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Compare to matrices with GTest

Mon Jan 01, 2018 6:25 pm
You need a fuzzy comparison tolerating a few bits of round-off error, something like:

ASSERT( A.isApprox(B) );

and replace "ASSERT" by the appropriate GTest macro. You can also specify the tolerance as a second argument to isApprox.
blightzyear
Registered Member
Posts
2
Karma
0

Re: Compare to matrices with GTest

Sun Jan 21, 2018 4:17 pm
Hey,

thank you, i saw that the values were different in the 7th position... now I am calculating the norm of the matrices and compare these two -> but first i have to check how to cut off the other values. I don't need so much comma positions...

Thx for your advice!
bl


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]