ruby-changes:53289
From: marcandre <ko1@a...>
Date: Sat, 3 Nov 2018 03:00:45 +0900 (JST)
Subject: [ruby-changes:53289] marcandRe: r65503 (trunk): lib/matrix: use consistent style
marcandre 2018-11-03 02:52:12 +0900 (Sat, 03 Nov 2018) New Revision: 65503 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65503 Log: lib/matrix: use consistent style Modified files: trunk/lib/matrix/eigenvalue_decomposition.rb trunk/lib/matrix.rb Index: lib/matrix/eigenvalue_decomposition.rb =================================================================== --- lib/matrix/eigenvalue_decomposition.rb (revision 65502) +++ lib/matrix/eigenvalue_decomposition.rb (revision 65503) @@ -43,7 +43,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/eigenvalue_decomposition.rb#L43 def eigenvector_matrix Matrix.send(:new, build_eigenvectors.transpose) end - alias v eigenvector_matrix + alias_method :v, :eigenvector_matrix # Returns the inverse of the eigenvector matrix +V+ # @@ -52,7 +52,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/eigenvalue_decomposition.rb#L52 r = r.transpose.inverse unless @symmetric r end - alias v_inv eigenvector_matrix_inv + alias_method :v_inv, :eigenvector_matrix_inv # Returns the eigenvalues in an array # @@ -73,7 +73,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix/eigenvalue_decomposition.rb#L73 def eigenvalue_matrix Matrix.diagonal(*eigenvalues) end - alias d eigenvalue_matrix + alias_method :d, :eigenvalue_matrix # Returns [eigenvector_matrix, eigenvalue_matrix, eigenvector_matrix_inv] # Index: lib/matrix.rb =================================================================== --- lib/matrix.rb (revision 65502) +++ lib/matrix.rb (revision 65503) @@ -145,8 +145,8 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L145 scalar(n, 1) end class << Matrix - alias unit identity - alias I identity + alias_method :unit, :identity + alias_method :I, :identity end # @@ -370,7 +370,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L370 rows = @rows.collect{|row| row.collect(&block)} new_matrix rows, column_count end - alias map collect + alias_method :map, :collect # # Yields all elements of the matrix, starting with those of the first row, @@ -1013,7 +1013,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1013 Matrix.Raise ErrDimensionMismatch unless square? self.class.I(row_count).send(:inverse_from, self) end - alias inv inverse + alias_method :inv, :inverse def inverse_from(src) # :nodoc: last = row_count - 1 @@ -1200,7 +1200,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1200 warn "Matrix#determinant_e is deprecated; use #determinant", uplevel: 1 determinant end - alias det_e determinant_e + alias_method :det_e, :determinant_e # # Returns a new matrix resulting by stacking horizontally @@ -1277,7 +1277,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1277 tr + @rows[i][i] end end - alias tr trace + alias_method :tr, :trace # # Returns the transpose of the matrix. @@ -1293,7 +1293,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1293 return self.class.empty(column_count, 0) if row_count.zero? new_matrix @rows.transpose, row_count end - alias t transpose + alias_method :t, :transpose # # Returns a new matrix resulting by stacking vertically @@ -1322,7 +1322,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1322 def eigensystem EigenvalueDecomposition.new(self) end - alias eigen eigensystem + alias_method :eigen, :eigensystem # # Returns the LUP decomposition of the matrix; see +LUPDecomposition+. @@ -1337,7 +1337,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1337 def lup LUPDecomposition.new(self) end - alias lup_decomposition lup + alias_method :lup_decomposition, :lup #-- # COMPLEX ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -1355,7 +1355,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1355 def conjugate collect(&:conjugate) end - alias conj conjugate + alias_method :conj, :conjugate # # Returns the imaginary part of the matrix. @@ -1369,7 +1369,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1369 def imaginary collect(&:imaginary) end - alias imag imaginary + alias_method :imag, :imaginary # # Returns the real part of the matrix. @@ -1393,7 +1393,7 @@ class Matrix https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L1393 def rect [real, imag] end - alias rectangular rect + alias_method :rectangular, :rect #-- # CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -2045,7 +2045,7 @@ class Vector https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L2045 els = @elements.collect(&block) self.class.elements(els, false) end - alias map collect + alias_method :map, :collect # # Returns the modulus (Pythagorean distance) of the vector. @@ -2054,8 +2054,8 @@ class Vector https://github.com/ruby/ruby/blob/trunk/lib/matrix.rb#L2054 def magnitude Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2}) end - alias r magnitude - alias norm magnitude + alias_method :r, :magnitude + alias_method :norm, :magnitude # # Like Vector#collect2, but returns a Vector instead of an Array. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/