Module: MDS::Test::MatrixAssertions
- Included in:
- BundleMatrixInterface, BundleMetric
- Defined in:
- lib/mds/test/matrix_assertions.rb
Overview
Addition assertions for comparing matrices.
Instance Method Summary collapse
-
#assert_delta_matrices(a, b, delta = 1e-10) ⇒ Object
Assert that two matrices are equal up to delta.
-
#assert_equal_matrices(a, b) ⇒ Object
Assert that two matrices are equal.
Instance Method Details
#assert_delta_matrices(a, b, delta = 1e-10) ⇒ Object
Assert that two matrices are equal up to delta
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mds/test/matrix_assertions.rb', line 40 def assert_delta_matrices(a, b, delta = 1e-10) assert_instance_of(a.matrix.class, b.matrix) assert(a.nrows, b.nrows) assert(a.ncols, b.ncols) for i in 0..a.nrows-1 do for j in 0..a.ncols-1 do assert_in_delta(a[i,j], b[i,j], delta) end end end |
#assert_equal_matrices(a, b) ⇒ Object
Assert that two matrices are equal
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mds/test/matrix_assertions.rb', line 21 def assert_equal_matrices(a, b) assert_instance_of(a.matrix.class, b.matrix) assert(a.nrows, b.nrows) assert(a.ncols, b.ncols) for i in 0..a.nrows-1 do for j in 0..a.ncols-1 do assert_equal(a[i,j], b[i,j]) end end end |