Ruby Matrix Functions
EditRocket provides the following information on Matrix functions in the Ruby source code builder.
clone() - Returns a clone of the matrix, so that the contents of each do not reference identical objects.
coerce(other) - "FIXME: describe #coerce."
collect( {|e| ...} - Returns a matrix that is the result of iteration of the given block over all elements of the matrix.
column(j) - Returns column vector number j of the matrix as a Vector (starting at 0 like an array). When a block is given, the elements of that vector are iterated.
column_size() - Returns the number of columns. Note that it is possible to construct a matrix with uneven columns (e.g. Matrix[ [1,2,3], [4,5] ]), but this is mathematically unsound. This method uses the first row to determine the result.
column_vector(column) - Creates a single-column matrix where the values of that column are as given in column.
column_vectors() - Returns an array of the column vectors of the matrix. See Vector.
columns(columns) - Creates a matrix using columns as an array of column vectors.
compare_by_row_vectors(rows) - Not really intended for general consumption.
det() - "Alias for #determinant"
determinant() - Returns the determinant of the matrix. If the matrix is not square, the result is 0.
diagonal(*values) - Creates a matrix where the diagonal elements are composed of values.
eql?(other) - "Alias for #=="
hash() - Returns a hash-code for the matrix.
identity(n) - Creates an n by n identity matrix.
inspect() - Overrides Object#inspect
inv() - "Alias for #inverse"
inverse() - Returns the inverse of the matrix.
inverse_from(src) - Not for public consumption?
map( - "Alias for #collect"
minor(*param) - "Returns a section of the matrix. The parameters are either:"
new(init_method, *argv) - This method is used by the other methods that create matrices, and is of no use to general users.
rank() - Returns the rank of the matrix. Beware that using Float values, with their usual lack of precision, can affect the value returned by this method. Use Rational values instead if this is important to you.
regular?() - Returns true if this is a regular matrix.
row(i) - Returns row vector number i of the matrix as a Vector (starting at 0 like an array). When a block is given, the elements of that vector are iterated.
row_size() - Returns the number of rows.
row_vector(row) - Creates a single-row matrix where the values of that row are as given in row.
row_vectors() - Returns an array of the row vectors of the matrix. See Vector.
rows(rows, copy = true) - Creates a matrix where rows is an array of arrays, each of which is a row to the matrix. If the optional argument copy is false, use the given arrays as the internal structure of the matrix without copying.
scalar(n, value) - Creates an n by n diagonal matrix where each diagonal element is value.
singular?() - Returns true is this is a singular (i.e. non-regular) matrix.
square?() - Returns true is this is a square matrix. See note in column_size about this being unreliable, though.
t() - "Alias for #transpose"
to_a() - Returns an array of arrays that describe the rows of the matrix.
to_s() - Overrides Object#to_s
tr() - "Alias for #trace"
trace() - Returns the trace (sum of diagonal elements) of the matrix.
transpose() - Returns the transpose of the matrix.
zero(n) - Creates an n by n zero matrix.