Returns true
iff the current severity level allows for the printing of WARN
messages.
Sets the severity to WARN.
Returns true
iff the current severity level allows for the printing of ERROR
messages.
Sets the severity to ERROR.
Creates an n
by n
diagonal matrix where each diagonal element is value
.
Matrix.scalar(2, 5) # => 5 0 # 0 5
Create a matrix by combining matrices entrywise, using the given block
x = Matrix[[6, 6], [4, 4]] y = Matrix[[1, 2], [3, 4]] Matrix.combine(x, y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
Creates new matrix by combining with other_matrices entrywise, using the given block.
x = Matrix[[6, 6], [4, 4]] y = Matrix[[1, 2], [3, 4]] x.combine(y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
Returns true
if this is a regular (i.e. non-singular) matrix.
Returns true
if this is a singular matrix.
Returns true
if this is a square matrix.
Returns true
if this is a unitary matrix Raises an error if matrix is not square.
Returns the rank 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]].rank # => 2
deprecated; use Matrix#rank
Returns the trace (sum of diagonal elements) of the matrix.
Matrix[[7,6], [3,9]].trace # => 16
Returns the transpose of the matrix.
Matrix[[1,2], [3,4], [5,6]] # => 1 2 # 3 4 # 5 6 Matrix[[1,2], [3,4], [5,6]].transpose # => 1 3 5 # 2 4 6
Returns the imaginary part of the matrix.
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]] # => 1+2i i 0 # 1 2 3 Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary # => 2i i 0 # 0 0 0