aboutsummaryrefslogtreecommitdiffstats
path: root/test/matrix
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-07 20:18:35 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-07 20:18:35 +0000
commita2ae7bccf8670865fddbfc1aa7f30ab536bb4814 (patch)
tree2eb74b4198196dd7184a241a1331127bd2012460 /test/matrix
parent49e9f4714ef5d8c50ae757e3a7bf8b0807de63af (diff)
downloadruby-a2ae7bccf8670865fddbfc1aa7f30ab536bb4814.tar.gz
* lib/matrix.rb: Add @- and @+ for Matrix and Vector.
patch by gogo tanaka [#10068] [#10069] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/matrix')
-rw-r--r--test/matrix/test_matrix.rb9
-rw-r--r--test/matrix/test_vector.rb9
2 files changed, 18 insertions, 0 deletions
diff --git a/test/matrix/test_matrix.rb b/test/matrix/test_matrix.rb
index 2d99cead42..79ae9b965b 100644
--- a/test/matrix/test_matrix.rb
+++ b/test/matrix/test_matrix.rb
@@ -62,6 +62,15 @@ class TestMatrix < Test::Unit::TestCase
assert_equal @m1.hash, @m3.hash
end
+ def test_uplus
+ assert_equal(@m1, +@m1)
+ end
+
+ def test_negate
+ assert_equal(Matrix[[-1, -2, -3], [-4, -5, -6]], -@m1)
+ assert_equal(@m1, -(-@m1))
+ end
+
def test_rank
[
[[0]],
diff --git a/test/matrix/test_vector.rb b/test/matrix/test_vector.rb
index 465108dcec..fa29496451 100644
--- a/test/matrix/test_vector.rb
+++ b/test/matrix/test_vector.rb
@@ -120,6 +120,15 @@ class TestVector < Test::Unit::TestCase
assert_equal(0, Vector[1, 2, 3] - o)
end
+ def test_uplus
+ assert_equal(@v1, +@v1)
+ end
+
+ def test_negate
+ assert_equal(Vector[-1, -2, -3], -@v1)
+ assert_equal(@v1, -(-@v1))
+ end
+
def test_inner_product
assert_equal(1+4+9, @v1.inner_product(@v1))
end