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.

Parameters:
  • 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.

Returns:

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

Return type:

Vector

classmethod from_tuple(data, type=None)#

Constructs a Vector object from a Python tuple.

Parameters:
  • 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.

Returns:

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

Return type:

Vector

classmethod from_numpy(data, type=None)#

Constructs a Vector object from a NumPy array.

Parameters:
  • 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.

Returns:

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

Return type:

Vector

to_numpy()#

Converts the Vector object to a NumPy ndarray.

Returns:

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

Return type:

np.ndarray

to_list()#

Converts the Vector object to a Python list.

Returns:

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

Return type:

list