lib/matrix: use consistent style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a1f22c4f1c
commit
5ba9a9505d
@ -145,8 +145,8 @@ class Matrix
|
|||||||
scalar(n, 1)
|
scalar(n, 1)
|
||||||
end
|
end
|
||||||
class << Matrix
|
class << Matrix
|
||||||
alias unit identity
|
alias_method :unit, :identity
|
||||||
alias I identity
|
alias_method :I, :identity
|
||||||
end
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -370,7 +370,7 @@ class Matrix
|
|||||||
rows = @rows.collect{|row| row.collect(&block)}
|
rows = @rows.collect{|row| row.collect(&block)}
|
||||||
new_matrix rows, column_count
|
new_matrix rows, column_count
|
||||||
end
|
end
|
||||||
alias map collect
|
alias_method :map, :collect
|
||||||
|
|
||||||
#
|
#
|
||||||
# Yields all elements of the matrix, starting with those of the first row,
|
# Yields all elements of the matrix, starting with those of the first row,
|
||||||
@ -1013,7 +1013,7 @@ class Matrix
|
|||||||
Matrix.Raise ErrDimensionMismatch unless square?
|
Matrix.Raise ErrDimensionMismatch unless square?
|
||||||
self.class.I(row_count).send(:inverse_from, self)
|
self.class.I(row_count).send(:inverse_from, self)
|
||||||
end
|
end
|
||||||
alias inv inverse
|
alias_method :inv, :inverse
|
||||||
|
|
||||||
def inverse_from(src) # :nodoc:
|
def inverse_from(src) # :nodoc:
|
||||||
last = row_count - 1
|
last = row_count - 1
|
||||||
@ -1200,7 +1200,7 @@ class Matrix
|
|||||||
warn "Matrix#determinant_e is deprecated; use #determinant", uplevel: 1
|
warn "Matrix#determinant_e is deprecated; use #determinant", uplevel: 1
|
||||||
determinant
|
determinant
|
||||||
end
|
end
|
||||||
alias det_e determinant_e
|
alias_method :det_e, :determinant_e
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns a new matrix resulting by stacking horizontally
|
# Returns a new matrix resulting by stacking horizontally
|
||||||
@ -1277,7 +1277,7 @@ class Matrix
|
|||||||
tr + @rows[i][i]
|
tr + @rows[i][i]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
alias tr trace
|
alias_method :tr, :trace
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the transpose of the matrix.
|
# Returns the transpose of the matrix.
|
||||||
@ -1293,7 +1293,7 @@ class Matrix
|
|||||||
return self.class.empty(column_count, 0) if row_count.zero?
|
return self.class.empty(column_count, 0) if row_count.zero?
|
||||||
new_matrix @rows.transpose, row_count
|
new_matrix @rows.transpose, row_count
|
||||||
end
|
end
|
||||||
alias t transpose
|
alias_method :t, :transpose
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns a new matrix resulting by stacking vertically
|
# Returns a new matrix resulting by stacking vertically
|
||||||
@ -1322,7 +1322,7 @@ class Matrix
|
|||||||
def eigensystem
|
def eigensystem
|
||||||
EigenvalueDecomposition.new(self)
|
EigenvalueDecomposition.new(self)
|
||||||
end
|
end
|
||||||
alias eigen eigensystem
|
alias_method :eigen, :eigensystem
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the LUP decomposition of the matrix; see +LUPDecomposition+.
|
# Returns the LUP decomposition of the matrix; see +LUPDecomposition+.
|
||||||
@ -1337,7 +1337,7 @@ class Matrix
|
|||||||
def lup
|
def lup
|
||||||
LUPDecomposition.new(self)
|
LUPDecomposition.new(self)
|
||||||
end
|
end
|
||||||
alias lup_decomposition lup
|
alias_method :lup_decomposition, :lup
|
||||||
|
|
||||||
#--
|
#--
|
||||||
# COMPLEX ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
# COMPLEX ARITHMETIC -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||||
@ -1355,7 +1355,7 @@ class Matrix
|
|||||||
def conjugate
|
def conjugate
|
||||||
collect(&:conjugate)
|
collect(&:conjugate)
|
||||||
end
|
end
|
||||||
alias conj conjugate
|
alias_method :conj, :conjugate
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the imaginary part of the matrix.
|
# Returns the imaginary part of the matrix.
|
||||||
@ -1369,7 +1369,7 @@ class Matrix
|
|||||||
def imaginary
|
def imaginary
|
||||||
collect(&:imaginary)
|
collect(&:imaginary)
|
||||||
end
|
end
|
||||||
alias imag imaginary
|
alias_method :imag, :imaginary
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the real part of the matrix.
|
# Returns the real part of the matrix.
|
||||||
@ -1393,7 +1393,7 @@ class Matrix
|
|||||||
def rect
|
def rect
|
||||||
[real, imag]
|
[real, imag]
|
||||||
end
|
end
|
||||||
alias rectangular rect
|
alias_method :rectangular, :rect
|
||||||
|
|
||||||
#--
|
#--
|
||||||
# CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
# CONVERTING -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||||
@ -2045,7 +2045,7 @@ class Vector
|
|||||||
els = @elements.collect(&block)
|
els = @elements.collect(&block)
|
||||||
self.class.elements(els, false)
|
self.class.elements(els, false)
|
||||||
end
|
end
|
||||||
alias map collect
|
alias_method :map, :collect
|
||||||
|
|
||||||
#
|
#
|
||||||
# Returns the modulus (Pythagorean distance) of the vector.
|
# Returns the modulus (Pythagorean distance) of the vector.
|
||||||
@ -2054,8 +2054,8 @@ class Vector
|
|||||||
def magnitude
|
def magnitude
|
||||||
Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2})
|
Math.sqrt(@elements.inject(0) {|v, e| v + e.abs2})
|
||||||
end
|
end
|
||||||
alias r magnitude
|
alias_method :r, :magnitude
|
||||||
alias norm magnitude
|
alias_method :norm, :magnitude
|
||||||
|
|
||||||
#
|
#
|
||||||
# Like Vector#collect2, but returns a Vector instead of an Array.
|
# Like Vector#collect2, but returns a Vector instead of an Array.
|
||||||
|
@ -43,7 +43,7 @@ class Matrix
|
|||||||
def eigenvector_matrix
|
def eigenvector_matrix
|
||||||
Matrix.send(:new, build_eigenvectors.transpose)
|
Matrix.send(:new, build_eigenvectors.transpose)
|
||||||
end
|
end
|
||||||
alias v eigenvector_matrix
|
alias_method :v, :eigenvector_matrix
|
||||||
|
|
||||||
# Returns the inverse of the eigenvector matrix +V+
|
# Returns the inverse of the eigenvector matrix +V+
|
||||||
#
|
#
|
||||||
@ -52,7 +52,7 @@ class Matrix
|
|||||||
r = r.transpose.inverse unless @symmetric
|
r = r.transpose.inverse unless @symmetric
|
||||||
r
|
r
|
||||||
end
|
end
|
||||||
alias v_inv eigenvector_matrix_inv
|
alias_method :v_inv, :eigenvector_matrix_inv
|
||||||
|
|
||||||
# Returns the eigenvalues in an array
|
# Returns the eigenvalues in an array
|
||||||
#
|
#
|
||||||
@ -73,7 +73,7 @@ class Matrix
|
|||||||
def eigenvalue_matrix
|
def eigenvalue_matrix
|
||||||
Matrix.diagonal(*eigenvalues)
|
Matrix.diagonal(*eigenvalues)
|
||||||
end
|
end
|
||||||
alias d eigenvalue_matrix
|
alias_method :d, :eigenvalue_matrix
|
||||||
|
|
||||||
# Returns [eigenvector_matrix, eigenvalue_matrix, eigenvector_matrix_inv]
|
# Returns [eigenvector_matrix, eigenvalue_matrix, eigenvector_matrix_inv]
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user