quantax.utils.LogArray#
- class quantax.utils.LogArray#
Log-amplitude representation of JAX arrays: value = sign * exp(logabs) where
signis \(\pm 1\) or a complex phase andlogabsis real. Zero is encoded by sign=0, logabs=-inf.The array is a PyTree with two leaves:
signandlogabs. To convert it to a dense JAX array, usearr.value()orjnp.asarray(arr).Warning
JAX doesn’t have a full support for customized arrays, so one should be careful when using
LogArray. Here we list several possible problems.1. Manipulations like
jnp.fn(array)transform customized arrays toArray. To avoid it, callarray.fn()whenever possible.2. Computations like
jax_array * customized_arrayalways calljax_array.__mul__(customized_array), which returns aArray. To avoid it, usecustomized_array * jax_array.- __array__(dtype=None) NDArray#
Convert to a numpy array.
- property shape: tuple[int, ...]#
The shape of the represented array.
- property ndim: int#
The number of dimensions of the represented array.
- property size: int#
The total number of elements in the represented array.
- property nbytes: int#
The total number of bytes consumed by the represented array.
- sum(axis: int | tuple[int, ...] | None = None, keepdims: bool = False) LogArray#
Sum of array elements over a given axis.