зеркало из https://github.com/github/ruby.git
* lib/matrix: Add Matrix#round
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
f4dda52025
Коммит
376b825127
|
@ -1,3 +1,7 @@
|
|||
Fri Jul 1 15:10:22 2011 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/matrix: Add Matrix#round
|
||||
|
||||
Fri Jul 1 11:41:12 2011 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* string.c (tr_trans): free heap ptr when the str is not embeded.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -164,6 +164,7 @@ with all sufficient information, see the ChangeLog file.
|
|||
* Matrix#normal?
|
||||
* Matrix#orthogonal?
|
||||
* Matrix#permutation?
|
||||
* Matrix#round
|
||||
* Matrix#symmetric?
|
||||
* Matrix#unitary?
|
||||
* Matrix#upper_triangular?
|
||||
|
|
|
@ -89,6 +89,7 @@ end
|
|||
# * <tt> #determinant </tt>
|
||||
# * <tt> #det </tt>
|
||||
# * <tt> #rank </tt>
|
||||
# * <tt> #round </tt>
|
||||
# * <tt> #trace </tt>
|
||||
# * <tt> #tr </tt>
|
||||
# * <tt> #transpose </tt>
|
||||
|
@ -1125,6 +1126,12 @@ class Matrix
|
|||
rank
|
||||
end
|
||||
|
||||
# Returns a matrix with entries rounded to the given precision
|
||||
# (see Float#round)
|
||||
#
|
||||
def round(ndigits=0)
|
||||
map{|e| e.round(ndigits)}
|
||||
end
|
||||
|
||||
#
|
||||
# Returns the trace (sum of diagonal elements) of the matrix.
|
||||
|
|
Загрузка…
Ссылка в новой задаче