Matrix#
- class swordfish._swordfishcpp.Matrix#
Represents a two-dimensional matrix.
- classmethod from_numpy(data, type=None)#
Constructs a Matrix object from a one-dimensional or two-dimensional NumPy ndarray.
- Parameters:
data (np.ndarray) – A 1D or 2D NumPy array to be converted into a Matrix.
type (DataType, optional) – An enumeration value from the DataType enum, specifying the target data type for the matrix elements. If None, the type will be inferred from the NumPy array’s dtype.
- Returns:
A new Matrix object containing the data from the input NumPy array.
- Return type:
- to_numpy()#
Converts the Matrix to a two-dimensional NumPy ndarray.
- Returns:
A 2D NumPy array containing the data from the Matrix.
- Return type:
np.ndarray
- to_list()#
Converts the Matrix to a nested Python list.
- Returns:
A list of lists representing the Matrix. Each inner list corresponds to a column of the Matrix.
- Return type:
list