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)))
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: