ruby-changes:20302
From: marcandre <ko1@a...>
Date: Fri, 1 Jul 2011 15:10:51 +0900 (JST)
Subject: [ruby-changes:20302] marcandRe: r32350 (trunk): * lib/matrix: Add Matrix#round
marcandre 2011-07-01 15:10:40 +0900 (Fri, 01 Jul 2011) New Revision: 32350 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=32350 Log: * lib/matrix: Add Matrix#round Modified files: trunk/ChangeLog trunk/NEWS trunk/lib/matrix.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 32349) +++ ChangeLog (revision 32350) @@ -1,3 +1,7 @@ +Fri Jul 1 15:10:22 2011 Marc-Andre Lafortune <ruby-core@m...> + + * lib/matrix: Add Matrix#round + Fri Jul 1 11:41:12 2011 NARUSE, Yui <naruse@r...> * string.c (tr_trans): free heap ptr when the str is not embeded. Index: lib/matrix.rb =================================================================== --- lib/matrix.rb (revision 32349) +++ lib/matrix.rb (revision 32350) @@ -89,6 +89,7 @@ # * <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 @@ 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. Index: NEWS =================================================================== --- NEWS (revision 32349) +++ NEWS (revision 32350) @@ -164,6 +164,7 @@ * Matrix#normal? * Matrix#orthogonal? * Matrix#permutation? + * Matrix#round * Matrix#symmetric? * Matrix#unitary? * Matrix#upper_triangular? -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/