diff options
Diffstat (limited to 'test/matrix')
-rw-r--r-- | test/matrix/test_matrix.rb | 6 | ||||
-rw-r--r-- | test/matrix/test_vector.rb | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb index 3fdef3b314..7f058abe37 100644 --- a/test/matrix/test_matrix.rb +++ b/test/matrix/test_matrix.rb @@ -190,6 +190,12 @@ class TestMatrix < Test::Unit::TestCase assert_equal(@m1, Matrix[o, [4,5,6]]) end + def test_round + a = Matrix[[1.0111, 2.32320, 3.04343], [4.81, 5.0, 6.997]] + b = Matrix[[1.01, 2.32, 3.04], [4.81, 5.0, 7.0]] + assert_equal(a.round(2), b) + end + def test_rows assert_equal(@m1, Matrix.rows([[1, 2, 3], [4, 5, 6]])) end diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb index 3275310b42..77fc68dd2b 100644 --- a/test/matrix/test_vector.rb +++ b/test/matrix/test_vector.rb @@ -157,6 +157,10 @@ class TestVector < Test::Unit::TestCase assert_equal(5, Vector[3, 4].r) end + def test_round + assert_equal(Vector[1.234, 2.345, 3.40].round(2), Vector[1.23, 2.35, 3.4]) + end + def test_covector assert_equal(Matrix[[1,2,3]], @v1.covector) end |