sdynpy.core.sdynpy_matrix.Matrix
- class Matrix(shape, nrows, ncols, is_complex=False, buffer=None, offset=0, strides=None, order=None)[source]
Bases:
SdynpyArray
Matrix with degrees of freedom stored for better bookkeeping.
Use the matrix helper function to create the object.
- __init__()
Methods
Returns indices used to sort the coordinates on the rows and columns
data_dtype
(rows, columns[, is_complex])Data type of the underlying numpy structured array for real shapes
eye
(row_coordinate[, column_coordinate])Creates an identity matrix with the specified coordinates
plot
([ax, show_colorbar])Plots the matrix with coordinates labeled
Returns a copy of the Matrix with coordinate sorted
Attributes
Returns the full coordinate array for the matrix
Returns the number of coordinate columns
Returns the number of coordinate rows
- argsort_coordinate()[source]
Returns indices used to sort the coordinates on the rows and columns
- Returns
row_indices – Indices used to sort the row coordinates.
column_indices – Indices used to sort the column coordinates
- property coordinate
Returns the full coordinate array for the matrix
- static data_dtype(rows, columns, is_complex=False)[source]
Data type of the underlying numpy structured array for real shapes
- Parameters
rows (int) – Number of rows in the matrix
columns (int) – Number of columns in the matrix
- Returns
Numpy dtype that can be passed into any of the numpy array constructors
- Return type
list
- classmethod eye(row_coordinate, column_coordinate=None)[source]
Creates an identity matrix with the specified coordinates
- Parameters
row_coordinate (CoordinateArray) – Coordinate array to use as the row coordinates
column_coordinate (CoordinateArray, optional) – Coordinate array to use as the column coordinates. If not specified, the row coordinates are used.
- Returns
Diagonal matrix with the specified coordinates
- Return type
- property num_coordinate_columns
Returns the number of coordinate columns
- property num_coordinate_rows
Returns the number of coordinate rows
- plot(ax=None, show_colorbar=True, **imshow_args)[source]
Plots the matrix with coordinates labeled
- Parameters
ax (axis, optional) – Axis on which the matrix will be plotted. If not specified, a new figure will be created.
show_colorbar (bool, optional) – If true, show a colorbar. Default is true.
**imshow_args (various) – Additional arguments passed to imshow
- Raises
ValueError – Raised if matrix is multi-dimensional.