DynamicMatrix (with run time arithmetic)

Defined in matrix.hpp.

template<typename Semiring, typename Scalar>
class DynamicMatrix final

This is a class for matrices where both the arithmetic operations in the underlying semiring and the dimensions of the matrix can be set at run time.

Template Parameters
  • Semiring – the type of a semiring object which defines the semiring arithmetic (see requirements below).

  • Scalar – the type of the entries in the matrices (the type of elements in the underlying semiring)

Note

Certain member functions only work for square matrices and some only work for rows.

Semiring requirements

The template parameter Semiring must have the following member functions:

  • scalar_type zero() that returns the multiplicative zero scalar in the semiring

  • scalar_type one() that returns the multiplicative identity scalar in the semiring

  • scalar_type plus(scalar_type x, scalar_type y) that returns the sum in the semiring of the scalars x and y.

  • scalar_type prod(scalar_type x, scalar_type y) that returns the product in the semiring of the scalars x and y.

See, for example, MaxPlusTruncSemiring.

Member types

Member type

Definition

scalar_type

the type of scalars contained in the matrix (Scalar)

scalar_reference

the type of references to scalars contained in the matrix

scalar_const_reference

the type of const references to scalars contained in the matrix

Row

type of a row of the matrix

RowView

type of a row view int the matrix

semiring_type

the template parameter Semiring.

Member functions

(constructor)

constructs the matrix

number_of_rows/number_of_cols

the number of rows/columns in the matrix

semiring

returns a pointer to the semiring defining the arithmetic

Static member functions

make

constructs a matrix and checks that its entries are valid

identity

constructs an identity matrix

Iterators

begin/cbegin

returns an iterator to the beginning

end/cend

returns an iterator to the end

coords

returns the coordinates corresponding to an iterator

Accessors

operator()

access specified element

row

access specified row

rows

add all rows to a container

Arithmetic operators

operator+=

add a (matrix, scalar, or row view) to the matrix in place

operator*=

multiply the matrix by a matrix or scalar in place

operator+

add a (matrix, scalar, or row view) to the matrix

operator*

multiply the matrix by a matrix or scalar

Comparison operators

operator==

compare matrices

operator!=

compare matrices

operator<

compare matrices

operator>

compare matrices

Modifiers

swap

swaps the contents

transpose

transposes the matrix