There are several different classes in libsemigroups for representing matrices over various semirings. There are up to three different representations for every type of matrix:

  1. those whose dimension and arithmetic operations can be defined at compile time: StaticMatrix.

  2. those whose arithmetic operation can be defined at compile time but whose dimesions can be set at run time: DynamicMatrix

  3. those whose arithmetic operation and dimensions can be set at run time: DynamicMatrix

It’s unlikely that you will want to use the classes in described on this page directly, but rather through the aliases described on the other matrix pages (such as, for example, BMat).

Over specific semirings

The following matrix classes are provided which define matrices over some specific semirings:

Over arbitrary semirings

The following general matrix classes are provided which can be used to define matrices over arbitrary semirings:

Row views

A row view is a lightweight representations of a row of matrix. The following row view classes are provided:


The namespace matrix_helpers contains a number of helper functions for certain types of matrices:


There are various specialisations of the adapters described on this page<Adapters> for the matrices desribed on this page: