Skip to main content

omnibias.fields.torch.ops.complex

0.2.0rc1Release candidatePython >=3.10Apache-2.0

Structured scalar, vector, and tensor fields with derivative caches, calculus operators, and coordinate conventions.

import omnibias.fields.torch.ops.complex
Module contract & mathematical conventions

Complex (Wirtinger) calculus on a split-real field (torch).

A complex field f = f_R + i f_I is carried as two real components (the convention used by omnibias-qpinn). The Wirtinger derivatives

\partial_z = \tfrac12(\partial_x - i\,\partial_y), \qquad \partial_{\bar z} = \tfrac12(\partial_x + i\,\partial_y),

are returned as (real, imag) tensor pairs, built from the closed-form first derivatives of f_R and f_I. A holomorphic field satisfies dzbar(...) == (0, 0) (the Cauchy-Riemann equations).

Shared formulas do not imply universal floating-point identity. Verify dtype, shape, derivative-order support, and the stated numerical assumptions for the path you use.

FUNCTION

dz​

omnibias.fields.torch.ops.dzSource ↗
dz(state: FieldState, re_name: str, im_name: str, *, real_axis: int | str='x', imag_axis: int | str='y') -> tuple[Tensor, Tensor]

\partial_z f as a (real, imag) pair.

Parameters

NameType & defaultContract
statepositional-or-keywordFieldStateRequiredSee the operation contract and implementation below.
re_namepositional-or-keywordstrRequiredSee the operation contract and implementation below.
im_namepositional-or-keywordstrRequiredSee the operation contract and implementation below.
real_axiskeyword-onlyint | strDefault: 'x'See the operation contract and implementation below.
imag_axiskeyword-onlyint | strDefault: 'y'See the operation contract and implementation below.
Returnstuple[Tensor, Tensor]
Executed regression · dz of exp is exp

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_dz_of_exp_is_exp():  # type: ignore[no-untyped-def]
    from omnibias.fields.torch import _ops_dispatch
    from omnibias.fields.torch.ops.complex import dz

    field = _ExpZField(torch, _ops_dispatch)
    state = field(torch.as_tensor(COORDS, dtype=torch.float64))
    re, im = dz(state, "fR", "fI")
    # d/dz e^z = e^z -> (fR, fI)
    assert np.allclose(_np(re), _np(field.value_component(state, "fR")), atol=1e-12)
    assert np.allclose(_np(im), _np(field.value_component(state, "fI")), atol=1e-12)
python -m pytest "packages/omnibias-fields/tests/test_wirtinger.py::test_dz_of_exp_is_exp" -q
Regression example · wirtinger cross backend

This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_wirtinger_cross_backend():  # type: ignore[no-untyped-def]
    from omnibias.fields.jax import _ops_dispatch as jd
    from omnibias.fields.jax.ops.complex import dz as jdz
    from omnibias.fields.torch import _ops_dispatch as td
    from omnibias.fields.torch.ops.complex import dz as tdz

    ts = _ExpZField(torch, td)(torch.as_tensor(COORDS, dtype=torch.float64))
    js = _ExpZField(jnp, jd)(jnp.asarray(COORDS, dtype=jnp.float64))
    tre, tim = tdz(ts, "fR", "fI")
    jre, jim = jdz(js, "fR", "fI")
    assert np.allclose(_np(tre), _np(jre), rtol=1e-12, atol=1e-12)
    assert np.allclose(_np(tim), _np(jim), rtol=1e-12, atol=1e-12)
python -m pytest packages/omnibias-fields/tests/test_wirtinger.py -k test_wirtinger_cross_backend -q
Read the implementation
def dz(
    state: FieldState,
    re_name: str,
    im_name: str,
    *,
    real_axis: int | str = "x",
    imag_axis: int | str = "y",
) -> tuple[Tensor, Tensor]:
    r""":math:`\partial_z f` as a ``(real, imag)`` pair."""
    fr_x, fr_y, fi_x, fi_y = _partials(state, re_name, im_name, real_axis, imag_axis)
    return 0.5 * (fr_x + fi_y), 0.5 * (fi_x - fr_y)
Other public import paths
  • omnibias.fields.torch.ops.dz
  • omnibias.fields.torch.ops.complex.dz
FUNCTION

dzbar​

omnibias.fields.torch.ops.dzbarSource ↗
dzbar(state: FieldState, re_name: str, im_name: str, *, real_axis: int | str='x', imag_axis: int | str='y') -> tuple[Tensor, Tensor]

\partial_{\bar z} f as a (real, imag) pair (zero if holomorphic).

Parameters

NameType & defaultContract
statepositional-or-keywordFieldStateRequiredSee the operation contract and implementation below.
re_namepositional-or-keywordstrRequiredSee the operation contract and implementation below.
im_namepositional-or-keywordstrRequiredSee the operation contract and implementation below.
real_axiskeyword-onlyint | strDefault: 'x'See the operation contract and implementation below.
imag_axiskeyword-onlyint | strDefault: 'y'See the operation contract and implementation below.
Returnstuple[Tensor, Tensor]
Executed regression · cauchy riemann holomorphic

Recorded coverage confirms this test executed the API body. This example belongs to the pinned upstream test suite. It may use fixtures and imports from its full file. Run it from that checkout with its test dependencies installed.

def test_cauchy_riemann_holomorphic():  # type: ignore[no-untyped-def]
    from omnibias.fields.torch import _ops_dispatch
    from omnibias.fields.torch.ops.complex import dzbar

    state = _ExpZField(torch, _ops_dispatch)(torch.as_tensor(COORDS, dtype=torch.float64))
    re, im = dzbar(state, "fR", "fI")
    assert np.allclose(_np(re), 0.0, atol=1e-12)
    assert np.allclose(_np(im), 0.0, atol=1e-12)
python -m pytest "packages/omnibias-fields/tests/test_wirtinger.py::test_cauchy_riemann_holomorphic" -q
Read the implementation
def dzbar(
    state: FieldState,
    re_name: str,
    im_name: str,
    *,
    real_axis: int | str = "x",
    imag_axis: int | str = "y",
) -> tuple[Tensor, Tensor]:
    r""":math:`\partial_{\bar z} f` as a ``(real, imag)`` pair (zero if holomorphic)."""
    fr_x, fr_y, fi_x, fi_y = _partials(state, re_name, im_name, real_axis, imag_axis)
    return 0.5 * (fr_x - fi_y), 0.5 * (fi_x + fr_y)
Other public import paths
  • omnibias.fields.torch.ops.dzbar
  • omnibias.fields.torch.ops.complex.dzbar