diff options
Diffstat (limited to 'lib/matrix.rb')
-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. # |