class Apatite::LinearAlgebra::Matrix

Included Modules

Defined in:

apatite/linear_algebra/matrix.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(rows, column_count : Int32 = rows[0].size) #

[View source]

Class Method Detail

def self.[](*rows) #

Creates a matrix where each argument is a row.


[View source]
def self.build(row_count, column_count = row_count, &block) #

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.


[View source]
def self.col_vector(column) #

Creates a single-column matrix where the values of that column are as given in column.


[View source]
def self.columns(columns) #

Creates a matrix using .columns as an array of column vectors.


[View source]
def self.diagonal(values) #

Creates a matrix where the diagonal elements are composed of values.


[View source]
def self.diagonal(*values) #

Creates a matrix where the diagonal elements are composed of values.


[View source]
def self.empty(row_count = 0, column_count = 0) #

Creates a empty matrix of row_count x column_count. At least one of #row_count or #column_count must be 0.


[View source]
def self.hstack(x, *matrices) #

TODO


[View source]
def self.identity(n) #

Creates a n x n identity matrix.


[View source]
def self.row_vector(row) #

Creates a single-row matrix where the values of that row are as given in #row.


[View source]
def self.rows(rows) #

Creates a matrix where rows is an array of arrays, each of which is a row of the matrix.


[View source]
def self.scalar(n, value) #

Creates an n by n diagonal matrix where each diagonal element is value.


[View source]
def self.vstack(x, y) #

TODO


[View source]
def self.zero(row_count, column_count = row_count) #

Creates a zero matrix.


[View source]

Instance Method Detail

def *(other : Matrix) #

[View source]
def *(int : Int) #

[View source]
def *(ind : Indexable) #

[View source]
def **(int) #

[View source]
def +(other : Matrix) #

[View source]
def +(vec : Indexable) #

[View source]
def -(vec : Indexable) #

[View source]
def -(other : Matrix) #

[View source]
def /(other : Matrix) #

[View source]
def /(vec : Indexable) #

[View source]
def ==(other : Matrix) #

[View source]
def [](row : Int, col : Int) #

Returns element (row, col) of the matrix. Throws error on index error.


[View source]
def []?(row : Int, col : Int) #

Returns element (row, col) of the matrix, or nil if the index is not found.


[View source]
def adjugate #

Returns the adjugate of the matrix.


[View source]
def cofactor(row, column) #

Returns the (row, column) cofactor which is obtained by multiplying the first minor by (-1)**(row + column)


[View source]
def column(j, &block) #

Iterates over the specified column in the matrix, returning the Vector's items.


[View source]
def column(j) #

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).


[View source]
def column?(j) #

Returns column vector number j of the matrix as a Vector (starting at 0 like an array).


[View source]
def column_count : Int32 #

[View source]
def column_vectors #

Returns an array of the column vectors of the matrix. See Vector.


[View source]
def determinant #

[View source]
def first_minor(row, column) #

[View source]
def inverse #

Returns the inverse of the matrix.


[View source]
def laplace_expansion(*, row = nil, column = nil) #

Returns the Laplace expansion along given row or column.


[View source]
def pretty_print(pp) : Nil #

[View source]
def row(i, &block) #

[View source]
def row(i) #

[View source]
def row_count : Int32 #

[View source]
def rows #

[View source]
def square? #

[View source]
def to_s(io) #

[View source]
def transpose #

[View source]
def unsafe_fetch(index : Int) #

[View source]