banded matrix, heap-allocated
Constructors
new(nrows : Int32, ncolumns : Int32, upper_band : Int32, lower_band : Int32, values : Indexable)
Sourcenew(nrows, ncolumns, upper_band, values : Indexable)
Sourcenew(nrows :
Int32, ncolumns :
Int32, upper_band :
Int32, lower_band :
Int32 = upper_band, flags :
LA::MatrixFlags =
MatrixFlags::None)
Sourcenew(nrows :
Int32, ncolumns :
Int32, upper_band :
Int32, lower_band :
Int32 = upper_band, flags :
LA::MatrixFlags =
MatrixFlags::None, &)
Sourcenew(matrix : BandedMatrix)
Sourcenew(matrix : Matrix, tolerance = matrix.tolerance)
SourceClass methods
diag(nrows, ncolumns, values)
Sourceestimate(matrix : Matrix(T), tolerance = matrix.tolerance)
Sourcerand(nrows, ncolumns, upper_band : Int32, lower_band : Int32, rng : Random = Random::DEFAULT)
Sourcerand(nrows, ncolumns, upper_band : Int32, rng : Random = Random::DEFAULT)
SourceInstance methods
-(m : BandedMatrix(T))
returns element-wise subtract
Source==(other : BandedMatrix(T))
SourcePerform inplace addition with matrix m multiplied to scalar k
a.add!(k, b) is equal to a = a + k * b, but faster as no new matrix is allocated
Sourceconjtranspose
returns conjtransposed matrix
Sourcedet(*, overwrite_a = false)
Calculates determinant for a square matrix
if overwrite_a is true, a will be overriden in process of calculation
Uses getrf LAPACK routine
Sourcedup
Returns a shallow copy of this object.
This allocates a new object and copies the contents of
self into it.
Sourceeach_index(*, all = false, &)
Yields every index
all argument controls whether to yield all or non-empty elements for banded\sparse matrices
Example:
m.each_index { |i, j| m[i, j] = -m[i, j] }
Sourceflags
Returns flags of matrix (see MatrixFlags)
Sourceflags=(flags : MatrixFlags)
Returns flags of matrix (see MatrixFlags)
Sourcemap_with_index
Returns result of appliyng block to every element with index
Sourcencolumns
Returns number of columns in matrix
Sourcenorm(kind : MatrixNorm = MatrixNorm::Frobenius)
Sourcenrows
Returns number of rows in matrix
Sourceset_bands(aupper, alower) : Nil
Sourcesolve(b : GeneralMatrix(T), *, overwrite_a = false, overwrite_b = false)
Sourceto_unsafe
Returns pointer to underlying data
Storage format depends of matrix type
This method raises at runtime if matrix doesn't have raw pointer
Sourcetranspose
returns transposed matrix
Sourcetril(k = 0)
Same as tril in scipy - returns lower triangular or trapezoidal part of matrix
Returns a matrix with all elements above k-th diagonal zeroed
Sourcetril!(k = 0)
Works like a tril in scipy - remove all elements above k-diagonal
Sourcetriu(k = 0)
Same as triu in scipy - returns upper triangular or trapezoidal part of matrix
Returns a matrix with all elements below k-th diagonal zeroed
Sourcetriu!(k = 0)
Works like a triu in scipy - remove all elements below k-diagonal
Source