Struct dyn_matrix

Struct Documentation

struct dyn_matrix

Representation of a dynamically-sized matrix using a dynamic array row vectors, with each row vector also being a dynamic array.

Dynamic in the sense that the matrix dimensions can be changed after initialization. The matrix can grow to be any size, but an initial size can be specified during initialization, as the resizing operation can be very expensive, depending on the current size of the matrix. Assumes row-major order (this is C after all).

Should only be used for applications where the matrix is dense, or when the dimensions of the matrix are small (if the dimensions are large AND the matrix is sparse, it will definitely be really inefficient, and possibly won’t even fit into memory). In addition, this data structure should really only be used if you can guarantee that resizing the matrix happens infrequently.

The matrix is never resized autonomously.

Public Members

struct darray *rows

Vector of row vectors.

size_t n_rows

Number of rows in matrix.

size_t n_cols

Number of columns in matrix.

size_t elt_size

Size of matrix elements in bytes.

uint32_t flags

Configuration flags. Valid flags are:

All other flags are ignored.

void (*printe)(const void *const e)

For printing an element. Can be NULL. If NULL, then dyn_matrix_print() is disabled.