Vector#

class swordfish._swordfishcpp.Vector#

Represents a one-dimensional vector.

Inherits from the Constant class and provides functionality for working with vector data structures. Supports conversion to/from Python lists, tuples, and NumPy arrays.

classmethod from_list(data, type=None)#

Constructs a Vector object from a Python list.

参数:
  • data (list) -- The input data as a Python list instance.

  • type (DataType, optional) -- An enumeration value from the DataType enum, specifying the target data type for the vector elements.

返回:

A new Vector object containing the data from the input list, converted to the specified data type.

返回类型:

Vector

classmethod from_tuple(data, type=None)#

Constructs a Vector object from a Python tuple.

参数:
  • data (tuple) -- The input data as a Python tuple instance.

  • type (DataType, optional) -- An enumeration value from the DataType enum, specifying the target data type for the vector elements.

返回:

A new Vector object containing the data from the input tuple, converted to the specified data type.

返回类型:

Vector

classmethod from_numpy(data, type=None)#

Constructs a Vector object from a NumPy array.

参数:
  • data (np.ndarray) -- The input data as a 1-dimensional ndarray.

  • type (DataType, optional) -- An enumeration value from the DataType enum, specifying the target data type for the vector elements.

返回:

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

返回类型:

Vector

to_numpy()#

Converts the Vector object to a NumPy ndarray.

返回:

A new 1-dimensional NumPy array containing all the elements of the Vector.

返回类型:

np.ndarray

to_list()#

Converts the Vector object to a Python list.

返回:

A new Python list containing all the elements of the Vector.

返回类型:

list