зеркало из https://github.com/github/ruby.git
* lib/matrix.rb (Matrix#singular?, Matrix#regular?): raise on rectangular
matrices, and use determinant instead of rank. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
4e6a29e083
Коммит
a3a4542fb4
|
@ -478,17 +478,17 @@ class Matrix
|
|||
end
|
||||
|
||||
#
|
||||
# Returns +true+ if this is a regular matrix.
|
||||
# Returns +true+ if this is a regular (i.e. non-singular) matrix.
|
||||
#
|
||||
def regular?
|
||||
square? and rank == column_size
|
||||
not singular?
|
||||
end
|
||||
|
||||
#
|
||||
# Returns +true+ is this is a singular (i.e. non-regular) matrix.
|
||||
# Returns +true+ is this is a singular matrix.
|
||||
#
|
||||
def singular?
|
||||
not regular?
|
||||
determinant == 0
|
||||
end
|
||||
|
||||
#
|
||||
|
|
Загрузка…
Ссылка в новой задаче