dynpy.mx - Matrix utilities module¶
Module which provides a consistent interface for working with both dense arrays and sparse matrices. Also constains some utility functions for working with matrices.
- class dynpy.mx.StateBase[source]¶
Bases:
object
Base class for managing objects which hold state of dynamical system
- class dynpy.mx.IntScalar[source]¶
Bases:
StateBase
- class dynpy.mx.MxBase[source]¶
Bases:
StateBase
Base class from which sparse and dense matrix operation classes inherit
- classmethod format_obj(obj)[source]¶
Format object obj into the current class’s preferred type (e.g., convert a dense matrix to sparse, or vice-versa, as appropriate)
- classmethod create_editable_zeros_mx(shape, dtype=None)[source]¶
Create blank editable transition matrix, of size specified by shape
- classmethod get_largest_right_eigs(mx)[source]¶
Get largest right eigenvectors and eigenvalues of matrix mx
- classmethod get_largest_left_eigs(mx)[source]¶
Get largest left eigenvectors and eigenvalues of matrix mx
- Returns:
- 1-dimensional numpy array
Eigenvalues
- 2-dimensional numpy array
Eigenvectors
- classmethod array_equal(mx, other_mx)[source]¶
Return True if mx and other_mx are equal (including nan’s, unlike numpy’s array_equal
- classmethod from_coords(rows, cols, data, shape)[source]¶
Initialize matrix using data and row, column coordinates. Duplicates should be summed
- classmethod vstack(data)¶
Stack states vertically
- class dynpy.mx.SparseMatrix[source]¶
Bases:
MxBase
Class for sparse matrix operations. See documentation for
dynpy.mx.MxBase
for description of methods.- classmethod create_editable_zeros_mx(shape, dtype=None)[source]¶
Create blank editable transition matrix, of size specified by shape
- classmethod get_largest_right_eigs(mx)[source]¶
Get largest right eigenvectors and eigenvalues of matrix mx
- classmethod from_coords(rows, cols, data, shape)[source]¶
Initialize matrix using data and row, column coordinates. Duplicates should be summed
- classmethod array_equal(mx, other_mx)¶
Return True if mx and other_mx are equal (including nan’s, unlike numpy’s array_equal
- classmethod format_obj(obj)¶
Format object obj into the current class’s preferred type (e.g., convert a dense matrix to sparse, or vice-versa, as appropriate)
- classmethod get_largest_left_eigs(mx)¶
Get largest left eigenvectors and eigenvalues of matrix mx
- Returns:
- 1-dimensional numpy array
Eigenvalues
- 2-dimensional numpy array
Eigenvectors
- class dynpy.mx.DenseMatrix[source]¶
Bases:
MxBase
Class for dense matrix operations. See documentation for
dynpy.mx.MxBase
for description of methods.- classmethod get_largest_right_eigs(mx)[source]¶
Get largest right eigenvectors and eigenvalues of matrix mx
- classmethod create_editable_zeros_mx(shape, dtype=None)[source]¶
Create blank editable transition matrix, of size specified by shape
- classmethod array_equal(mx, other_mx)[source]¶
Return True if mx and other_mx are equal (including nan’s, unlike numpy’s array_equal
- classmethod from_coords(rows, cols, data, shape)[source]¶
Initialize matrix using data and row, column coordinates. Duplicates should be summed
- classmethod format_obj(obj)¶
Format object obj into the current class’s preferred type (e.g., convert a dense matrix to sparse, or vice-versa, as appropriate)
- classmethod get_largest_left_eigs(mx)¶
Get largest left eigenvectors and eigenvalues of matrix mx
- Returns:
- 1-dimensional numpy array
Eigenvalues
- 2-dimensional numpy array
Eigenvectors
- class dynpy.mx.hashable_array(data)[source]¶
Bases:
ndarray
This class provides a hashable and sortable np.array. This is useful for using np.array as dicitionary keys, for example.
Notice that hashable arrays change the default behavior of numpy arrays for equality and comparison operators. Instead of performing element-wise tests, hashable arrays return a value for the array as a whole