jet.bindings.TensorNetworkSerializerC64

class TensorNetworkSerializerC64

Bases: pybind11_builtins.pybind11_object

TensorNetworkSerializer represents a functor for serializing (and deserializing) a tensor network and contraction path to (and from) a JSON document.

If called with a tensor network (and optionally a contraction path), the tensor network serializer will return a JSON string representing the given arguments.

If called with a string, the tensor network serializer will parse the string as a JSON object and return a tensor network file instance. The object must contain a “tensors” key containing an array of tensors. It may optionally contain a “path” key describing a contraction path.

Each element of the "tensors" array is an array with four elements containing the tags, ordered indices, shape, and values of each tensor, respectively. Each value is an array of size two, representing the real and imaginary components of a complex number. For example,

[
    ["A", "hermitian"],
    ["a", "b"],
    [2, 2],
    [[1.0, 0.0], [0.0, 1.0], [0.0, -1.0], [1.0, 0.0]]
]

corresponds to the 2x2 matrix

[[1, i], [-i, 1]]

where “a” is the row index and “b” is the column index.

The “path” value is a list of integer pairs such as [i, j] where i and j are the indexes of two tensors in the "tensors" array (or the index of an intermediate tensor).

Parameters

indent (int) – Indentation level to use when serializing to JSON. The default value (-1) uses the most compact representation.

dtype

dtype

__call__(*args, **kwargs)

Overloaded function.

__call__(*args, **kwargs)

Overloaded function.

  1. __call__(self: jet.bindings.TensorNetworkSerializerC64, tn: jet.bindings.TensorNetworkC64) -> str

Dumps the given tensor network to a JSON string.

Parameters

tn (TensorNetwork) – Tensor network to serialize.

Returns

Serialized tensor network file representing the given tensor network.

Return type

str

  1. __call__(self: jet.bindings.TensorNetworkSerializerC64, tn: jet.bindings.TensorNetworkC64, path: jet.bindings.PathInfo) -> str

Dumps the given tensor network and path to a JSON string.

Parameters
  • tn (TensorNetwork) – Tensor network to serialize.

  • path (PathInfo) – Contraction path to serialize.

Returns

Serialized tensor network file representing the given tensor network and contraction path.

Return type

str

  1. __call__(self: jet.bindings.TensorNetworkSerializerC64, str: str) -> jet.bindings.TensorNetworkFileC64

Loads a tensor network file from a JSON string.

Parameters

str (str) – JSON string representing a serialized tensor network file.

Returns

Deserialized tensor network file representing a tensor network (and contraction path, if specified).

Return type

TensorNetworkFile