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 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: str | type[Any] | dtype | SupportsDType | None = None) NDArray#
Convert to a numpy array.
- astype(dtype: str | type[Any] | dtype | SupportsDType) LogArray#
Cast the represented array to given dtype.
- sum(axis: int | tuple[int, ...] | None = None, keepdims: bool = False) LogArray#
Sum of array elements over a given axis.