new

new(rows, column_count = rows[0].size) Class Public methods ::new is private; use ::rows, columns, [], etc⦠to create.

identity

identity(n) Class Public methods Creates an n by n identity matrix. Matrix.identity(2) => 1 0 0 1 unit I

empty

empty(row_count = 0, column_count = 0) Class Public methods Creates a empty matrix of row_count x column_count. At least one of row_count or column_count must be 0. m = Matrix.empty(2, 0) m == Matrix[ [], [] ] => true n = Matrix.empty(0, 3) n == Matrix.columns([ [], [], [] ]) => true m * n => Matrix[[0, 0, 0], [0, 0, 0]]

diagonal

diagonal(*values) Class Public methods Creates a matrix where the diagonal elements are composed of values. Matrix.diagonal(9, 5, -3) => 9 0 0 0 5 0 0 0 -3

columns

columns(columns) Class Public methods Creates a matrix using columns as an array of column vectors. Matrix.columns([[25, 93], [-1, 66]]) => 25 -1 93 66

column_vector

column_vector(column) Class Public methods Creates a single-column matrix where the values of that column are as given in column. Matrix.column_vector([4,5,6]) => 4 5 6

build

build(row_count, column_count = row_count) Class Public methods Creates a matrix of size row_count x column_count. It fills the values by calling the given block, passing the current row and column. Returns an enumerator if no block is given. m = Matrix.build(2, 4) {|row, col| col - row } => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]] m = Matrix.build(3) { rand } => a 3x3 matrix with random elements

[]

[](*rows) Class Public methods Creates a matrix where each argument is a row. Matrix[ [25, 93], [-1, 66] ] => 25 93 -1 66

I

I(n) Class Public methods Alias for: identity

u

u() Instance Public methods Returns the upper triangular factor U