summaryrefslogtreecommitdiff
path: root/lib/matrix.rb
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 /lib/matrix.rb
parent49e9f4714ef5d8c50ae757e3a7bf8b0807de63af (diff)
* 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 'lib/matrix.rb')
-rw-r--r--lib/matrix.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb
index b56b128..b39973b 100644
--- a/lib/matrix.rb
+++ b/lib/matrix.rb
@@ -90,6 +90,8 @@ end
# * #inverse
# * #inv
# * #**
+# * #+@
+# * #-@
#
# Matrix functions:
# * #determinant
@@ -1122,6 +1124,14 @@ class Matrix
end
end
+ def +@
+ self
+ end
+
+ def -@
+ collect {|e| -e }
+ end
+
#--
# MATRIX FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++
@@ -1670,6 +1680,8 @@ end
# * #*(x) "is matrix or number"
# * #+(v)
# * #-(v)
+# * #+@
+# * #-@
#
# Vector functions:
# * #inner_product(v)
@@ -1907,6 +1919,14 @@ class Vector
end
end
+ def +@
+ self
+ end
+
+ def -@
+ collect {|e| -e }
+ end
+
#--
# VECTOR FUNCTIONS -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
#++