Check equality with tolerance
v0dro opened this issue · 1 comments
v0dro commented
If you're approximating a matrix and check element-wise accuracy with the original matrix, you frequently need to use equality with some tolerance. Having a function like be_within
similar to rspec would be helpful.
For example:
n = NMatrix.random(8)
u,s,d = n.gesvd
assert n.be_within(0.0001, u.dot(s.dot(d)))
translunar commented
(n - u.dot(s.dot(d))) <= 0.0001