diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-05 23:45:42 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-05 23:45:42 +0000 |
commit | b81950f480df1c07f2e6f271d23d066dafdc0e1f (patch) | |
tree | 032b3e9f6e56fd5acb4cb353ea16969c4c9d3a5d /lib | |
parent | ce85cd55c621804a39f06e9ce46974fc693ff8df (diff) |
* lib/matrix.rb: Add Vector#round. Patch by Jordan Stephens.
[Fixes GH-802]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/matrix.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/matrix.rb b/lib/matrix.rb index 1f8f0589e1..f1e30f82cb 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -1713,6 +1713,7 @@ end # * #norm # * #normalize # * #r +# * #round # * #size # # Conversion to other data types: @@ -1790,6 +1791,13 @@ class Vector alias set_component []= private :[]=, :set_element, :set_component + # Returns a vector with entries rounded to the given precision + # (see Float#round) + # + def round(ndigits=0) + map{|e| e.round(ndigits)} + end + # # Returns the number of elements in the vector. # |