Returns true
if this is a permutation matrix Raises an error if matrix is not square.
Returns true
if this is a matrix with only zero elements
Returns the inverse of the matrix.
Matrix[[-1, -1], [0, -1]].inverse # => -1 1 # 0 -1
Returns the determinant of the matrix.
Beware that using Float
values can yield erroneous results because of their lack of precision. Consider using exact types like Rational
or BigDecimal
instead.
Matrix[[7,6], [3,9]].determinant # => 45
deprecated; use Matrix#determinant
Returns the Eigensystem of the matrix; see EigenvalueDecomposition
.
m = Matrix[[1, 2], [3, 4]] v, d, v_inv = m.eigensystem d.diagonal? # => true v.inv == v_inv # => true (v * d * v_inv).round(5) == m # => true
The coerce method provides support for Ruby type coercion. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. See also Numeric#coerce
.
Returns true
iff all elements are zero.
The coerce method provides support for Ruby type coercion. This coercion mechanism is used by Ruby to handle mixed-type numeric operations: it is intended to find a compatible common type between the two operands of the operator. See also Numeric#coerce
.
Terminates option parsing. Optional parameter arg
is a string pushed back to be the first non-option argument.
Heading banner preceding summary.
Returns version string from program_name
, version and release.
Parses command line arguments argv
in order. When a block is given, each non-option argument is yielded. When optional into
keyword argument is provided, the parsed option values are stored there via []=
method (so it can be Hash
, or OpenStruct
, or other similar object).
Returns the rest of argv
left unparsed.
Same as order
, but removes switches destructively. Non-option arguments remain in argv
.
Parses command line arguments argv
in permutation mode and returns list of non-option arguments. When optional into
keyword argument is provided, the parsed option values are stored there via []=
method (so it can be Hash
, or OpenStruct
, or other similar object).
Same as permute
, but removes switches destructively. Non-option arguments remain in argv
.
Wrapper method for getopts.rb.
params = ARGV.getopts("ab:", "foo", "bar:", "zot:Z;zot option") # params["a"] = true # -a # params["b"] = "1" # -b1 # params["foo"] = "1" # --foo # params["bar"] = "x" # --bar x # params["zot"] = "z" # --zot Z
Loads options from file names as filename
. Does nothing when the file is not present. Returns whether successfully loaded.
filename
defaults to basename of the program without suffix in a directory ~/.options, then the basename with ‘.options’ suffix under XDG and Haiku standard places.
Looks up the first IP address for name
.