Next: Graphs and partial orders
Up: Miscellaneous
Previous: text_lines
Index
In matrix.diesel:
A matrix is a two-dimensional indexable collection.
Matrices support querying the number of rows and columns of a
matrix, extracting an element, a row, or a column of the matrix. The
do and indices_do
methods support iterating over the
matrix. Conformable matrices can be added and multiplied. A matrix
of comparable values is itself comparable, pointwise. Mutable
matrices support changing a given matrix element.
One concrete implementation of matrices exists, based on
representing matrices by a vector of vectors. The
new_vector_matrix_init
functions supports creating a new
vector_matrix
of a given size with its elements initialized as
specified by the init_fn
closure.
module Matrix;
abstract class matrix[T];
fun num_rows(:matrix[`T]):int;
fun num_cols(:matrix[`T]):int;
fun fetch(:matrix[`T], row:int, col:int):T;
fun row(m:matrix[`T], row:int):indexed[T];
fun col(m:matrix[`T], col:int):indexed[T];
fun rows(m:matrix[`T]):indexed[indexed[T]];
fun indices_do(m:matrix[`T], c:&(int,int):void):void;
fun do(m:matrix[`T], c:&(int,int,T):void):void;
fun +(m1:matrix[`T <= num], m2:matrix[T]):matrix[T];
fun *(m1:matrix[`T >= int <= num], m2:matrix[T]):matrix[T];
fun *_ugly(m1:matrix[`T >= int <= num], m2:matrix[T]):matrix[T];
extend class matrix[`T <= comparable[T]] isa comparable[matrix[T]];
fun copy_init(m:matrix[`T], num_rows:int, num_cols:int,
init:&(int,int):T):matrix[T];
fun copy_init[T](:matrix[T], num_rows:int, num_cols:int,
init:&(int,int):T):matrix[T];
fun copy_mutable_init(m:matrix[`T], num_rows:int, num_cols:int,
init:&(int,int):T):m_matrix[T];
fun copy_mutable_init[T](:matrix[T], num_rows:int, num_cols:int,
init:&(int,int):T):m_matrix[T];
abstract class m_matrix[T] isa matrix[T];
fun store(:matrix[`T], row:int, col:int, value:T):void;
class vector_matrix[T] isa m_matrix[T];
fun new_vector_matrix_init[T](num_rows:int, num_cols:int,
init:&(int,int):T):m_matrix[T];
Next: Graphs and partial orders
Up: Miscellaneous
Previous: text_lines
Index
Cecil/Vortex Project