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.

参数:
  • 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.

返回:

A new Matrix object containing the data from the input NumPy array.

返回类型:

Matrix

to_numpy()#

Converts the Matrix to a two-dimensional NumPy ndarray.

返回:

A 2D NumPy array containing the data from the Matrix.

返回类型:

np.ndarray

to_list()#

Converts the Matrix to a nested Python list.

返回:

A list of lists representing the Matrix. Each inner list corresponds to a column of the Matrix.

返回类型:

list