Sets the severity to ERROR.
logdev
The log device. This is a filename (String
) or IO
object (typically STDOUT
, STDERR
, or an open file). reopen the same filename if it is nil
, do nothing for IO
. Default is nil
.
Reopen a log device.
Create a matrix by stacking matrices vertically
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
Create a matrix by stacking matrices horizontally
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] Matrix.hstack(x, y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
Returns a section of the matrix. The parameters are either:
start_row, nrows, start_col, ncols; OR
row_range, col_range
Matrix.diagonal(9, 5, -3).minor(0..1, 0..2) # => 9 0 0 # 0 5 0
Like Array#[]
, negative indices count backward from the end of the row or column (-1 is the last element). Returns nil if the starting row or column is greater than row_count
or column_count
respectively.
Returns true
if this is a normal matrix. Raises an error if matrix is not square.
Returns true
if this is an orthogonal matrix Raises an error if matrix is not square.
Returns true
if all entries of the matrix are real.
Returns true
if this is a regular (i.e. non-singular) matrix.
Returns true
if this is a square matrix.
Returns a new matrix resulting by stacking horizontally the receiver with the given matrices
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] x.hstack(y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
Returns a new matrix resulting by stacking vertically the receiver with the given matrices
x = Matrix[[1, 2], [3, 4]] y = Matrix[[5, 6], [7, 8]] x.vstack(y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
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
Returns the real 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]].real # => 1 0 0 # 1 2 3
Returns an array containing matrices corresponding to the real and imaginary parts of the matrix
m.rect == [m.real, m.imag] # ==> true for all matrices m
Returns an array of arrays that describe the rows of the matrix.
Overrides Object#to_s
Makes the matrix frozen and Ractor-shareable
Returns a new vector with the same direction but with norm 1.
v = Vector[5,8,2].normalize # => Vector[0.5184758473652127, 0.8295613557843402, 0.20739033894608505] v.norm # => 1.0
Returns the elements of the vector in an array.
Overrides Object#to_s