Skip to content

API reference

Every object on this page is rendered from its docstring. Names exported at the top level are used as tensordev.NAME (import tensordev as td); objects that only a subpackage exports are shown with their import path, for example tensordev.sss.JordanLambda.

Package structure

The top-level tensordev namespace re-exports the main objects of core, development, volterra, sss and kernel; tensordev.util is imported on its own. Home has the installation and a first example.

tensordev/
├── core/           # Tensor algebra backends
├── development/    # Signature development, free and classical
├── sss/            # State-space signatures, aka Volterra signatures for finite state-space kernels
├── volterra/       # Volterra signatures: fractional, gamma and FSSK kernels
├── kernel/         # Signature kernels: classical, free, FSSK, higher-order
└── util/           # Path generators and combinatorics

Cores

A core implements the truncated tensor algebra. make_core builds one, and set_default_core installs one as the process default, which the module-level operations use and functions that accept core= use when it is omitted. Tensor algebra explains the configurations with examples.

Class Selected by make_core and set_default_core with
Jax integer dims and integer max_trunc; an unbounded Jax() is the initial default
JaxBigraded pair dims and pair max_trunc
JaxPartiallySymmetrizedBigraded pair dims, pair max_trunc, partially_symmetrized=True
JaxShearTotal pair dims, integer max_trunc, coordinates="shear"
JaxShearBigraded pair dims, pair max_trunc, coordinates="shear"
JaxPartiallySymmetrizedShearBigraded pair dims, pair max_trunc, partially_symmetrized=True, coordinates="shear"
JaxSequentialCore paired with every built-in core as its sequential core

Most code selects a class through make_core or set_default_core rather than calling its constructor. The class entries show only the constructor; the operations every core provides are under Tensor operations.

make_core

make_core(
    *,
    dims: int | tuple[int, int],
    max_trunc: int | tuple[int, int],
    default_trunc: int | tuple[int, int] | None = None,
    partially_symmetrized: bool = False,
    coordinates: Literal["standard", "shear"] = "standard",
    precompute_shuffle: bool | Literal["generator"] = False,
) -> Any

Construct a JAX algebra core without changing the process default.

The configuration arguments and inference rules are identical to the construction form of set_default_core. Integer dims and max_trunc select standard total-degree truncation. Pair-valued dims and max_trunc select bidegree truncation. Shear coordinates require pair-valued dims and use the shape of max_trunc to choose total-degree or bidegree truncation.

set_default_core

set_default_core(
    core: Any | None = None,
    seq_core: Any | None = None,
    *,
    dims: int | tuple[int, int] | None = None,
    max_trunc: int | tuple[int, int] | None = None,
    default_trunc: int | tuple[int, int] | None = None,
    partially_symmetrized: bool = False,
    coordinates: Literal["standard", "shear"] = "standard",
    precompute_shuffle: bool | Literal["generator"] = False,
) -> Any

Set or construct the process-wide default algebra core.

Pass an already constructed core to install it directly. To construct and install a core in one call, omit core and pass the same configuration accepted by make_core. The supported configurations are:

  • integer dims and integer max_trunc: standard total degree;
  • pair dims and pair max_trunc: bidegree, optionally with partially_symmetrized=True;
  • pair dims and integer max_trunc with coordinates="shear": dense total-degree shear;
  • pair dims and pair max_trunc with coordinates="shear": placement-factored bidegree shear.

Partially symmetrized and shear cores require finite capacity because their discrete plans are precomputed. precompute_shuffle=False omits the optional shuffle law, "generator" retains only first-level-factor shuffles, and True retains arbitrary shuffles within capacity. Standard total degree accepts only the boolean modes.

When seq_core is omitted, the resolved core may provide either a make_sequential_core method or a default_sequential_core attribute. Built-in and composed JAX cores automatically reuse the shared JaxSequentialCore singleton.

Returns:

Type Description
Any

The installed algebra core.

reset_default_core

reset_default_core() -> None

Restore the singleton pair selected by TENSORDEV_BACKEND.

get_default_core

get_default_core() -> Any

Return the active algebra core, the first entry of get_default_core_pair().

get_default_seq_core

get_default_seq_core() -> Any

Return the active sequential core, the second entry of get_default_core_pair().

get_default_core_pair

get_default_core_pair() -> tuple[Any, Any]

Return the active algebra and sequential cores as one coherent pair.

The environment-selected backend is constructed lazily on first access. Reading the pair through this function avoids observing a core and a sequential core from two different default configurations.

core_expected_memory

core_expected_memory(
    *,
    dims: int | tuple[int, int],
    max_trunc: int | tuple[int, int],
    partially_symmetrized: bool = False,
    coordinates: Literal["standard", "shear"] = "standard",
    unit: str = "MiB",
    precompute_shuffle: bool | Literal["generator"] = False,
    breakdown: bool = False,
) -> float | dict[str, float]

Estimate exact eager plan-buffer payload for make_core.

Dispatch matches make_core: standard coordinates use an integer/integer total configuration or pair/pair bidegree configuration. Bidegree cores may use partially_symmetrized=True. Shear coordinates require pair-valued dims and use the shape of max_trunc to select total degree or bidegree. Results default to "MiB"; unit may instead be "bytes", "KiB", or "GiB". Set breakdown=True to return the category mapping including total. The exact count is derived without constructing a core or allocating any payload-sized plan arrays. It excludes Python-container overhead, runtime temporaries, and compiled executable storage; high-order symbolic counting may still take time.

shear_core

shear_core(
    core: Any,
    *,
    dims: tuple[int, int] | None = None,
    max_trunc: int | tuple[int, int] | None = None,
    precompute_shuffle: bool
    | Literal["generator"]
    | None = None,
) -> Any

Construct the matching shear core from a standard JAX core.

A standard total-degree core does not record the alphabet split, so dims=(d_prime, d_doubleprime) is required. Its finite capacity is inherited when available; converting an unbounded Jax() additionally requires max_trunc. A bidegree core already records both pieces and shares every compatible block-plan store with the returned shear core. This applies to ordered and partially symmetrized sources.

Unless explicitly overridden, the ordinary core's shuffle-precomputation scope is carried over. The target core constructs or reuses the plans required by its shear coordinates.

symmetrize_core

symmetrize_core(
    core: Any,
    *,
    precompute_shuffle: bool
    | Literal["generator"]
    | None = None,
) -> (
    JaxPartiallySymmetrizedBigraded
    | JaxPartiallySymmetrizedShearBigraded
)

Construct the matching partially symmetrized bidegree core.

The source core is authoritative for dimensions, capacity, active default truncation, backend, and coordinates. By default its shuffle scope is inherited; pass False, "generator", or True to override it.

Jax

Jax(
    *,
    d=None,
    max_trunc=None,
    default_trunc=None,
    precompute_shuffle=False,
    shuffle_plan_store=None,
)

Dense total-degree JAX core. Jax() without arguments is dimension-free and accepts any total-degree truncation; make_core(dims=d, max_trunc=N) returns a Jax with d=d and max_trunc=N.

JaxSequentialCore

JaxSequentialCore(default_time_axis: int = -2)

Sequential core implemented with JAX map and scan primitives.

JaxBigraded

JaxBigraded(
    *,
    dims=None,
    max_trunc=None,
    default_trunc=None,
    plan_store=None,
    shuffle_plan_store=None,
    precompute_shuffle=False,
)

Fixed-capacity JAX core for standard ordered bidegree coordinates.

JaxPartiallySymmetrizedBigraded

JaxPartiallySymmetrizedBigraded(
    *,
    dims=None,
    max_trunc=None,
    default_trunc=None,
    plan_store=None,
    bridge_plan_store=None,
    shear_plan_store=None,
    shuffle_plan_store=None,
    precompute_shuffle=False,
)

JAX core for partially symmetrized bidegree tensors.

JaxPartiallySymmetrizedShearBigraded

JaxPartiallySymmetrizedShearBigraded(
    *,
    dims=None,
    max_trunc=None,
    default_trunc=None,
    plan_store=None,
    bridge_plan_store=None,
    shear_plan_store=None,
    generator_plan_store=None,
    shuffle_plan_store=None,
    precompute_shuffle=False,
)

JAX partially symmetrized bidegree core in shear coordinates.

tensordev.core.JaxShearTotal

JaxShearTotal(
    *,
    dims=None,
    max_trunc=None,
    default_trunc=None,
    precompute_shuffle=False,
    plan_store=None,
)

Bounded dense total-degree JAX core in ordered shear coordinates.

tensordev.core.JaxShearBigraded

JaxShearBigraded(
    *,
    dims=None,
    max_trunc=None,
    default_trunc=None,
    plan_store=None,
    shear_plan_store=None,
    shuffle_plan_store=None,
    precompute_shuffle=False,
)

JAX ordered-bidegree shear core.

BigradedSpec dataclass

BigradedSpec(
    d_prime: int,
    d_doubleprime: int,
    truncation: Bidegree,
    coordinates: str = "standard",
    include_scalar: bool = True,
    partially_symmetrized: bool = False,
)

Small, hashable metadata describing one active bigraded tensor layout.

The spec is suitable as JAX PyTree auxiliary data. It intentionally holds no NumPy/JAX arrays and no reference to a capacity-level plan store.

placement_count staticmethod

placement_count(grade: object) -> int

Number of ordinary prime-letter placements at grade.

rank_count

rank_count(grade: object) -> int

Number of stored rank coordinates at grade.

BigradedTensor dataclass

BigradedTensor(blocks: Tuple[Any, ...], spec: BigradedSpec)

Ragged array container with one dynamic PyTree leaf per bidegree.

Every block uses the package-wide batch + (coordinates,) convention. The block at (n, m) has the final width prescribed by spec.

Tensor operations

The module-level functions td.tensor_* are bound methods of the installed default core: tensordev binds each name to the methods of the core it installs, and set_default_core and reset_default_core rebind them. The initial default is an unbounded Jax core, so td.tensor_product(A, B) calls td.get_default_core().tensor_product(A, B). Every core object has the same 36 methods; see Tensor algebra for examples.

The entries below are the generic implementations on Universal, the base class of every core, and describe the total-degree layout: a tuple of levels (X_0, X_1, ..., X_N) in which level k has shape batch + (d**k,), or (X_1, ..., X_N) in the first-on format that flags such as a_first_on and first_on_out select. Bidegree cores take and return a BigradedTensor and override some operations, for example tensor_to_flat, tensor_from_flat and tensor_densify; shear cores override tensor_product, tensor_logarithm and tensor_fmexp. Only partially symmetrized cores implement tensor_partially_symmetrize, tensor_partially_symmetrize_homogeneous and tensor_to_ordered; other cores raise RuntimeError.

Group Operation
Sum, scaling tensor_summation
tensor_scalar_multiply
tensor_dilation
Tensor product tensor_product
tensor_product_homogeneous
Shuffle product tensor_shuffle_vector
tensor_shuffle_vector_homogeneous
tensor_shuffle_product
tensor_shuffle_product_homogeneous
Exp, log tensor_exponential
tensor_logarithm
tensor_fmexp
Pairing, adjoint tensor_inner_product
tensor_inner_product_homogeneous
tensor_shear_pairing
tensor_shear_pairing_homogeneous
tensor_adjoint_product
tensor_adjoint_left_homogeneous
tensor_adjoint_right_homogeneous
Matrix-valued tensor_matrix_product
tensor_matrix_product_homogeneous
tensor_matrix_product_left
tensor_matrix_product_left_homogeneous
tensor_matrix_product_right
tensor_matrix_product_right_homogeneous
Layout tensor_stack
tensor_moveaxis
tensor_densify
tensor_from_flat
tensor_to_flat
tensor_slice
tensor_from_standard_coordinates
tensor_to_standard_coordinates
tensor_partially_symmetrize
tensor_partially_symmetrize_homogeneous
tensor_to_ordered

td.tensor_flatten is also bound, as an alias of tensor_to_flat.

Note

from tensordev import tensor_product binds the method of the core that is the default when the import runs. A later set_default_core does not change that name; call td.tensor_product instead.

tensor_summation

tensor_summation(
    A: DenseElem, B: DenseElem, trunc: Optional[int] = None
) -> DenseElem

Level-wise sum C = A + B (with implicit zero-padding if degrees differ).

Parameters:

Name Type Description Default
A sequence of ndarray

Inputs with shapes A_k.shape == B_k.shape whenever both exist.

required
B sequence of ndarray

Inputs with shapes A_k.shape == B_k.shape whenever both exist.

required
trunc int

If given, keep only degrees 0..trunc.

None

Returns:

Type Description
tuple of ndarray

C_k = A_k + B_k for all available k (zeros used if one side lacks degree k).

tensor_scalar_multiply

tensor_scalar_multiply(
    A: DenseElem, alpha: Union[Array, float]
) -> DenseElem

Uniform scalar multiply: Y = a * X.

Parameters:

Name Type Description Default
A sequence of ndarray

Input levels.

required
alpha float or ndarray

Either a scalar, or a batch-shaped array broadcastable to the leading batch shape. When array-valued, scaling is done elementwise per batch example (broadcast over the last axis).

required

Returns:

Type Description
tuple of ndarray

Levels B_k = alpha * A_k.

tensor_dilation

tensor_dilation(
    A: DenseElem, c: Union[Array, float]
) -> DenseElem

Scale each homogeneous degree k by c**k.

tensor_product

tensor_product(
    A: Union[DenseElem, DenseElemFirstOn],
    B: Union[DenseElem, DenseElemFirstOn],
    trunc: Optional[int] = None,
    *,
    a_first_on: bool = False,
    b_first_on: bool = False,
) -> Union[DenseElem, DenseElemFirstOn]

Graded (Cauchy-type) product C = A ⊗ B in the free tensor algebra.

For each degree n, C_n = ∑_{i+j=n} flatten(tensor_product_homogeneous(A_i, B_j)).

Parameters:

Name Type Description Default
A tuple of ndarray

Levels of the left/right factors, each of shape batch + (d**k,).

By default, inputs are interpreted as (A_0, A_1, ..., A_N) and (B_0, B_1, ..., B_M).

If a_first_on=True, then A is interpreted as (A_1, A_2, ..., A_N).

If b_first_on=True, then B is interpreted analogously.

required
B tuple of ndarray

Levels of the left/right factors, each of shape batch + (d**k,).

By default, inputs are interpreted as (A_0, A_1, ..., A_N) and (B_0, B_1, ..., B_M).

If a_first_on=True, then A is interpreted as (A_1, A_2, ..., A_N).

If b_first_on=True, then B is interpreted analogously.

required
trunc int

If given, truncate the result to degrees up to trunc.

None
a_first_on bool

Whether the corresponding input starts at degree 1 rather than 0.

False
b_first_on bool

Whether the corresponding input starts at degree 1 rather than 0.

False

Returns:

Type Description
tuple of ndarray

Product levels. If both flags are False, returns (C_0, C_1, ..., C_N). Otherwise returns (C_1, C_2, ..., C_N).

tensor_product_homogeneous

tensor_product_homogeneous(Ai: Array, Bj: Array) -> Array

Homogeneous-degree tensor (Chen) product on the last axis.

Given degree-i and degree-j levels with shapes Ai.shape == batch + (d**i,), Bj.shape == batch + (d**j,), return their (flattened) tensor product (Ai ⊗ Bj).shape == batch + (d**(i+j),).

This is just a Kronecker on the last axis, preserving the batch shape.

tensor_shuffle_vector

tensor_shuffle_vector(
    A: Union[DenseElem, DenseElemFirstOn],
    v: Array,
    *,
    trunc: Optional[int] = None,
    a_first_on: bool = False,
) -> DenseElemFirstOn

Graded shuffle product C = A ⊔ v where v is degree-1.

Output is in first-on format (degrees 1, 2, ...): C_n = A_{n-1} ⊔ v for n = 1, ..., min(NA + 1, trunc)

Parameters:

Name Type Description Default
A DenseElem or DenseElemFirstOn

Graded element. If a_first_on=True, starts at degree 1.

required
v Array, shape batch + (d,)

Degree-1 vector; batch shapes are broadcast per level.

required
trunc int

Maximum output degree.

None
a_first_on bool

Whether A starts at degree 1.

False

Returns:

Type Description
DenseElemFirstOn

Output levels starting at degree 1.

tensor_shuffle_vector_homogeneous

tensor_shuffle_vector_homogeneous(
    Ai: Array, v: Array, i: int
) -> Array

Homogeneous shuffle product (A_i ⊔ v)_{i+1} where v is degree-1.

For each output word (l_0, ..., l_i) the result is: sum_{p=0}^{i} A_i[l_0,...,l_{p-1},l_{p+1},...,l_i] * v[l_p]

Parameters:

Name Type Description Default
Ai Array, shape batch + (d**i,)
required
v Array, shape batch + (d,) — batch shapes are broadcast.
required
i int

Degree of Ai.

required

Returns:

Type Description
Array, shape batch + (d**(i+1),)

tensor_shuffle_product

tensor_shuffle_product(
    A: Union[DenseElem, DenseElemFirstOn],
    B: Union[DenseElem, DenseElemFirstOn],
    *,
    trunc: Optional[int] = None,
    a_first_on: bool = False,
    b_first_on: bool = False,
    first_on_out: bool = False,
) -> Union[DenseElem, DenseElemFirstOn]

Compute the truncated graded, commutative shuffle product.

tensor_shuffle_product_homogeneous

tensor_shuffle_product_homogeneous(
    Ai: Array, Bj: Array, i: int, j: int
) -> Array

Compute the homogeneous ordinary shuffle product.

tensor_exponential

tensor_exponential(
    X: DenseElemFirstOn,
    *,
    trunc: Any = None,
    output_zero_level: bool = True,
) -> Tuple[Array, ...]

Algebra exponential for inputs starting at degree 1 (treat X₀ ≡ 0).

Implemented via the efficient primitive: exp(X) = I ⊗ exp(X) with I = (1,) (level-0 only)

tensor_logarithm

tensor_logarithm(
    X: DenseElemFirstOn,
    *,
    trunc: Any = None,
    output_zero_level: bool = True,
) -> Tuple[Array, ...]

Algebra logarithm with input levels starting at 1.

Convention

Input X = (X₁, X₂, …) is interpreted with X₀ ≡ 1. Let H := (0, X₁, X₂, …) (zero scalar part). Then log(1 + H) = (0, ∑_{n≥1} (-1)^{n+1} H^{⊗ n} / n), truncated to degree trunc. No padding of higher degrees is performed; the convolution grows degrees naturally via tensor_product(..., trunc=trunc).

Parameters:

Name Type Description Default
X DenseElemFirstOn

Levels start at degree 1, last dim d**k, shared batch shape.

required
trunc int

Maximum degree (inclusive) of the output.

None
output_zero_level bool

Whether to include degree-0 in the returned tuple (it's identically zero).

True

Returns:

Type Description
DenseElem (or degrees 1..trunc when output_zero_level=False)

tensor_fmexp

tensor_fmexp(
    g: DenseElem,
    X: DenseElemFirstOn,
    *,
    trunc: Any = None,
    output_zero_level: bool = True,
) -> Tuple[Array, ...]

Efficient formal multiplicative exponential: compute Y = g ⊗ exp(X).

Conventions
  • g is a dense graded element (g₀, g₁, …).
  • X has levels starting at 1: (X₁, X₂, …), with X₀ ≡ 0.
Algorithm
  • For the pure degree-1 case (len(X) == 1), use the fused Horner scheme for g ⊗ exp(X₁).
  • In the general case, build the truncated exponential exp(X) = I + X + X^{⊗2}/2! + ... + X^{⊗trunc}/trunc! exactly via the truncated tensor power series, and then compute Y = g ⊗ exp(X).

Parameters:

Name Type Description Default
g DenseElem

Left factor with explicit level-0.

required
X DenseElemFirstOn

Exponent argument with levels starting at degree 1.

required
trunc int

Maximum degree (inclusive) of the output.

None
output_zero_level bool

If False, drop degree-0 from the returned tuple.

True

Returns:

Type Description
Tuple[Array, ...]

(Y₀, …, Y_trunc) for output_zero_level=True; otherwise (Y₁, …, Y_trunc).

tensor_inner_product

tensor_inner_product(
    A: Union[DenseElem, DenseElemFirstOn],
    B: Union[DenseElem, DenseElemFirstOn],
) -> Array

Canonical Euclidean inner product, summing level-wise dot products over the last axis.

Parameters:

Name Type Description Default
A DenseElem or DenseElemFirstOn

Graded elements with matching batch shape. If the inputs start at level 1, the inner product is taken over the positive levels only.

required
B DenseElem or DenseElemFirstOn

Graded elements with matching batch shape. If the inputs start at level 1, the inner product is taken over the positive levels only.

required

Returns:

Type Description
Array

Batch-shaped array with the inner product.

tensor_inner_product_homogeneous

tensor_inner_product_homogeneous(
    Ak: Array, Bk: Array
) -> Array

Level-wise (homogeneous) Euclidean inner product over the last axis.

Parameters:

Name Type Description Default
Ak ndarray

Same-degree levels with shape batch + (d**k,).

required
Bk ndarray

Same-degree levels with shape batch + (d**k,).

required

Returns:

Type Description
ndarray

Batch-shaped array batch with ⟨Ak, Bk⟩ = sum over the last axis.

tensor_shear_pairing

tensor_shear_pairing(
    words: Union[DenseElem, DenseElemFirstOn],
    standard_tensor: Union[DenseElem, DenseElemFirstOn],
    *,
    words_first_on: bool = False,
    standard_first_on: bool = False,
) -> Array

Pair words with a compatible standard-coordinate tensor.

tensor_shear_pairing_homogeneous

tensor_shear_pairing_homogeneous(
    words: Array,
    standard_tensor: Array,
    *,
    grade: Any,
    standard_partially_symmetrized: bool = False,
) -> Array

Pair one word block with a standard-coordinate block.

tensor_adjoint_product

tensor_adjoint_product(
    W: Union[DenseElem, DenseElemFirstOn],
    Y: Union[DenseElem, DenseElemFirstOn],
    trunc: Any = None,
    side: Literal["left", "right"] = "left",
    *,
    w_first_on: bool = False,
    y_first_on: bool = False,
    first_on_out: bool = False,
) -> Union[DenseElem, DenseElemFirstOn]

Compute the graded adjoint product of two truncated tensor-algebra elements.

This is the shared implementation behind the left and right adjoint actions. It contracts homogeneous levels of W against shifted homogeneous levels of Y and sums all contributions that land in the same output degree.

Degree convention

Let W_i denote the degree-i level of W and Y_j the degree-j level of Y. For each output degree n, this routine computes

Z_n = sum_i Adj(W_i, Y_{n+i}),

where Adj is either the left or right homogeneous adjoint contraction, depending on side.

More precisely: - for side="left", use tensor_adjoint_left_homogeneous(W_i, Y_{n+i}); - for side="right", use tensor_adjoint_right_homogeneous(W_i, Y_{n+i}).

Input format

The inputs may be stored either as dense graded elements or as first-on graded elements:

  • dense: (A_0, A_1, ..., A_N)
  • first-on: (A_1, A_2, ..., A_N)

The flags w_first_on and y_first_on specify which convention is used for W and Y respectively.

Output format

The returned tuple is intended to be either

  • dense, if first_on_out=False: (Z_0, Z_1, ..., Z_M)
  • first-on, if first_on_out=True: (Z_1, Z_2, ..., Z_M)

where M is the largest output degree allowed by the input ranges and by trunc.

Important

This routine should return output in a canonical graded format: - dense output must begin at degree 0, - first-on output must begin at degree 1.

If the lowest nonzero computable degree is higher than that starting degree, the missing lower degrees should be represented by zero levels rather than being silently skipped. Otherwise the returned tuple no longer has a well-defined dense/first-on interpretation.

Parameters:

Name Type Description Default
W Union[DenseElem, DenseElemFirstOn]

Multiplier graded element. Its stored levels are interpreted as starting at degree 0 or degree 1 according to w_first_on.

required
Y Union[DenseElem, DenseElemFirstOn]

Target graded element. Its stored levels are interpreted as starting at degree 0 or degree 1 according to y_first_on.

required
trunc Any

Optional maximum output degree. If None, all output degrees permitted by the available levels of W and Y are produced.

None
side Literal['left', 'right']

Which adjoint action to use: - "left" -> left homogeneous adjoint contraction, - "right" -> right homogeneous adjoint contraction.

'left'
w_first_on bool

Whether W is stored in first-on format.

False
y_first_on bool

Whether Y is stored in first-on format.

False
first_on_out bool

Whether to return the result in first-on format.

False

Returns:

Type Description
DenseElem or DenseElemFirstOn

The graded adjoint product, truncated at degree trunc if requested, in the storage convention specified by first_on_out.

Notes

If W has degrees i in some range and Y has degrees j in some range, then the admissible output degrees are those for which at least one pair (i, j) satisfies j = n + i. This determines the natural output degree window before truncation is applied.

tensor_adjoint_left_homogeneous

tensor_adjoint_left_homogeneous(
    Ai: Array, Yni: Array
) -> Array

Homogeneous left-adjoint contraction for degree i.

Given Ai.shape == batch + (d**i,) Yni.shape == batch + (d**(n+i),) reshape Yni as (..., d**i, -1) and contract the first width with Ai: out = Ai^T • Yni_(..., i, N) -> shape batch + (N,)

tensor_adjoint_right_homogeneous

tensor_adjoint_right_homogeneous(
    Bj: Array, Ynj: Array
) -> Array

Homogeneous right-adjoint contraction for degree j.

Given Bj.shape == batch + (d**j,) Ynj.shape == batch + (d**(n+j),) reshape Ynj as (..., -1, d**j) and contract the last width with Bj: out = Ynj_(..., N, j) • Bj -> shape batch + (N,)

tensor_matrix_product

tensor_matrix_product(
    A: DenseElem,
    B: DenseElem,
    trunc: Optional[int] = None,
    row_axis: int = -3,
    col_axis: int = -2,
) -> DenseElem

Multiply two matrix-valued tensor-algebra elements.

If A and B are represented levelwise as batch + (T?, n, k, d_i) and batch + (T?, k, l, d_j), respectively, then this computes the graded Cauchy product

(A * B)[r] = sum_{i+j=r} A[i] @ B[j],

where the homogeneous products contract the inner matrix index and use the tensor product on the final tensor-coordinate axis.

Parameters:

Name Type Description Default
A tuple of ndarray

Matrix-valued tensor-algebra elements.

required
B tuple of ndarray

Matrix-valued tensor-algebra elements.

required
trunc int

If given, truncate the product to degrees 0, ..., trunc.

None
row_axis int

Positions of the matrix row and column axes in each homogeneous level of A and B. Both operands are assumed to use the same convention.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in each homogeneous level of A and B. Both operands are assumed to use the same convention.

(-3, -2)

Returns:

Type Description
tuple of ndarray

Matrix-valued tensor-algebra product.

tensor_matrix_product_homogeneous

tensor_matrix_product_homogeneous(
    A: Array,
    B: Array,
    row_axis: int = -3,
    col_axis: int = -2,
) -> Array

Multiply two homogeneous matrix-valued tensor-algebra coefficients.

If A has shape batch + (T?, n, k, d_i) and B has shape batch + (T?, k, l, d_j) up to axis placement, then the result has shape batch + (T?, n, l, d_i d_j) up to axis placement.

Parameters:

Name Type Description Default
A ndarray

Homogeneous matrix-valued coefficients.

required
B ndarray

Homogeneous matrix-valued coefficients.

required
row_axis int

Positions of the matrix row and column axes in A and B. Both operands are assumed to follow the same convention.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in A and B. Both operands are assumed to follow the same convention.

(-3, -2)

Returns:

Type Description
ndarray

Homogeneous matrix-valued coefficient.

tensor_matrix_product_left

tensor_matrix_product_left(
    M: Array,
    A: DenseElem,
    trunc: Optional[int] = None,
    row_axis: int = -3,
    col_axis: int = -2,
) -> DenseElem

Left-multiply a matrix-valued tensor-algebra element by a numeric matrix.

Each homogeneous level A[r] is interpreted using the matrix-axis convention specified by row_axis and col_axis. Under the default convention, levels have shape

batch + (T?, k, l, d_r).

Parameters:

Name Type Description Default
M ndarray

Numeric matrix with shape (..., n, k).

required
A tuple of ndarray

Matrix-valued tensor-algebra element.

required
trunc int

If given, keep only degrees 0, ..., trunc.

None
row_axis int

Positions of the matrix row and column axes in each level of A.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in each level of A.

(-3, -2)

Returns:

Type Description
tuple of ndarray

Matrix-valued tensor-algebra element with row dimension updated from k to n.

tensor_matrix_product_left_homogeneous

tensor_matrix_product_left_homogeneous(
    M: Array,
    A: Array,
    row_axis: int = -3,
    col_axis: int = -2,
) -> Array

Left-multiply a homogeneous matrix-valued tensor-algebra coefficient by a numeric matrix.

The default axis convention is

batch + (T?, k, l, d_r),

where the final axis stores tensor coordinates, an optional time axis precedes the matrix axes, and the matrix axes are (row_axis, col_axis).

Parameters:

Name Type Description Default
M ndarray

Numeric matrix with shape (..., n, k).

required
A ndarray

Homogeneous matrix-valued coefficient with shape batch + (T?, k, l, d_r) up to axis placement.

required
row_axis int

Positions of the matrix row and column axes in A.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in A.

(-3, -2)

Returns:

Type Description
ndarray

Homogeneous coefficient with shape batch + (T?, n, l, d_r) up to axis placement.

tensor_matrix_product_right

tensor_matrix_product_right(
    A: DenseElem,
    M: Array,
    trunc: Optional[int] = None,
    row_axis: int = -3,
    col_axis: int = -2,
) -> DenseElem

Right-multiply a matrix-valued tensor-algebra element by a numeric matrix.

Each homogeneous level A[r] is interpreted using the matrix-axis convention specified by row_axis and col_axis. Under the default convention, levels have shape

batch + (T?, n, k, d_r).

Parameters:

Name Type Description Default
A tuple of ndarray

Matrix-valued tensor-algebra element.

required
M ndarray

Numeric matrix with shape (..., k, l).

required
trunc int

If given, keep only degrees 0, ..., trunc.

None
row_axis int

Positions of the matrix row and column axes in each level of A.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in each level of A.

(-3, -2)

Returns:

Type Description
tuple of ndarray

Matrix-valued tensor-algebra element with column dimension updated from k to l.

tensor_matrix_product_right_homogeneous

tensor_matrix_product_right_homogeneous(
    A: Array,
    M: Array,
    row_axis: int = -3,
    col_axis: int = -2,
) -> Array

Right-multiply a homogeneous matrix-valued tensor-algebra coefficient by a numeric matrix.

The default axis convention is

batch + (T?, n, k, d_r),

where the final axis stores tensor coordinates, an optional time axis precedes the matrix axes, and the matrix axes are (row_axis, col_axis).

Parameters:

Name Type Description Default
A ndarray

Homogeneous matrix-valued coefficient with shape batch + (T?, n, k, d_r) up to axis placement.

required
M ndarray

Numeric matrix with shape (..., k, l).

required
row_axis int

Positions of the matrix row and column axes in A.

(-3, -2)
col_axis int

Positions of the matrix row and column axes in A.

(-3, -2)

Returns:

Type Description
ndarray

Homogeneous coefficient with shape batch + (T?, n, l, d_r) up to axis placement.

tensor_stack

tensor_stack(X: List[DenseElem], *, axis: int) -> tuple

Stack a list of equally structured elements level-wise along axis.

tensor_moveaxis

tensor_moveaxis(
    X: DenseElem, *, source: int, destination: int
) -> DenseElem

Move the axis source to destination in every level.

tensor_densify

tensor_densify(levels: Elem) -> DenseElem

Turn a possibly sparse graded element (levels may be None) into a dense one.

Rules

• If a positive degree (k ≥ 1) level is present, infer the base dimension d from the first such level: width(level_k) must equal d**k. - All other present levels are validated against this d and shared batch shape. • Missing levels are filled with exact zeros of matching batch shape and width d**k (for k=0 the width is 1). • If d cannot be inferred (because the input is empty, all levels are None, or only degree-0 is provided), return a canonical zero scalar: (np.array([0.0]),).

Parameters:

Name Type Description Default
levels Tuple[Optional[Array], ...]

Packed levels (X₀, X₁, ..., X_N), where any X_k may be None.

required

Returns:

Type Description
Tuple[Array, ...]

Dense graded element (Y₀, Y₁, ..., Y_N) with no Nones.

Raises:

Type Description
ValueError

If present levels disagree on batch shape, or a present width at degree k does not equal d**k.

tensor_from_flat

tensor_from_flat(
    flat: Array,
    dim: int,
    insert_zero_level: Optional[Union[bool, float]] = None,
) -> DenseElem

Split a flattened graded tensor into a dense (X₀, X₁, ..., X_N).

Layouts supported on the last axis of flat: • [X₀ | X₁ | ... | X_N] with widths 1, d, d**2, ... • [X₁ | ... | X_N] with widths d, d**2, ...

Degree-0 policy (always return a DenseElem): - insert_zero_level is None → if X₀ missing, insert zeros; if present, keep. - insert_zero_level is True → set/insert X₀ = ones. - insert_zero_level is False → set/insert X₀ = zeros. - insert_zero_level is float → set/insert X₀ = that scalar.

Parameters:

Name Type Description Default
flat Array

Packed array with the concatenated degrees on the last axis.

required
dim int

Base dimension d so that width(Xₖ) = d**k.

required
insert_zero_level None | bool | float

Degree-0 policy as described above.

None

Returns:

Type Description
DenseElem

A tuple (X₀, X₁, ..., X_N), each with matching batch shape and last dim d**k.

tensor_to_flat

tensor_to_flat(
    levels: DenseElem, *, start_at_level_one: bool = False
) -> Array

Concatenate per-degree levels into a single flattened array.

Parameters:

Name Type Description Default
levels sequence of ndarray

(X₀, X₁, ..., X_N) with matching batch shapes.

required
start_at_level_one bool

If True, pack only degrees 1..N (drop X₀ in the output). Otherwise pack 0..N.

False

Returns:

Type Description
ndarray

The concatenation along the last axis.

tensor_slice

tensor_slice(A: DenseElem) -> _TensorSliceProxy

Return a proxy that applies an index or slice to every level of A.

Usage:

td.tensor_slice(A)[i:j]       # → tuple(lvl[i:j] for lvl in A)
td.tensor_slice(A)[..., 0]    # → tuple(lvl[..., 0] for lvl in A)

tensor_from_standard_coordinates

tensor_from_standard_coordinates(
    A: Any, *, trunc: Any = None, first_on: bool = False
) -> Any

Convert standard coefficients to this core's native coordinates.

This changes coordinates only: total-degree tuples remain total-degree tuples, while bidegree tensors retain their grading, truncation, and scalar policy. On a standard-coordinate core this is a validated identity operation.

tensor_to_standard_coordinates

tensor_to_standard_coordinates(
    A: Any, *, trunc: Any = None, first_on: bool = False
) -> Any

Convert this core's native coefficients to standard coordinates.

This is the inverse coordinate map and does not change total versus bidegree layout. A bidegree shear result remains a BigradedTensor, with its coordinate metadata changed to "standard". On a standard-coordinate core this is a validated identity operation.

tensor_partially_symmetrize

tensor_partially_symmetrize(
    element: Any,
    *,
    trunc: Any = None,
    first_on: bool = False,
) -> Any

Partially symmetrize one ordered tensor when supported.

tensor_partially_symmetrize_homogeneous

tensor_partially_symmetrize_homogeneous(
    block: Any, *, grade: Any = None
) -> Any

Partially symmetrize one ordered block when supported.

tensor_to_ordered

tensor_to_ordered(
    element: Any,
    *,
    trunc: Any = None,
    first_on: bool = False,
) -> Any

Lift a partially symmetrized word tensor when supported.

Signatures and developments

path_signature computes the truncated signature of a path and free_development the free development of a tensor-valued path. Signature and FreeDevelopment bind trunc, core and seq_core for repeated calls. Examples are on Signatures.

path_signature

path_signature(
    x: _Array,
    *,
    trunc: Any = None,
    increment_input: bool = False,
    starting_point: Optional[
        DenseElem | BigradedTensor
    ] = None,
    axis: Optional[int] = None,
    block_size: Optional[int] = None,
    output_starting_point: bool = False,
    accumulate: bool = True,
    accumulate_in_tree: bool = False,
    parallel: bool = False,
    core: Any = None,
    seq_core: SequentialCore = None,
    execution: str = "auto",
) -> DenseElem | BigradedTensor

Truncated signature of a scalar path.

A thin wrapper around free_development that accepts a single level-1 path array x instead of a full DenseElemFirstOn tuple.

Parameters:

Name Type Description Default
x Array

Path with shape batch + (S+1, d) when increment_input=False, or batch + (S, d) when increment_input=True.

required
trunc int or pair of int

Active truncation. The unbounded total-degree core requires an integer; a bidegree core accepts (N, M) and may supply a default.

None
increment_input bool

If True, x is already in increment form; skip differencing.

False
starting_point DenseElem or BigradedTensor

Left seed g in the selected core's native tensor format; the output is g ⊗ Sig(x). Defaults to the identity of the selected core.

None
axis int

Step axis of x. Defaults to seq_core.default_time_axis.

None
block_size int

Steps per emitted block. None → one block covering all steps.

None
output_starting_point bool

If True, prepend the seed to the output.

False
accumulate bool

Carry the running product across blocks.

True
accumulate_in_tree bool

Use an associative tree scan for across-block accumulation.

False
parallel bool

If True, pre-compute all per-step exponentials and combine with an associative tree scan (higher parallelism, higher memory). If False, stream via sequential tensor_fmexp (lower memory, sequential depth).

False
core Any

Tensor algebra backend.

None
seq_core SequentialCore

Sequential operations backend.

None
execution ('auto', 'jax', 'wordwise')

"auto" retains the default execution policy; "jax" forces portable JAX. "wordwise" explicitly requests the alpha NVIDIA GPU kernels for float32/float64 input on one device with CUDA compute capability 8.0 or newer. Wordwise execution requires eager calls with parallel=False and accumulate_in_tree=False; it does not support outer jit, grad, or vmap transformations. Unsupported explicit requests raise instead of falling back.

"auto"

Returns:

Type Description
DenseElem or BigradedTensor

Tensor element in the selected core's native format. With blocking, its arrays carry a block axis at axis.

Signature dataclass

Signature(
    trunc: Any = None,
    core: Any = None,
    seq_core: Any = None,
)

Truncated signature of a scalar path.

Thin wrapper around path_signature that binds core, seq_core, and trunc so they do not need to be repeated at every call site.

Parameters:

Name Type Description Default
trunc int or pair of int

Active truncation. May be omitted when the bound core supplies a default.

None
core optional

Tensor algebra core. Defaults to the active core configured by tensordev.set_default_core or, initially, by the TENSORDEV_BACKEND environment variable.

None
seq_core SequentialCore

Sequential operations backend. Defaults to the same backend as core.

None

__call__

__call__(
    x: _Array,
    *,
    axis: Optional[int] = None,
    block_size: Optional[int] = None,
    accumulate: bool = True,
    starting_point: Optional[
        DenseElem | BigradedTensor
    ] = None,
    output_starting_point: bool = False,
    parallel: bool = False,
    accumulate_in_tree: bool = False,
    increment_input: bool = False,
    execution: str = "auto",
) -> DenseElem | BigradedTensor

Compute the signature of x.

Forwards all arguments to path_signature with the bound core, seq_core, and trunc.

free_development

free_development(
    X: DenseElemFirstOn,
    *,
    trunc: Any = None,
    increment_input: bool = False,
    starting_point: Optional[TensorElement] = None,
    axis: Optional[int] = None,
    block_size: Optional[int] = None,
    output_starting_point: bool = False,
    accumulate: bool = True,
    accumulate_in_tree: bool = False,
    parallel: bool = False,
    core: Any = None,
    seq_core: SequentialCore = None,
) -> TensorElement

Truncated free development of a tensor-valued path.

Computes the running Chen product S = exp(dX_1) ⊗ exp(dX_2) ⊗ ... ⊗ exp(dX_S) truncated at degree trunc, optionally left-seeded by starting_point.

Parameters:

Name Type Description Default
X DenseElemFirstOn

Tensor-valued path levels starting at degree 1. For a total-degree core, level k has shape batch + (S+1, d**k) when increment_input=False, or batch + (S, d**k) when increment_input=True. Bidegree cores accept one combined first-level path array, supplied as (X1,), whose width is sum(core.dims).

required
trunc int or pair of int

Active truncation. The unbounded total-degree core requires an integer; a bidegree core accepts (N, M) and may supply a default.

None
increment_input bool

If True, X is already in increment form; skip differencing.

False
starting_point DenseElem or BigradedTensor

Left seed g in the selected core's native tensor format; the output is g ⊗ S. Defaults to the identity of the selected core.

None
axis int

Step axis of X. Defaults to seq_core.default_time_axis.

None
block_size int

Steps per emitted block. None → one block covering all steps.

None
output_starting_point bool

If True, prepend the seed to the output.

False
accumulate bool

Carry the running product across blocks.

True
accumulate_in_tree bool

Use an associative tree scan for across-block accumulation.

False
parallel bool

If True, pre-compute all per-step exponentials via tensor_fmexp(neutral, step) and combine them with tensor_product using an associative tree scan (higher parallelism, higher memory). If False, stream via sequential tensor_fmexp (lower memory, sequential depth).

False
core Any

Tensor algebra backend. Must provide tensor_fmexp, tensor_product, tensor_exponential, and xp.

None
seq_core SequentialCore

Sequential operations backend.

None

Returns:

Type Description
DenseElem or BigradedTensor

Tensor element in the selected core's native format. With blocking, its arrays carry a block axis at axis.

FreeDevelopment dataclass

FreeDevelopment(
    trunc: Any = None,
    core: Any = None,
    seq_core: Any = None,
)

Truncated free development of a tensor-valued path.

Thin wrapper around free_development that binds core, seq_core, and trunc so they do not have to be repeated at every call site.

Parameters:

Name Type Description Default
trunc int or pair of int

Active truncation. May be omitted when the bound core supplies a default.

None
core optional

Tensor algebra core. Defaults to the active core configured by tensordev.set_default_core or, initially, by the TENSORDEV_BACKEND environment variable.

None
seq_core SequentialCore

Sequential operations backend. Defaults to the same backend as core.

None

__call__

__call__(
    X: DenseElemFirstOn,
    *,
    axis: Optional[int] = None,
    block_size: Optional[int] = None,
    accumulate: bool = True,
    starting_point: Optional[TensorElement] = None,
    output_starting_point: bool = False,
    parallel: bool = False,
    accumulate_in_tree: bool = False,
    increment_input: bool = False,
) -> TensorElement

Compute the free development of X.

Forwards all arguments to free_development with the bound core, seq_core, and trunc.

Volterra signatures

vsig computes the truncated Volterra signature of a path for a ConvolutionKernel, and VolterraSignature binds a kernel and a truncation. The iteration functions implement the schemes "quadratic", "fft" and "adams" of vsig and take increments on the final grid. Examples are on Volterra signatures.

vsig

vsig(
    X: Array,
    *,
    kernel: ConvolutionKernel,
    trunc=None,
    dt: Array | float = 1.0,
    axis: int = -2,
    block_size: Optional[int] = None,
    accumulate: bool = True,
    starting_point: Any = None,
    output_starting_point: bool = False,
    increment_input: bool = False,
    order: int = 0,
    dyadic_order: int = 0,
    scheme: Literal[
        "auto", "fft", "quadratic", "adams"
    ] = "auto",
    lag_tables: Optional[PrecomputedLagTables] = None,
    core=None,
    seq_core=None,
)

Compute the truncated Volterra signature of X.

The parameters of vsig are described in Computing a Volterra signature. The method VolterraSignature.vsig takes the same arguments except kernel, trunc, core and seq_core, which the object binds, and its entry lists them.

tensordev.volterra.vsig_fft module-attribute

vsig_fft = partial(vsig, scheme='fft')

Alias for vsig with scheme="fft" preset.

VolterraSignature dataclass

VolterraSignature(
    kernel: ConvolutionKernel,
    trunc: Any = None,
    core: Any = None,
    seq_core: Any = None,
)

Thin wrapper binding a kernel, truncation, and coherent core pair.

Parameters:

Name Type Description Default
kernel ConvolutionKernel

The underlying Volterra kernel.

required
trunc Any

Active integer or bidegree truncation. May be omitted when the bound core supplies a default. Static (changes cause retracing).

None
core Any

Algebra and sequential backends. Omitted values resolve from the process-wide coherent default pair.

None
seq_core Any

Algebra and sequential backends. Omitted values resolve from the process-wide coherent default pair.

None

q property

q: int

Number of scalar kernel components.

m property

m: int

Latent output dimension of each A_p.

path_dim property

path_dim: int

Input path dimension d.

fractional classmethod

fractional(
    *, trunc=None, core=None, seq_core=None, **kwargs
) -> "VolterraSignature"

Construct from a fractional kernel. Forwards all kwargs to FractionalKernel.

gamma classmethod

gamma(
    *, trunc=None, core=None, seq_core=None, **kwargs
) -> "VolterraSignature"

Construct from a Gamma kernel. Forwards all kwargs to GammaKernel.

vsig

vsig(
    X: Array,
    *,
    dt: Array | float = 1.0,
    axis: int = -2,
    block_size: Optional[int] = None,
    accumulate: bool = True,
    starting_point: Any = None,
    output_starting_point: bool = False,
    increment_input: bool = False,
    dyadic_order: int = 0,
    order: int = 0,
    scheme: Literal[
        "auto", "fft", "quadratic", "adams"
    ] = "auto",
    lag_tables: Optional[PrecomputedLagTables] = None,
)

Compute the truncated Volterra signature of X.

Thin wrapper around the module-level vsig. self.kernel and self.trunc are forwarded automatically; all other arguments are passed through unchanged.

Parameters:

Name Type Description Default
X Array

Path nodes or increments (..., S, d); step axis axis.

required
dt Array | float

Step size(s). Scalar → uniform grid; 1-D array → non-uniform. Default 1.0.

1.0
axis int

Step axis of X (default -2).

-2
block_size Optional[int]

Steps per emitted block. None → single terminal result.

None
accumulate bool

Carry history across blocks (True) or treat blocks independently via rebatch (False).

True
starting_point Any

Optional seed prepended when output_starting_point=True.

None
output_starting_point bool

If True, prepend the seed to the output along axis.

False
increment_input bool

Treat X as increments; skip jnp.diff.

False
dyadic_order int

Dyadic refinement order (default 0).

0
order int

Quadrature order for the basis-expansion scheme (default 0).

0
scheme Literal['auto', 'fft', 'quadratic', 'adams']

"auto" (default), "fft", "quadratic", or "adams".

'auto'

Returns:

Type Description
object

Native Volterra tensor; see module-level vsig for details.

ConvolutionKernel dataclass

ConvolutionKernel(A: Array, beta: Array)

Abstract base class for Volterra convolution kernels.

A Volterra kernel is represented as

\[ K(t,s) = \sum_{p=1}^n k_p(t-s)\, A_p, \]

where \(A_p \in \mathbb{R}^{m \times d}\) and \(\beta_p > 0\) is the fractional order of \(k_p\) (\(\beta_p = 1\) for smooth kernels). Concrete subclasses implement alpha.

At tau == t the one-sided partial derivative of a degree-\(n\) coefficient in tau is infinite when \(n\beta_p < 1\). There \((t-s)/(\tau-s)\) and \(\tau-t\) are held constant in differentiation, so the returned derivatives in t and tau are finite but are not the partial derivatives; their sum, the derivative along tau == t, is exact.

q property

q: int

Number of scalar kernel components.

m property

m: int

Latent output dimension of each A_p.

path_dim property

path_dim: int

Input path dimension d.

fractional classmethod

fractional(*, beta: Array, A: Array) -> FractionalKernel

Construct a multivariate fractional Volterra kernel.

The scalar kernels are

\[ k_p(t,s) = \frac{(t-s)^{\beta_p - 1}}{\Gamma(\beta_p)}, \qquad p = 1,\ldots,n, \]

where \(\beta_p > 0\).

Parameters:

Name Type Description Default
beta Array

Exponent vector of shape (n,) with all entries positive.

required
A Array

Kernel matrices of shape (n, m, d).

required

gamma classmethod

gamma(
    *,
    beta: Array,
    A: Array,
    scale: Array = 1.0,
    rate: Array = 1.0,
    quad_order: int = 64,
) -> GammaKernel

Construct a scalar Gamma Volterra kernel (\(n = 1\)).

The kernel is

\[ k(t,s) = \mathrm{scale} \cdot e^{-\mathrm{rate}(t-s)} \cdot \frac{(t-s)^{\beta-1}}{\Gamma(\beta)}, \]

where \(\beta > 0\), \(\mathrm{scale} > 0\) and \(\mathrm{rate} \geq 0\).

Parameters:

Name Type Description Default
beta Array

Shape parameter, scalar or shape (1,). Must be positive.

required
A Array

Kernel matrix of shape (1, m, d).

required
scale Array

Positive scale factor.

1.0
rate Array

Non-negative exponential decay rate.

1.0
quad_order int

Number of tanh-sinh nodes for coefficients with rate * (t - s) above the threshold of the truncated series (13.85 in float64 and 18.93 in float32); see GammaKernel.

64

fssk classmethod

fssk(fssk: FSSK) -> FSSKConvolutionKernel

Construct a finite-state-space Volterra kernel adapter.

Wraps an FSSK instance so that it satisfies the ConvolutionKernel interface. The scalar kernels are smooth exponential mixtures (\(\beta = 1\)).

Parameters:

Name Type Description Default
fssk FSSK

Finite-state-space kernel to wrap.

required

alpha

alpha(
    layout: MultiIndexLayout,
    *,
    rho: float | Array = 0.0,
    dtype: dtype,
    s: Array,
    t: Array,
    tau: Array,
) -> tuple[Array, Array]

Evaluate normalized kernel coefficients for time triples (s, t, tau).

Returns (vals, valid) where vals has shape leading + (n, M) and valid has shape leading.

coef

coef(
    s: Array,
    t: Array,
    tau: Array,
    *,
    trunc: int,
    rho: float | Array = 0.0,
    dtype: Optional[dtype] = None,
) -> VolterraCoefficients

Build packed coefficients for broadcasted triples (s, t, tau).

s, t and tau are broadcast to a common leading shape. The returned alpha has shape leading + (n, M). Triples outside s < t <= tau are marked invalid and their coefficients are zero.

Parameters:

Name Type Description Default
rho float | Array

Basis exponent for higher-order schemes. rho=0 (default) recovers the standard Euler coefficients.

0.0

coef_grid

coef_grid(
    times: Array,
    *,
    trunc: int,
    rho: float | Array = 0.0,
    tau: Optional[Array] = None,
    dtype: Optional[dtype] = None,
) -> VolterraCoefficients

Build source/readout-grid coefficients.

Parameters:

Name Type Description Default
times Array

Path grid of shape (S + 1,). Source interval i is [times[i], times[i+1]].

required
rho float | Array

Basis exponent for higher-order schemes. rho=0 (default) recovers the standard Euler coefficients.

0.0
tau Optional[Array]

Optional readout times of shape (R,). If omitted, tau = times[1:] and the leading coefficient shape is (S, S).

None
trunc int

Tensor truncation level.

required

Returns:

Type Description
VolterraCoefficients

Coefficients with leading shape (S, R).

lag_weights

lag_weights(
    *,
    out_len: int,
    h: Array,
    theta: Array,
    n: int,
    rho: float | Array = 0.0,
    dtype: dtype,
) -> Array

Lag-k causal convolution weights for k = 0, ..., out_len-1.

Evaluates the degree-(n-1) Volterra coefficients at the time triples s=0, t=h, tau=(k+θ)·h, which are the causal convolution weights for the order-n term of the discrete signature kernel. Lag 0 is always zero (strict causality, tau < t).

Returns an array of shape (out_len, self.q, M_{n-1}), where M_{n-1} is the number of multi-indices of degree n-1 for self.n components.

FractionalKernel dataclass

FractionalKernel(A: Array, beta: Array)

Bases: ConvolutionKernel

Multivariate fractional Volterra kernel.

The scalar kernels are

\[ k_p(t,s) = \frac{(t-s)^{\beta_p - 1}}{\Gamma(\beta_p)}, \qquad p = 1,\ldots,n, \]

where \(\beta_p > 0\) is the fractional order of \(k_p\) (in particular \(\beta_p = 1\) gives the flat kernel \(k_p \equiv 1\)). The full kernel is \(K(t,s) = \sum_p k_p(t,s)\,A_p\).

Parameters:

Name Type Description Default
beta Array

Fractional-order vector of shape (n,) with all entries positive (\(\beta_p = 1\) recovers the flat/classical case).

required
A Array

Kernel matrices of shape (n, m, d).

required

GammaKernel dataclass

GammaKernel(
    A: Array,
    beta: Array,
    scale: Array,
    rate: Array,
    quad_order: int = 64,
)

Bases: ConvolutionKernel

Scalar Gamma Volterra kernel (\(n = 1\)).

The kernel is

\[ k(t,s) = \mathrm{scale} \cdot e^{-\mathrm{rate}(t-s)} \cdot \frac{(t-s)^{\beta-1}}{\Gamma(\beta)}, \]

where \(\beta > 0\), \(\mathrm{scale} > 0\) and \(\mathrm{rate} \geq 0\).

With \(\lambda = \mathrm{rate}\), \(h = t-s\), \(n = |\ell|+1\) and the same unnormalised basis weight \((u-s)^\rho\) as FractionalKernel, the coefficients are :math:\alpha_n(s,t,\tau;\rho) = h^{-n}\int_s^t (u-s)^\rho\, \dot\kappa_n(u)\,\mathrm{d}u. Expanding \(e^{-\lambda(\tau-u)} = e^{-\lambda(\tau-s)}\sum_j \lambda^j(u-s)^j/j!\) gives the exact positive series

\[ \alpha_n(\rho) = \mathrm{scale}^n e^{-\lambda(\tau-s)} \sum_{j\ge 0} \frac{\lambda^j}{j!}\,\alpha^{\mathrm{frac}}_n(\rho+j), \]

where \(\alpha^{\mathrm{frac}}_n\) is the closed form of FractionalKernel. It is truncated after 64 terms, which bounds the relative error by \(\sum_{j\ge 64} x^j/j!\) with \(x = \lambda h\); this is below half the machine epsilon for \(x \le 13.8\) in float64 and \(x \le 18.9\) in float32. Larger \(x\) substitute \((t-u)/h = -\log(1-cy)/x\), \(c = 1-e^{-x}\), so that \(e^{-xv}\,\mathrm{d}v = (c/x)\,\mathrm{d}y\) for \(v = (t-u)/h\), and apply the tanh-sinh rule on \(y \in [0, 1]\) with quad_order nodes \(y_k = (1+e^{-\pi\sinh t_k})^{-1}\) at equispaced \(t_k\). For \(\beta \ge 0.15\) its float64 relative error is about 1e-9 for \(n\beta < 3\) and 1e-7 for \(n\beta < 6\) with 64 nodes and about 1e-11 for \(n\beta < 6\) with 128 nodes; it grows with the exponent of the integrand factor \((\tau-u)^{n\beta-1}\). In float32 it is about 1e-5.

Second derivatives that involve s, t or tau are NaN at tau == t, for tau < t and for rate * (t - s) above the series threshold.

Parameters:

Name Type Description Default
beta Array

Shape parameter, scalar or shape (1,). Must be positive.

required
scale Array

Positive scale factor.

required
rate Array

Non-negative exponential decay rate.

required
A Array

Kernel matrix of shape (1, m, d).

required
quad_order int

Number of tanh-sinh nodes for coefficients with rate * (t - s) above the series threshold (13.85 in float64, 18.93 in float32). When any coefficient of a call is above it, every coefficient of that call costs quad_order, rounded up to a multiple of 16, incomplete-beta evaluations.

64

FSSKConvolutionKernel dataclass

FSSKConvolutionKernel(
    A: Array,
    beta: Array,
    lam: Lambda,
    b: Array,
    quad_order: int = 32,
)

Bases: ConvolutionKernel

Expose an FSSK kernel through the generic ConvolutionKernel interface.

This lets the generic Volterra iteration code call:

kernel.coef(..., rho=...)

while the coefficient values are computed using the FSSK psi coefficients.

Notes

FSSK is smooth/exponential, so beta is fixed to ones(q).

state_dim property

state_dim: int

FSSK state dimension R.

from_fssk classmethod

from_fssk(fssk: FSSK) -> FSSKConvolutionKernel

Build a generic ConvolutionKernel adapter from an existing FSSK.

alpha

alpha(
    layout: MultiIndexLayout,
    *,
    rho: float | Array = 0.0,
    dtype: dtype,
    s: Array,
    t: Array,
    tau: Array,
) -> tuple[Array, Array]

Evaluate packed FSSK Volterra coefficients.

Returns:

Name Type Description
vals Array

Array of shape leading_shape + (q, M), where M = layout.size.

valid Array

Boolean array of shape leading_shape.

The coefficient is

vals[..., p, ell] = psi_rho[..., ell, R] · exp(-Lambda * (tau - t)) b_p

in the normalized coefficient convention expected by VolterraCoefficients.

as_convolution_kernel

as_convolution_kernel() -> FSSKConvolutionKernel

For API symmetry; this object is already a ConvolutionKernel.

tensordev.volterra.VolterraCoefficients dataclass

VolterraCoefficients(
    layout: MultiIndexLayout,
    trunc: int,
    m: int,
    q: int,
    alpha: Array,
    valid: Array,
)

Packed interval coefficients for the quadratic Volterra-signature scheme.

This object stores the coefficient arrays consumed by the symmetric shuffle/Horner evaluation routines. These routines assume the coefficient symmetry hypothesis from the paper: the coefficient of a word w p depends on the prefix word w only through its multi-index ell.

For a triple (s,t,tau) and a prefix multi-index ell with |ell| <= trunc - 1, alpha[..., p, ell_idx] stores the normalized coefficient

K_{s,t}^{w(ell) p, tau} / (t - s)^{|ell| + 1}.

Consequently, alpha has trailing shape (q, M), where M = #{ell in N^q : |ell| <= trunc - 1}. All axes before (q, M) are generic leading axes. For grid precomputation these leading axes are usually (source_interval, readout_index).

__getitem__

__getitem__(item) -> 'VolterraCoefficients'

Slice the leading coefficient axes only.

with_leading_axis

with_leading_axis() -> 'VolterraCoefficients'

Ensure that a leading axis exists.

If the object already has leading axes, it is returned unchanged. If it is scalar in the leading axes, a length-one leading axis is inserted.

broadcast_to_leading_shape

broadcast_to_leading_shape(
    leading_shape: tuple[int, ...],
) -> "VolterraCoefficients"

Broadcast alpha and valid to a common leading shape.

broadcast_source_readout

broadcast_source_readout(
    steps: int, readouts: int | None = None
) -> "VolterraCoefficients"

Broadcast the first two leading axes to a grid shape.

This is the convention used by the quadratic Volterra recursion: leading axes (S, R) correspond to source intervals and readout indices. Existing axes must either be singleton axes or already have the requested length.

tensordev.volterra.quadratic_iteration

quadratic_iteration(
    dX: Array,
    *,
    kernel: ConvolutionKernel,
    trunc=None,
    dt: Array | float = 1.0,
    axis: int = -2,
    return_trajectory: bool = False,
    order: int = 0,
    core=None,
    seq_core=None,
)

Quadratic Volterra-Chen recursion on pre-processed increments.

Expects dX to already be in increment form (no differencing) and on the final time grid (dyadic refinement applied externally if needed). All preprocessing is the responsibility of the caller — typically the high-level vsig.

Parameters:

Name Type Description Default
dX Array

Increments. Shape (*batch, S, d) with step axis at axis and trailing path dimension d = kernel.path_dim.

required
kernel ConvolutionKernel

Volterra kernel supplying projections and coefficient builders.

required
trunc

Active integer or bidegree truncation. May be omitted for a bounded core with a configured default.

None
dt Array | float

Step size(s). Scalar → uniform grid; 1-D array of length S → non-uniform grid (default 1.0).

1.0
axis int

Step axis of dX (default -2).

-2
return_trajectory bool

If True, return [V_1, ..., V_S] with the step axis at axis. If False (default), return the terminal V_S.

False
order int

Quadrature order for the basis-expansion scheme. 0 (default) left-point; 1 uses {1, s^beta, s}; 2 uses {1, s^beta, s, s^(beta+1), s^2}.

0
core

Algebra and sequential JAX cores. Omitted values resolve from the coherent process default.

None
seq_core

Algebra and sequential JAX cores. Omitted values resolve from the coherent process default.

None

Returns:

Type Description
object

Native tensor element, or a native full trajectory when return_trajectory=True.

tensordev.volterra.fft_iteration

fft_iteration(
    dX: Array,
    *,
    kernel: ConvolutionKernel,
    trunc=None,
    dt: Array | float = 1.0,
    axis: int = -2,
    return_trajectory: bool = False,
    order: int = 0,
    lag_tables: PrecomputedLagTables | None = None,
    core=None,
    seq_core=None,
)

Volterra signature via FFT convolution on a uniform grid.

dX must already contain increments on the final grid. The returned tensor uses the native format of the resolved algebra core. trunc may therefore be an integer for total degree or a bidegree pair for a standard bidegree core; a bounded core may supply its default when trunc is omitted.

tensordev.volterra.pc_iteration

pc_iteration(
    dX: Array,
    *,
    kernel: ConvolutionKernel,
    trunc=None,
    dt: Array | float = 1.0,
    axis: int = -2,
    return_trajectory: bool = False,
    order: int = 1,
    core=None,
    seq_core=None,
)

Volterra signature via Adams predictor-corrector on a uniform grid.

Restricted to FractionalKernel with a single component (q=1). The time convolution is accelerated with FFT, so dt must be a scalar (uniform grid).

Parameters:

Name Type Description Default
dX Array

Increments with step axis at axis and trailing path dimension d = kernel.path_dim. Dyadic refinement is applied by the caller (vsig) before this function is invoked.

required
kernel ConvolutionKernel

Must be a FractionalKernel with q=1.

required
trunc

Active integer or bidegree truncation. May be omitted for a bounded core with a configured default.

None
dt Array | float

Uniform step size scalar (default 1.0).

1.0
axis int

Step axis of dX (default -2).

-2
return_trajectory bool

If True, return [V_1, ..., V_S] with the step axis at axis. If False (default), return only the terminal V_S.

False
order int

0 → Euler (left-point) quadrature weights. ≥1 → predictor-corrector (trapezoidal) quadrature weights.

1
core

Algebra and sequential JAX cores. Omitted values resolve from the coherent process default.

None
seq_core

Algebra and sequential JAX cores. Omitted values resolve from the coherent process default.

None

Returns:

Type Description
object

Native tensor element, or a native full trajectory when return_trajectory=True.

Raises:

Type Description
TypeError

If kernel is not a FractionalKernel.

ValueError

If kernel.q != 1 or other arguments are invalid.

State-space signatures

StateSpaceSignature binds a finite state-space kernel (FSSK), a truncation and a hidden state, and computes Volterra signatures by a state recursion; fssk_vsig and fssk_state are the functional forms. Lambda is the state operator, with the dense and real-Jordan implementations DenseLambda and JordanLambda. Examples are on State-space signatures.

StateSpaceSignature dataclass

StateSpaceSignature(
    kernel: FSSK,
    trunc: Any,
    state: Any = None,
    core: Any = None,
    seq_core: Any = None,
)

Thin wrapper around FSSK that binds a truncation, algebra core, sequential core, and optional hidden recursion state.

Parameters:

Name Type Description Default
kernel FSSK

The underlying finite-state-space Volterra kernel.

required
trunc Any

Positive total-degree level or nonzero bidegree rectangle. Static changes cause retracing.

required
state Any

Hidden recursion seed in first-on format. A total-degree core uses a tuple without degree zero; a bidegree core uses a scalar-omitting BigradedTensor. Defaults to None, in which case a zero state is created.

None
core Any

Algebra and sequential cores. Both default to the configured core pair and remain bound to the returned object.

None
seq_core Any

Algebra and sequential cores. Both default to the configured core pair and remain bound to the returned object.

None

from_matrix classmethod

from_matrix(
    *,
    trunc: Any,
    state: Any = None,
    core: Any = None,
    seq_core: Any = None,
    **kwargs,
) -> StateSpaceSignature

Construct from a dense Lambda matrix. Forwards all kwargs to FSSK.from_matrix.

from_jordan classmethod

from_jordan(
    *,
    trunc: Any,
    state: Any = None,
    core: Any = None,
    seq_core: Any = None,
    **kwargs,
) -> StateSpaceSignature

Construct from Jordan block data. Forwards all kwargs to FSSK.from_jordan.

from_prony classmethod

from_prony(
    *,
    trunc: Any,
    state: Any = None,
    core: Any = None,
    seq_core: Any = None,
    **kwargs,
) -> StateSpaceSignature

Construct from Prony coefficients. Forwards all kwargs to FSSK.from_prony.

update_with_path

update_with_path(
    X: Array,
    *,
    dt: Array | float,
    axis: int = -2,
    increment_input: bool = False,
    execution: str = "auto",
) -> StateSpaceSignature

Process a multi-step path X and return a new instance with the terminal hidden state.

Takes the current state as the seed, runs the FSSK recursion over all steps of X, and stores the resulting terminal state in the returned instance. The kernel, truncation, and cores are preserved.

Parameters:

Name Type Description Default
X Array

Path nodes or increments, shape (..., S, d) by default. The step axis is selected by axis and the trailing axis must match self.kernel.path_dim.

required
dt Array | float

Step size(s). Scalar, (S,) array, or matching batch/step axes of X without the trailing coordinate axis.

required
axis int

Step axis of X (default -2).

-2
increment_input bool

Pass True if X already contains increments rather than path nodes (skips the internal jnp.diff).

False
execution str

"auto", "jax", or "wordwise"; see fssk_state.

'auto'

Returns:

Type Description
StateSpaceSignature

New instance identical to self except state is replaced by the terminal hidden state after processing X.

update_with_increment

update_with_increment(
    dx: Array, *, dt: Array | float, execution: str = "auto"
) -> StateSpaceSignature

Advance the state by a single increment dx.

Convenience wrapper around update_with_path for the common online case where increments arrive one at a time.

Parameters:

Name Type Description Default
dx Array

A single path increment with shape (..., d) where d must match self.kernel.path_dim. No step axis is expected.

required
dt Array | float

Scalar step size for this increment.

required
execution str

"auto", "jax", or "wordwise"; see fssk_state.

'auto'

Returns:

Type Description
StateSpaceSignature

New instance with state advanced by one step.

readout

readout(*, tau_dt: Array | float = 0.0) -> Any

Read out the truncated Volterra signature from the current hidden state.

Evaluates the linear readout

1 + sum_p Z^p · exp(-Lambda · tau_dt) · b_p

where Z^p are the stored hidden state levels.

Parameters:

Name Type Description Default
tau_dt Array | float

Non-negative readout lag tau - t. Scalar or arbitrary batch shape; broadcasts against the state leading axes.

0.0

Returns:

Type Description
tuple or BigradedTensor

Truncated Volterra signature in the bound core's native layout and coordinates. The scalar block is the unit 1.

reset

reset(new_state: Any = None) -> StateSpaceSignature

Return a copy with the hidden state reset.

Parameters:

Name Type Description Default
new_state Any

Replacement state in first-on format. When None (default) the state is reset to zeros via __post_init__.

None

Returns:

Type Description
StateSpaceSignature

New instance identical to self except state is replaced.

states

states(
    X: Array,
    *,
    dt: Array | float,
    axis: int = -2,
    block_size: int | None = None,
    accumulate: bool = True,
    initial_state: Any = None,
    output_starting_state: bool = True,
    increment_input: bool = False,
    execution: str = "auto",
) -> Any

Return the hidden-state trajectory over X.

A thin, read-only wrapper around fssk_state. self.state is used as the recursion seed by default but is never modified.

Parameters:

Name Type Description Default
X Array

Path nodes or increments (..., S, d); step axis axis.

required
dt Array | float

Step size(s), same conventions as update_with_path.

required
axis int

Step axis of X (default -2).

-2
block_size int | None

Steps per emitted state block. None (default) emits a single block covering the full sequence.

None
accumulate bool

Carry hidden state across blocks (default True).

True
initial_state Any

Explicit seed in first-on format. Defaults to self.state.

None
output_starting_state bool

Prepend the seed state to the output (default True).

True
increment_input bool

True if X already contains increments.

False
execution str

"auto", "jax", or "wordwise"; see fssk_state.

'auto'

Returns:

Type Description
tuple or BigradedTensor

First-on state trajectory in the bound core's native layout and coordinates, with the emitted block axis placed at axis.

vsig

vsig(
    X: Array,
    *,
    dt: Array | float,
    axis: int = -2,
    block_size: int | None = None,
    accumulate: bool = True,
    initial_state: Any = None,
    output_starting_state: bool = False,
    tau_dt: Array | float = 0.0,
    increment_input: bool = False,
    execution: str = "auto",
) -> Any

Compute the Volterra signature of X.

Runs the FSSK recursion and applies the linear readout. self.state is never modified.

When block_size is None (default) and output_starting_state=False, returns the signature at the single terminal time. Set block_size=1 and output_starting_state=True to obtain a full per-step signature trajectory.

Parameters:

Name Type Description Default
X Array

Path nodes or increments (..., S, d); step axis axis.

required
dt Array | float

Step size(s), same conventions as update_with_path.

required
axis int

Step axis of X (default -2).

-2
block_size int | None

Steps per emitted block. None = full sequence.

None
accumulate bool

Carry hidden state across blocks (default True).

True
initial_state Any

Explicit seed in first-on format. Defaults to self.state.

None
output_starting_state bool

Include the readout of the seed state (default False).

False
tau_dt Array | float

Non-negative readout lag tau - t; broadcasts against batch axes.

0.0
increment_input bool

True if X already contains increments.

False
execution str

"auto", "jax", or "wordwise"; see fssk_state.

'auto'

Returns:

Type Description
tuple or BigradedTensor

Volterra signature in the bound core's native layout and coordinates. With blocking, an emitted block axis appears at axis.

FSSK dataclass

FSSK(
    Lambda: Lambda, A: Array, b: Array, quad_order: int = 32
)

Finite-state-space Volterra kernel data.

This class represents kernels of the form

\[ K_{A,b}^{\Lambda}(t, s) = \sum_{r=1}^n \big(\mathbf 1^\top e^{-\Lambda(t-s)} b_r\big) A_r, \]

where A_r in R^{m x d}, b_r in R^R and Lambda is a state-space operator providing expm and shifted linear solves.

The method coef interprets dt as an arbitrary batch of time increments. If dt.shape == batch_shape, then the returned coefficient arrays carry the same leading batch_shape.

q property

q: int

Number of kernel components in the decomposition.

m property

m: int

Latent Volterra state width of each component matrix A_r.

path_dim property

path_dim: int

Path dimension d of the driving signal.

state_dim property

state_dim: int

State-space dimension R of the realization.

__post_init__

__post_init__() -> None

Validate and normalize the kernel arrays.

The kernel matrices A are stored with shape (n, m, d) and the state vectors b with shape (n, R). Both arrays are converted to JAX arrays so that the resulting kernel is a valid pytree and can be passed into jitted helper functions.

from_matrix classmethod

from_matrix(
    *,
    Lambda: Array,
    A: Array,
    b: Array,
    quad_order: int = 32,
) -> "FSSK"

Construct a kernel from a dense matrix realization.

This constructor uses the finite-state-space realization

\[ K_{A,b}^{\Lambda}(t,s) = \sum_{r=1}^n \big(\mathbf 1^\top e^{-\Lambda (t-s)} b_r\big) A_r, \]

where:

  • \(\Lambda \in \mathbb{R}^{R \times R}\) is given directly as a dense matrix,
  • \(b_r \in \mathbb{R}^R\) are the state vectors collected in b,
  • \(A_r \in \mathbb{R}^{m \times d}\) are the kernel matrices collected in A.

This is the most direct constructor. It is appropriate when the state-space realization is already available in matrix form and no additional structural assumptions on \(\Lambda\) are to be used.

Parameters:

Name Type Description Default
Lambda Array

Dense state matrix with shape (R, R).

required
A Array

Kernel matrices with shape (n, m, d).

required
b Array

State vectors with shape (n, R).

required
quad_order int

Number of contour quadrature nodes used by coef.

32

Returns:

Type Description
FSSK

Kernel using a DenseLambda realization.

from_prony classmethod

from_prony(
    *,
    A: Array,
    real_rates: Array = (),
    real_sizes: Array = (),
    osc_decays: Array = (),
    osc_freqs: Array = (),
    osc_sizes: Array = (),
    alpha: Optional[Array] = None,
    beta: Optional[Array] = None,
    delta: Optional[Array] = None,
    quad_order: int = 32,
) -> "FSSK"

Construct a kernel from Jordan data and Prony coefficients.

This constructor first builds a JordanLambda from the prescribed real and oscillatory Jordan blocks, and then constructs the state vectors b from Prony coefficients alpha, beta and delta.

The resulting kernel has the form

\[ K_{A,b}^{\Lambda}(t,s) = \sum_{r=1}^n \big(\mathbf 1^\top e^{-\Lambda (t-s)} b_r\big) A_r. \]

For each component \(r\), the vector \(b_r\) is assembled blockwise in the Jordan basis.

Real Jordan blocks. For a real block of size \(n\) with coefficients

\[ \alpha^{(r)} = (\alpha^{(r)}_0, \ldots, \alpha^{(r)}_{n-1}), \]

and the convention \(\alpha^{(r)}_n = 0\), define

\[ \Delta \alpha^{(r)}_k = \alpha^{(r)}_k - \alpha^{(r)}_{k+1}, \qquad k = 0, \ldots, n-1. \]

The contribution of that block to \(b_r\) is

\[ b^{(r)}_{\mathrm{real}} = \big( \Delta\alpha^{(r)}_0, \ldots, \Delta\alpha^{(r)}_{n-1} \big). \]

Oscillatory Jordan block pairs. For an oscillatory pair of size \(n\) with coefficients

\[ \beta^{(r)} = (\beta^{(r)}_0, \ldots, \beta^{(r)}_{n-1}), \qquad \delta^{(r)} = (\delta^{(r)}_0, \ldots, \delta^{(r)}_{n-1}), \]

and the conventions \(\beta^{(r)}_n = \delta^{(r)}_n = 0\), define

\[ \Delta \beta^{(r)}_k = \beta^{(r)}_k - \beta^{(r)}_{k+1}, \qquad \Delta \delta^{(r)}_k = \delta^{(r)}_k - \delta^{(r)}_{k+1}. \]

The corresponding length-\(2n\) Jordan-basis contribution is

\[ b^{(r)}_{\mathrm{osc}} = \Big( \tfrac12(\Delta\beta^{(r)}_0 - \Delta\delta^{(r)}_0), \tfrac12(\Delta\beta^{(r)}_0 + \Delta\delta^{(r)}_0), \ldots, \tfrac12(\Delta\beta^{(r)}_{n-1} - \Delta\delta^{(r)}_{n-1}), \tfrac12(\Delta\beta^{(r)}_{n-1} + \Delta\delta^{(r)}_{n-1}) \Big). \]

The full vector \(b_r\) is obtained by concatenating all real-block and oscillatory-block contributions in the same order as the blocks are specified to JordanLambda.

Parameters:

Name Type Description Default
A Array

Kernel matrices with shape (n, m, d).

required
real_rates array - like

Rates and Jordan block sizes for the real scalar poles.

()
real_sizes array - like

Rates and Jordan block sizes for the real scalar poles.

()
osc_decays array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
osc_freqs array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
osc_sizes array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
alpha Array

Prony coefficients used to construct b.

  • alpha must have shape (n, sum(real_sizes)) when real blocks are present.
  • beta and delta must both have shape (n, sum(osc_sizes)) when oscillatory blocks are present.
None
beta Array

Prony coefficients used to construct b.

  • alpha must have shape (n, sum(real_sizes)) when real blocks are present.
  • beta and delta must both have shape (n, sum(osc_sizes)) when oscillatory blocks are present.
None
delta Array

Prony coefficients used to construct b.

  • alpha must have shape (n, sum(real_sizes)) when real blocks are present.
  • beta and delta must both have shape (n, sum(osc_sizes)) when oscillatory blocks are present.
None
quad_order int

Number of contour quadrature nodes used by coef.

32

Returns:

Type Description
FSSK

Kernel using a JordanLambda realization with b constructed from the supplied Prony coefficients.

from_jordan classmethod

from_jordan(
    *,
    A: Array,
    b: Array,
    real_rates: Array = (),
    real_sizes: Array = (),
    osc_decays: Array = (),
    osc_freqs: Array = (),
    osc_sizes: Array = (),
    quad_order: int = 32,
) -> "FSSK"

Construct a kernel from Jordan block data and explicit state vectors.

This constructor builds a JordanLambda from the prescribed real and oscillatory Jordan blocks, while the state vectors b are supplied directly.

The resulting kernel has the finite-state-space form

\[ K_{A,b}^{\Lambda}(t,s) = \sum_{r=1}^n \big(\mathbf 1^\top e^{-\Lambda (t-s)} b_r\big) A_r. \]

Here \(\Lambda\) is not passed as a dense matrix. Instead it is specified through its Jordan structure:

  • real Jordan blocks with rates real_rates and sizes real_sizes,
  • oscillatory Jordan block pairs with decays osc_decays, frequencies osc_freqs and sizes osc_sizes.

The vectors b_r are assumed to already be expressed in the same Jordan basis determined by those block specifications.

Parameters:

Name Type Description Default
A Array

Kernel matrices with shape (n, m, d).

required
b Array

State vectors with shape (n, R), expressed in the Jordan basis induced by the supplied block data.

required
real_rates array - like

Rates and Jordan block sizes for the real scalar poles.

()
real_sizes array - like

Rates and Jordan block sizes for the real scalar poles.

()
osc_decays array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
osc_freqs array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
osc_sizes array - like

Decays, frequencies and Jordan block sizes for oscillatory pole pairs.

()
quad_order int

Number of contour quadrature nodes used by coef.

32

Returns:

Type Description
FSSK

Kernel using a JordanLambda realization with explicitly provided Jordan-basis vectors b.

coef

coef(
    dt: Array, *, trunc: int, dtype: Optional[dtype] = None
) -> FSSKCoefficients

Build packed FSSK coefficients for a batch of time increments.

Let batch_shape = dt.shape. Then the returned coefficient arrays have shapes

  • E: batch_shape + (R, R)
  • psi: batch_shape + (M, R)
  • phi: batch_shape + (n, Mphi, R, R)

where M and Mphi are determined by the packed multi-index layout.

Parameters:

Name Type Description Default
dt Array

Array of time increments. Its full shape is treated as a batch shape.

required
trunc int

Tensor truncation level. The packed multi-index layout is built up to degree trunc - 1.

required
dtype optional

Real dtype used for the returned arrays. If omitted, the dtype is inherited from b.

None

Returns:

Type Description
FSSKCoefficients

Packed coefficient object containing the propagators E and the normalized coefficient arrays psi and phi over the batch induced by dt.

fssk_vsig

fssk_vsig(
    X: Array,
    *,
    kernel: FSSK,
    dt: Array | float,
    trunc: Any = None,
    axis: int = -2,
    block_size: int | None = None,
    accumulate: bool = True,
    initial_state: Any = None,
    output_starting_state: bool = False,
    tau_dt: Array | float = 0.0,
    increment_input: bool = False,
    core: Any = None,
    seq_core: Any = None,
    execution: str = "auto",
) -> Any

Compute the Volterra signature of a path via the FSSK recursion.

Equivalent to calling fssk_state followed by fssk_readout. When block_size is None (default) and output_starting_state=False, returns the signature at the single terminal time. Set block_size=1 and output_starting_state=True to obtain a full per-step signature trajectory.

Parameters:

Name Type Description Default
X Array

Path nodes or increments. Trailing axis is the coordinate dim kernel.path_dim; axis is the step axis. Set increment_input=True to skip jnp.diff.

required
kernel FSSK

Finite-state-space Volterra kernel.

required
dt Array | float

Step size(s). Accepted shapes: scalar, (1,), (S,), or matching batch/step axes of X without the trailing coordinate axis.

required
trunc Any

Positive total-degree level or nonzero bidegree rectangle. When omitted, the selected core's default truncation is used.

None
axis int

Step axis of X (default -2).

-2
block_size int | None

Steps per emitted block (None = full sequence).

None
accumulate bool

Carry hidden state across blocks (default True).

True
initial_state Any

Optional core-native seed in first-on format.

None
output_starting_state bool

Include the readout of the seed state (default False).

False
tau_dt Array | float

Non-negative readout lag tau - t; broadcasts against batch axes.

0.0
increment_input bool

Treat X as increments rather than path nodes.

False
core Any

Algebra and sequential JAX cores. Both default to the configured pair. Non-standard cores require kernel.q == 1.

None
seq_core Any

Algebra and sequential JAX cores. Both default to the configured pair. Non-standard cores require kernel.q == 1.

None
execution str

"auto", "jax", or "wordwise"; see fssk_state.

'auto'

Returns:

Type Description
tuple or BigradedTensor

Volterra signature in the selected core's native layout and coordinates. With blocking, an emitted block axis appears at axis.

fssk_state

fssk_state(
    X: Array,
    *,
    kernel: FSSK,
    dt: Array | float,
    trunc: Any = None,
    axis: int = -2,
    block_size: int | None = None,
    accumulate: bool = True,
    initial_state: Any = None,
    output_starting_state: bool = False,
    increment_input: bool = False,
    core: Any = None,
    seq_core: Any = None,
    execution: str = "auto",
) -> Any

Compute hidden FSSK recursion states from path nodes or increments.

Projects each increment through kernel.A, builds coefficients via kernel.coef, and delegates to fssk_state_from_coef.

Parameters:

Name Type Description Default
X Array

Path nodes or increments. Trailing axis is the coordinate dim kernel.path_dim; axis is the step axis. Set increment_input=True to skip jnp.diff.

required
kernel FSSK

Finite-state-space Volterra kernel.

required
dt Array | float

Step size(s). Accepted shapes: scalar, (1,), (S,), or matching batch/step axes of X without the trailing coordinate axis.

required
trunc Any

Positive total-degree level or nonzero bidegree rectangle. When omitted, the selected core's default truncation is used.

None
axis int

Step axis of X.

-2
block_size int | None

Steps per emitted block (None = full sequence).

None
accumulate bool

Carry hidden state across blocks.

True
initial_state Any

Optional core-native seed in first-on format.

None
output_starting_state bool

Prepend seed state to the output.

False
increment_input bool

Treat X as increments rather than path nodes.

False
core Any

Algebra and sequential JAX cores. Both default to the configured core pair. Non-standard cores require kernel.q == 1.

None
seq_core Any

Algebra and sequential JAX cores. Both default to the configured core pair. Non-standard cores require kernel.q == 1.

None
execution str

"auto" uses the default implementation; "jax" forces portable JAX. "wordwise" requests the alpha implementation for kernel.q == 1 and raises if unsupported. It requires eager float32/float64 inputs on one NVIDIA GPU with CUDA compute capability 8.0 or newer, outside jit, grad, and vmap.

'auto'

tensordev.sss.Lambda

Bases: ABC

State operator \(\Lambda\) of a finite-state-space kernel.

For dt of shape () or (m,) the methods evaluate \(f(-dt\,\Lambda)\) for

\[ f=\exp\quad\text{or}\quad f=\varphi_k,\ \ \varphi_k(z)=\sum_{j=0}^{\infty}\frac{z^j}{(j+k)!},\ k=1,2, \]

apply it to operands, and solve \((\zeta I+dt\,\Lambda)x=b\). precompute_* returns a copy that stores \(f(-dt\,\Lambda)\) per step; its *_multiply_* methods apply the stored values and ignore dt. The stored values are constants: to differentiate with respect to \(\Lambda\), call precompute_* inside the differentiated function.

A subclass is a frozen dataclass with the fields _expm, _phi1 and _phi2 and defines state_dim, lambda_multiply_left, _dtype, _operator, _action_paired and _solve_paired; _operators evaluates several functions at once.

state_dim abstractmethod property

state_dim: int

Dimension R of the state space.

lambda_multiply_left abstractmethod

lambda_multiply_left(
    rhs: Array, *, dtype: Optional[dtype] = None
) -> Array

Return Lambda @ rhs acting on the second-to-last axis of rhs.

expm

expm(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> Array

Return exp(-dt * Lambda).

phi1

phi1(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> Array

Return phi_1(-dt * Lambda).

phi2

phi2(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> Array

Return phi_2(-dt * Lambda).

solve_shifted

solve_shifted(
    zeta: complex | Array,
    dt: Array | float,
    rhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Solve (zeta I + dt Lambda) x = rhs.

solve_shifted_transpose

solve_shifted_transpose(
    zeta: complex | Array,
    dt: Array | float,
    rhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Solve (zeta I + dt Lambda)^T x = rhs.

lambda_multiply_right

lambda_multiply_right(
    lhs: Array, *, dtype: Optional[dtype] = None
) -> Array

Return lhs @ Lambda^T acting on the last axis of lhs.

expm_multiply_left

expm_multiply_left(
    dt: Array | float,
    rhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return exp(-dt * Lambda) @ rhs.

expm_multiply_right

expm_multiply_right(
    dt: Array | float,
    lhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return lhs @ exp(-dt * Lambda^T).

phi1_multiply_left

phi1_multiply_left(
    dt: Array | float,
    rhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return phi_1(-dt * Lambda) @ rhs.

phi1_multiply_right

phi1_multiply_right(
    dt: Array | float,
    lhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return lhs @ phi_1(-dt * Lambda^T).

phi2_multiply_left

phi2_multiply_left(
    dt: Array | float,
    rhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return phi_2(-dt * Lambda) @ rhs.

phi2_multiply_right

phi2_multiply_right(
    dt: Array | float,
    lhs: Array,
    *,
    dtype: Optional[dtype] = None,
) -> Array

Return lhs @ phi_2(-dt * Lambda^T).

precompute_expm

precompute_expm(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> "Lambda"

Return a copy that stores exp(-dt * Lambda) per step.

precompute_phi1

precompute_phi1(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> "Lambda"

Return a copy that stores phi_1(-dt * Lambda) per step.

precompute_phi2

precompute_phi2(
    dt: Array | float, *, dtype: Optional[dtype] = None
) -> "Lambda"

Return a copy that stores phi_2(-dt * Lambda) per step.

__getitem__

__getitem__(ix) -> 'Lambda'

Return a copy whose stored values are those of step ix.

tensordev.sss.DenseLambda dataclass

DenseLambda(matrix: Array)

Bases: Lambda

State operator \(\Lambda\) given by matrix of shape (R, R).

\(e^{-t\Lambda}\) is jax.scipy.linalg.expm, and \(\varphi_k(-t\Lambda)\) is a [6/6] Padé approximant with scaling and doubling.

tensordev.sss.JordanLambda dataclass

JordanLambda(
    real_rates: Array = (lambda: jnp.zeros(0))(),
    real_sizes: tuple[int, ...] = tuple(),
    osc_decays: Array = (lambda: jnp.zeros(0))(),
    osc_freqs: Array = (lambda: jnp.zeros(0))(),
    osc_sizes: tuple[int, ...] = tuple(),
)

Bases: Lambda

Block-diagonal \(\Lambda\) with real and oscillatory Jordan blocks

\[ \lambda I_n-N_n,\qquad I_n\otimes\begin{pmatrix}\mu&-\omega\\\omega&\mu\end{pmatrix}-N_n\otimes I_2, \]

with \((\lambda, n)\) from real_rates and real_sizes, \((\mu, \omega, n)\) from osc_decays, osc_freqs and osc_sizes, and \(N_n\) the \(n\times n\) matrix with ones on its first superdiagonal. The sizes are static; \(\omega>0\) is checked for concrete frequencies.

b_from_prony

b_from_prony(
    *,
    alpha: Optional[Array] = None,
    beta: Optional[Array] = None,
    delta: Optional[Array] = None,
) -> Array

Construct the Jordan-basis vectors b from Prony coefficients.

matrix

matrix(*, dtype: Optional[dtype] = None) -> Array

Materialize the dense matrix represented by this operator.

tensordev.sss.FSSKCoefficients dataclass

FSSKCoefficients(
    layout: MultiIndexLayout,
    trunc: int,
    m: int,
    q: int,
    R: int,
    E: Array,
    psi: Array,
    phi: Array,
)

Packed coefficients for finite-state-space kernels.

Leading axes are generic broadcast axes. For state recursion, the first leading axis is interpreted as the time axis. Scalar coefficients may have no leading axis and can be converted to time length one using with_time_axis.

__getitem__

__getitem__(item) -> 'FSSKCoefficients'

Slice the leading coefficient axes only.

with_time_axis

with_time_axis() -> 'FSSKCoefficients'

Ensure a leading time axis exists.

If the object already has leading axes, it is returned unchanged. If it is scalar in time, a length-one leading axis is inserted.

broadcast_to_leading_shape

broadcast_to_leading_shape(
    leading_shape: tuple[int, ...],
) -> "FSSKCoefficients"

Broadcast all coefficient arrays to a common leading shape.

broadcast_time

broadcast_time(steps: int) -> 'FSSKCoefficients'

Broadcast the first leading axis to steps.

This is the convention used by state recursion.

Signature kernels

Every signature kernel class derives from BaseKernel: a kernel object is callable as kernel(X, Y, ...) and inherits the empirical methods compute_kernel, compute_Gram, compute_mmd, compute_scoring_rule and compute_expected_scoring_rule. The lower-case functions are the functional forms, and the static kernels are values for the static_kernel argument. Examples are on Signature kernels.

tensordev.kernel.BaseKernel

Bases: ABC

Abstract base class for configured kernel objects.

A BaseKernel instance is a callable object representing a kernel with fixed hyperparameters. Subclasses implement _compute for the actual single-device kernel evaluation and _as_sample_batch for normalization of public inputs into the batched empirical format expected by the empirical helper methods.

Parallelism and chunking

__call__ centralises both concerns:

  • Chunking (max_batch): a Python loop over blocks of at most max_batch samples is applied before any JAX work. This is a memory guard — it limits peak device memory independently of the number of accelerators.
  • Device parallelism (num_devices): after chunking, each block is dispatched via pmap_batch across num_devices devices and delegated to _compute on each shard.
Empirical convention

The empirical helpers (compute_kernel, compute_Gram, …) are thin wrappers around __call__ that perform input normalisation, size validation, and — for the symmetric Gram case — the triangle optimisation.

Input format

increment_input controls whether inputs are interpreted as path values (False, the default) or as pre-computed interval increments (True). It can be set once at construction time (via a subclass field) or overridden on a per-call basis by passing it explicitly to __call__ or any empirical helper.

__call__

__call__(
    X,
    Y,
    *,
    evaluate: str = "terminal",
    return_fg: bool = False,
    pairwise: bool = False,
    max_batch: Optional[int] = None,
    increment_input: Optional[bool] = None,
)

compute_kernel

compute_kernel(
    X,
    Y,
    *,
    max_batch: Optional[int] = 100,
    increment_input: Optional[bool] = None,
)

Compute batchwise kernel values (k(x_i, y_i))_i.

Parameters:

Name Type Description Default
X

Public inputs accepted by the concrete kernel wrapper. After normalization, both inputs must have the same empirical sample size.

required
Y

Public inputs accepted by the concrete kernel wrapper. After normalization, both inputs must have the same empirical sample size.

required
max_batch int

Passed to __call__ to limit peak memory.

100
increment_input bool

If provided, overrides the instance's increment_input for this call.

None

Returns:

Type Description
Array

Array of shape (*batch) containing the batchwise kernel values.

Raises:

Type Description
ValueError

If X and Y do not have the same batch shape.

compute_Gram

compute_Gram(
    X,
    Y=None,
    *,
    sym: bool = False,
    max_batch: Optional[int] = 100,
    increment_input: Optional[bool] = None,
)

Compute the Gram matrix (k(x_i, y_j))_{i,j}.

Parameters:

Name Type Description Default
X

Public inputs accepted by the concrete kernel wrapper. If Y is None, then Y = X and sym is forced to True.

required
Y

Public inputs accepted by the concrete kernel wrapper. If Y is None, then Y = X and sym is forced to True.

required
sym bool

If True and the two empirical sample sizes agree, only the upper triangle is computed blockwise and then mirrored.

False
max_batch int

Passed to __call__ (non-sym) or used as block size (sym triangle).

100
increment_input bool

If provided, overrides the instance's increment_input for this call.

None

Returns:

Type Description
Array

Gram matrix of shape (*batch_x, *batch_y).

Raises:

Type Description
ValueError

If sym=True and the two batch shapes do not agree.

compute_mmd

compute_mmd(
    X,
    Y,
    *,
    max_batch: Optional[int] = 100,
    increment_input: Optional[bool] = None,
)

Compute the empirical maximum mean discrepancy induced by the kernel.

The within-sample terms use the off-diagonal average of the corresponding Gram matrices.

Parameters:

Name Type Description Default
X

Public inputs accepted by the concrete kernel wrapper.

required
Y

Public inputs accepted by the concrete kernel wrapper.

required
max_batch int

Block size used internally for Gram matrix computation.

100
increment_input bool

If provided, overrides the instance's increment_input for this call.

None

Returns:

Type Description
Array

Scalar array containing the empirical MMD.

compute_scoring_rule

compute_scoring_rule(
    X,
    y,
    *,
    max_batch: Optional[int] = 100,
    increment_input: Optional[bool] = None,
)

Compute the empirical kernel scoring rule

S(X, y) = E_offdiag[k(X, X)] - 2 E[k(X, y)],

where X is a sample batch and y is a single sample.

Parameters:

Name Type Description Default
X

Public input representing a batch of samples.

required
y

Public input representing a single sample.

required
max_batch int

Block size used internally for Gram matrix computation.

100
increment_input bool

If provided, overrides the instance's increment_input for this call.

None

Returns:

Type Description
Array

Scalar array containing the empirical scoring rule.

Raises:

Type Description
ValueError

If y does not represent exactly one sample.

compute_expected_scoring_rule

compute_expected_scoring_rule(
    X,
    Y,
    *,
    max_batch: Optional[int] = 100,
    increment_input: Optional[bool] = None,
)

Compute the empirical expected kernel scoring rule

E_Y[S(X, Y)] = E_offdiag[k(X, X)] - 2 E[k(X, Y)],

where X and Y are sample batches.

Parameters:

Name Type Description Default
X

Public inputs accepted by the concrete kernel wrapper.

required
Y

Public inputs accepted by the concrete kernel wrapper.

required
max_batch int

Block size used internally for Gram matrix computation.

100
increment_input bool

If provided, overrides the instance's increment_input for this call.

None

Returns:

Type Description
Array

Scalar array containing the empirical expected scoring rule.

SigKernel dataclass

SigKernel(
    backend: str = "scan",
    dyadic_order: DyadicOrder = 0,
    num_devices: int = 1,
    static_kernel: StaticKernel = LinearKernel(scale=1.0),
    increment_input: bool = False,
)

Bases: BaseKernel

Classical linear signature kernel for Euclidean paths.

This class evaluates the signature kernel for paths in R^d and provides empirical kernel statistics such as batchwise kernel values, Gram matrices, MMD, and scoring rules.

Input convention

Inputs are paths of shape (batch, length, dim) or a single path of shape (length, dim). A single path is promoted to batch size 1.

The parameter dyadic_order controls optional dyadic refinement of the time grid before evaluation. It can be a single int (same for both paths) or a tuple (order_x, order_y) for asymmetric refinement.

The parameter static_kernel replaces the default ⟨dx_i, dy_j⟩ increment inner product with the discrete mixed-difference formula:

G[i,j] = k(x_{i+1}, y_{j+1}) - k(x_i, y_{j+1})
       - k(x_{i+1}, y_j)   + k(x_i, y_j)

where x_i are the path nodes. The default LinearKernel(scale=1.0) reproduces the classical signature kernel exactly.

FreeKernel dataclass

FreeKernel(
    backend: Literal["scan", "wavefront"] = "scan",
    dyadic_order: DyadicOrder = 0,
    increment_input: bool = False,
    num_devices: int = 1,
    static_kernel: StaticKernel = LinearKernel(scale=1.0),
)

Bases: BaseKernel

Kernel induced by truncated free developments of tensor-valued paths.

This class evaluates the free kernel on tensor paths given in packed positive-level form and provides empirical kernel statistics such as batchwise kernel values, Gram matrices, MMD, and scoring rules.

Input convention

Inputs are given as one tensor level or as a tuple/list of tensor levels.

  • A single array is interpreted as a level-1 tensor path.
  • A tuple/list is interpreted as packed positive tensor levels.
  • A missing leading sample axis is promoted to batch size 1.

Depending on increment_input, tensor inputs are interpreted either as path values or as interval increments.

free_kernel

free_kernel(
    x,
    y,
    *,
    evaluate: Literal["terminal", "grid"] = "terminal",
    return_fg: bool = False,
    pairwise: bool = False,
    backend: Literal["scan", "wavefront"] = "scan",
    dyadic_order: DyadicOrder = 0,
    increment_in: bool = False,
    quadrature: Literal[
        "left", "midpoint", "trapezoid"
    ] = "left",
    static_kernel: StaticKernel = LinearKernel(scale=1.0),
)

Compute the truncated kernel of free developments.

Parameters:

Name Type Description Default
x

Tensor-level tuples, interpreted as path values if increment_in=False and as interval increments if increment_in=True.

If increment_in=True, the k-th level should have shape batch + (S, d**k) for x and batch + (T, d**k) for y. If increment_in=False, the k-th level should have shape batch + (S+1, d**k) for x and batch + (T+1, d**k) for y.

required
y

Tensor-level tuples, interpreted as path values if increment_in=False and as interval increments if increment_in=True.

If increment_in=True, the k-th level should have shape batch + (S, d**k) for x and batch + (T, d**k) for y. If increment_in=False, the k-th level should have shape batch + (S+1, d**k) for x and batch + (T+1, d**k) for y.

required
evaluate ('terminal', 'grid')

Whether to return only the terminal value or the full discrete solution.

"terminal"
return_fg bool

If True, also return the tensor-valued components f and g.

False
pairwise bool

If True, evaluate the kernel pairwise over the batch axes of x and y.

False
backend ('scan', 'wavefront')

Discrete solver backend.

"scan"
dyadic_order int or tuple of int

Dyadic refinement level. A single int applies the same refinement to both paths. A tuple (order_x, order_y) allows different refinement for x and y. Each coarse interval is split into 2**order sub-intervals; driving data is stored on the coarse grid and indexed lazily (memory-efficient).

0
increment_in bool

Whether tensor-valued inputs x and y are already given as interval increments. If False, they are interpreted as path values and converted to increments along the interval axis.

False
static_kernel StaticKernel

Static (pointwise) kernel used to compute the driving term G_ij in the M == N == 1 fast path via the discrete mixed-difference formula:

G[i,j] = k(x_{i+1}, y_{j+1}) - k(x_i, y_{j+1})
       - k(x_{i+1}, y_j)   + k(x_i, y_j)

where x_i are the cumulative-sum node values of the level-1 increments. With the default LinearKernel(scale=1.0), this is exactly the increment inner product G[i,j] = ⟨dx_i, dy_j⟩.

Has no effect when M > 1 or N > 1.

LinearKernel(scale=1.0)

Returns:

Type Description
Depending on evaluate and return_fg, returns either w or
(w, f, g), either at the terminal point or on the full discrete grid.

HigherOrderKernel dataclass

HigherOrderKernel(
    log_steps: tuple[int, int],
    log_degree: tuple[int, int],
    backend: str = "scan",
    dyadic_order: DyadicOrder = 0,
    increment_input: bool = False,
    num_devices: int = 1,
)

Bases: BaseKernel

Higher-order kernel based on log-linear approximations of tensor-valued paths.

This class evaluates the higher-order kernel determined by the chosen log-step and log-degree parameters and provides empirical kernel statistics such as batchwise kernel values, Gram matrices, MMD, and scoring rules.

Input convention

Inputs are level-1 tensor paths of shape (*batch, length, dim). A missing leading sample axis is promoted to batch size 1.

The parameters log_steps and log_degree determine the log-linear approximation used in the kernel evaluation.

higher_order_kernel

higher_order_kernel(
    X: Array,
    Y: Array,
    *,
    log_steps: tuple[int, int],
    log_degree: tuple[int, int],
    evaluate: Literal["terminal", "grid"] = "terminal",
    return_fg: bool = False,
    pairwise: bool = False,
    backend: Literal["scan", "wavefront"] = "scan",
    dyadic_order: DyadicOrder = 0,
    increment_input: bool = False,
)

Higher-order signature kernel via piecewise log-linear approximation.

Input convention

X and Y are paths whose positive tensor levels are packed as

(X_1, ..., X_N),   (Y_1, ..., Y_M),

with the time / steps axis on -2 and flat tensor width on the last axis.

A plain array is interpreted as a level-1 path, i.e. as (X_1,).

If increment_input=False, the inputs are interpreted as paths and are first converted to interval increments by differencing along axis -2.

If increment_input=True, the inputs are interpreted directly as interval increments.

Higher-order approximation

For each input separately:

  • split the interval sequence into contiguous blocks of size log_steps_x / log_steps_y,
  • compute the block signatures truncated at degree log_degree_x / log_degree_y,
  • take their tensor logarithms,
  • interpret these blockwise log-signatures as the increments of a piecewise log-linear path.

These two piecewise log-linear paths are then passed to free_kernel.

Parameters:

Name Type Description Default
X Array

Path inputs in packed positive-level form, with steps on axis -2.

required
Y Array

Path inputs in packed positive-level form, with steps on axis -2.

required
log_steps tuple[int, int]

Tuple (log_steps_x, log_steps_y) of block sizes used to form the piecewise log-linear approximations of X and Y. Each block size must divide the corresponding number of input intervals.

required
log_degree tuple[int, int]

Tuple (log_degree_x, log_degree_y) of truncation degrees used for the block signatures / block log-signatures of X and Y.

required
evaluate Literal['terminal', 'grid']

Passed through to free_kernel.

'terminal'
return_fg Literal['terminal', 'grid']

Passed through to free_kernel.

'terminal'
pairwise Literal['terminal', 'grid']

Passed through to free_kernel.

'terminal'
backend Literal['terminal', 'grid']

Passed through to free_kernel.

'terminal'
dyadic_order Literal['terminal', 'grid']

Passed through to free_kernel.

'terminal'
increment_input bool

If False, interpret X and Y as paths and first difference them. If True, interpret them directly as interval increments.

False

Returns:

Type Description
Whatever free_kernel returns for the piecewise log-linear approximations.

FSSKSigKernel dataclass

FSSKSigKernel(
    kernel: FSSK,
    dt_x: Array | float,
    dt_y: Array | float,
    backend: str = "scan",
    scheme: str = "heun",
    precompute_propagators: bool = True,
    dyadic_order: DyadicOrder = 0,
    increment_input: bool = False,
    num_devices: int = 1,
    static_kernel: StaticKernel = LinearKernel(scale=1.0),
)

Bases: BaseKernel

Configured finite-state-space Volterra signature kernel.

Wraps an FSSKKernel together with discretization parameters into a callable BaseKernel that can evaluate terminal values, full grids, Gram matrices, and MMD statistics via the inherited empirical helpers.

Parameters:

Name Type Description Default
kernel FSSK

Algebraic specification of the kernel (decay matrix Λ, projection tensors A, mixing weights b).

required
dt_x float or Array

Time-step size(s) for the X and Y paths respectively. A scalar means uniform spacing; a 1-D array provides per-interval widths.

required
dt_y float or Array

Time-step size(s) for the X and Y paths respectively. A scalar means uniform spacing; a 1-D array provides per-interval widths.

required
backend ('scan', 'wavefront')

Traversal strategy for the 2-D PDE grid.

"scan"
scheme ('etd1', 'heun')

Numerical cell-update scheme. "etd1" is first-order exponential time differencing; "heun" adds a predictor–corrector step for second-order convergence.

"etd1"
precompute_propagators bool

If True, matrix exponentials and φ-functions are precomputed once per time-step size and reused across all cells. Faster when dt is uniform but uses more memory.

False
dyadic_order int

Dyadic refinement level. Each coarse interval is split into 2^k sub-intervals; gamma is stored on the coarse grid and indexed lazily.

0
increment_input bool

If True, X and Y are already provided as increments (batch, intervals, dim) rather than as path values (batch, nodes, dim).

False
static_kernel StaticKernel

Static kernel used to build the coarse-grid gamma via the discrete mixed-derivative formula. The default LinearKernel(scale=1.0) (i.e. k(x,y)=⟨x,y⟩) is mathematically equivalent to a direct increment inner-product projection.

LinearKernel(scale=1.0)

fssk_sigkernel

fssk_sigkernel(
    X,
    Y,
    *,
    kernel: FSSK,
    dt_x: Array | float,
    dt_y: Array | float,
    evaluate: str = "terminal",
    return_fg: bool = False,
    pairwise: bool = False,
    backend: str = "scan",
    scheme: str = "heun",
    precompute_propagators: bool = False,
    dyadic_order: DyadicOrder = 0,
    increment_in: bool = False,
    static_kernel: StaticKernel = LinearKernel(scale=1.0),
)

Evaluate the beta PDE approximation of the FSSK signature kernel.

Parameters:

Name Type Description Default
X array - like

Path data of shape (batch, length, dim) or (length, dim). When increment_in=True the second axis indexes intervals (length equals the number of increments); otherwise it indexes nodes (length equals number of time-points ≥ 2).

required
Y array - like

Path data of shape (batch, length, dim) or (length, dim). When increment_in=True the second axis indexes intervals (length equals the number of increments); otherwise it indexes nodes (length equals number of time-points ≥ 2).

required
kernel FSSK

Algebraic kernel specification.

required
dt_x float or Array

Time-step size(s). Scalar for uniform grids, 1-D array for non-uniform.

required
dt_y float or Array

Time-step size(s). Scalar for uniform grids, 1-D array for non-uniform.

required
evaluate ('terminal', 'grid')

"terminal" returns only the value at the final grid corner; "grid" returns the full 2-D solution arrays.

"terminal"
return_fg bool

If True, also return the auxiliary matrices K, A, B alongside η.

False
pairwise bool

If False, evaluate batchwise k(Xᵢ, Yᵢ). If True, evaluate the full pairwise block k(Xᵢ, Yⱼ).

False
backend ('scan', 'wavefront')

Traversal strategy.

"scan"
scheme ('etd1', 'heun')

Cell-update scheme.

"etd1"
precompute_propagators bool

Precompute and reuse matrix exponentials / φ-functions.

False
dyadic_order int

Number of dyadic refinement levels.

0
increment_in bool

If True, X and Y are path increments, not path values.

False
static_kernel StaticKernel

Static kernel used to build the coarse-grid gamma via the discrete mixed-derivative formula

\[ G_{n,p}^{i,j} = k(A_q X_{i+1}, A_p Y_{j+1}) - k(A_q X_i, A_p Y_{j+1}) - k(A_q X_{i+1}, A_p Y_j) + k(A_q X_i, A_p Y_j) \]

followed by contraction \(\gamma[R,S] = \sum_{n,p} b_{n,R}\, G_{n,p}\, b_{p,S}\). The default LinearKernel(scale=1.0) is equivalent to a direct increment inner-product projection.

LinearKernel(scale=1.0)

Returns:

Type Description
Array or tuple
  • evaluate="terminal", return_fg=False — scalar η values, shape (batch,) or (bx, by).
  • evaluate="terminal", return_fg=True — tuple (η, K, A, B) at the terminal cell.
  • evaluate="grid", return_fg=False — η grid of shape (…, s_nodes, t_nodes).
  • evaluate="grid", return_fg=True — tuple (η, K, A, B) grids.

tensordev.kernel.StaticKernel

Bases: ABC

Abstract base class for static (pointwise) kernels k: R^d × R^d → R.

A StaticKernel represents a kernel function that operates on individual points (or sequences of points), supporting both batchwise and pairwise (Gram matrix) evaluation.

Shape convention

The last two axes of every input are (length, dim). All preceding axes form an arbitrary batch shape (possibly empty). Outputs follow the same convention on the batch prefix:

batch_kernel X: batch + (length_X, dim), Y: batch + (length_Y, dim) → batch + (length_X, length_Y)

Gram_matrix X: batch_X + (length_X, dim), Y: batch_Y + (length_Y, dim) → batch_X + batch_Y + (length_X, length_Y)

batch_kernel abstractmethod

batch_kernel(X: Array, Y: Array) -> Array

Evaluate batchwise kernel values k(X^i_s, Y^i_t).

Parameters:

Name Type Description Default
X batch + (length_X, dim)
required
Y batch + (length_Y, dim)
required

Returns:

Type Description
batch + (length_X, length_Y)

Gram_matrix abstractmethod

Gram_matrix(X: Array, Y: Array) -> Array

Evaluate the full pairwise Gram block k(X^i_s, Y^j_t).

Parameters:

Name Type Description Default
X batch_X + (length_X, dim)
required
Y batch_Y + (length_Y, dim)
required

Returns:

Type Description
batch_X + batch_Y + (length_X, length_Y)

LinearKernel dataclass

LinearKernel(scale: float = 1.0)

Bases: StaticKernel

Linear kernel k(x, y) = <scale·x, scale·y>.

Parameters:

Name Type Description Default
scale float

Multiplicative scaling applied to both inputs before computing the inner product.

1.0

batch_kernel

batch_kernel(X: Array, Y: Array) -> Array

X: batch + (length_X, dim) → batch + (length_X, length_Y)

Gram_matrix

Gram_matrix(X: Array, Y: Array) -> Array

X: batch_X + (length_X, dim), Y: batch_Y + (length_Y, dim) → batch_X + batch_Y + (length_X, length_Y)

RBFKernel dataclass

RBFKernel(sigma: float = 1.0)

Bases: StaticKernel

RBF kernel k(x, y) = exp(-‖x − y‖² / sigma).

Parameters:

Name Type Description Default
sigma float

Bandwidth parameter of the RBF kernel.

1.0

batch_kernel

batch_kernel(X: Array, Y: Array) -> Array

X: batch + (length_X, dim) → batch + (length_X, length_Y)

Gram_matrix

Gram_matrix(X: Array, Y: Array) -> Array

X: batch_X + (length_X, dim), Y: batch_Y + (length_Y, dim) → batch_X + batch_Y + (length_X, length_Y)

tensordev.kernel.RBF_CEXP_Kernel dataclass

RBF_CEXP_Kernel(
    sigma1: float = 1.0,
    sigma2: float = 1.0,
    n_freqs: int = 20,
    channels: int = 1,
)

Bases: StaticKernel

RBF kernel on node values that are functions, after a cos-exp transform.

A node value \(x\) is a function with channels components, sampled at \(s_i = i/(L-1)\), \(i = 0, \dots, L-1\), and stored grid-major in the last axis (x.reshape(L, channels)). With \(n\) = n_freqs,

\[ T(u) = e^{-u^2/\sigma_1} \sum_{l=0}^{n-1} \cos(2\pi l u), \qquad (Tx)(s_j) = \frac{1}{L} \sum_{i} x(s_i)\, T(s_i - s_j), \]

and \(k(x, y) = \exp(-\|Tx - Ty\|^2 / \sigma_2)\). A path of shape batch + (length_t, L, channels) is passed as X.reshape(X.shape[:-2] + (-1,)).

Parameters:

Name Type Description Default
sigma1 float

Bandwidth of the cos-exp integral operator.

1.0
sigma2 float

Bandwidth of the outer RBF kernel.

1.0
n_freqs int

Number of frequencies used in the cos-exp kernel.

20
channels int

Number of channels of the function values; the node dimension must be a multiple of it.

1

batch_kernel

batch_kernel(X: Array, Y: Array) -> Array

X: batch + (length_X, dim) → batch + (length_X, length_Y)

Gram_matrix

Gram_matrix(X: Array, Y: Array) -> Array

X: batch_X + (length_X, dim), Y: batch_Y + (length_Y, dim) → batch_X + batch_Y + (length_X, length_Y)

tensordev.kernel.RBF_SQR_Kernel dataclass

RBF_SQR_Kernel(sigma1: float = 1.0, sigma2: float = 1.0)

Bases: StaticKernel

Product of an RBF kernel on the node values and one on their squares.

k(x, y) = exp(-|x - y|^2 / sigma1) * exp(-|x**2 - y**2|^2 / sigma2), with the squares taken elementwise. For function-valued paths, flatten the samples of each value into the last axis, as for RBF_CEXP_Kernel.

Parameters:

Name Type Description Default
sigma1 float

Bandwidth for the RBF kernel applied to the values.

1.0
sigma2 float

Bandwidth for the RBF kernel applied to the squared values.

1.0

batch_kernel

batch_kernel(X: Array, Y: Array) -> Array

X: batch + (length_X, dim) → batch + (length_X, length_Y)

Gram_matrix

Gram_matrix(X: Array, Y: Array) -> Array

X: batch_X + (length_X, dim), Y: batch_Y + (length_Y, dim) → batch_X + batch_Y + (length_X, length_Y)

Utilities

Path generators and path preprocessing helpers, imported from tensordev.util. bucket_pad_ragged_paths and velocity_to_increments are also exported by tensordev.kernel. See Example paths and Batching.

tensordev.util.path_to_increments

path_to_increments(X)

Convert a DenseElemFirstOn path into interval increments.

tensordev.util.integrated_ou_first_on_path

integrated_ou_first_on_path(
    key,
    *,
    batch,
    steps,
    dim,
    trunc,
    horizon=1.0,
    mean_reversion=5.0,
    volatility=5.0,
    level_lambda=1.0,
    factorial=False,
)

Dense first-on path whose every flattened coordinate is an independent integrated Ornstein-Uhlenbeck process.

The level-k component is scaled by

level_lambda**k

and, if factorial=True, additionally by 1 / k!.

tensordev.util.random_trigonometric_polynomial_paths

random_trigonometric_polynomial_paths(
    key,
    *,
    batch,
    steps,
    dim,
    n_modes=5,
    scale=0.25,
    decay=1.5,
    horizon=1.0,
)

Batched random trigonometric-polynomial paths.

tensordev.util.unit_speed_paths

unit_speed_paths(
    *,
    dt: float,
    dt_fine: float = 0.001,
    n_paths: int,
    dim: int = 2,
    seed: int = 0,
    dtype=np.float64,
)

Generate deterministic smooth unit-speed paths on [0, 1].

Returns shape: (n_paths, int(1 / dt) + 1, dim)

tensordev.util.perturb_path_batch

perturb_path_batch(base_path, batch_size, grid)

Build a batch of paths by adding small deterministic trigonometric perturbations to a single base path.

The perturbation amplitudes grow linearly with batch index so that paths are spread out progressively further from the base.

Parameters:

Name Type Description Default
base_path Array, shape (length, d)

The reference path around which to perturb.

required
batch_size int

Number of paths in the returned batch.

required
grid Array, shape (length,)

Time grid shared by base_path.

required

Returns:

Type Description
Array, shape (batch, length, d)

Batch of perturbed paths; result[0] is the smallest perturbation.

tensordev.util.deterministic_trigonometric_path_pair

deterministic_trigonometric_path_pair(grid, dim)

Two complementary deterministic trigonometric paths on a shared time grid, intended as fixed base signals for kernel experiments and benchmarks.

The two paths x and w use different hard-coded frequency/phase parameters so they are structurally distinct but comparably smooth.

Parameters:

Name Type Description Default
grid Array, shape (length,)

Uniform time grid, e.g. jnp.linspace(0, 1, 101).

required
dim int

Path dimension.

required

Returns:

Name Type Description
x Array, shape (length, dim)
w Array, shape (length, dim)

tensordev.util.bucket_pad_ragged_paths

bucket_pad_ragged_paths(
    x: Sequence[Array],
    *,
    chunk_size: int | None = None,
    sort: bool = True,
    return_indices: bool = False,
    target_length: int | None = None,
)

Bucket and pad a ragged batch of Euclidean path values.

Each outer element of x is interpreted as either - one path of shape (length, dim), or - a dense mini-batch of paths with shape batch + (length, dim).

All leading sample axes are flattened, then the logical samples are optionally sorted by path length, grouped into chunks of size at most chunk_size, and padded inside each chunk to the local maximum path length by repeating the terminal path value.

Parameters:

Name Type Description Default
x Sequence[Array]

Ragged batch of Euclidean path values.

required
chunk_size int | None

Maximum number of logical samples per chunk. If None or non-positive, all samples are placed into a single chunk.

None
sort bool

Whether to sort logical samples by path length before chunking.

True
return_indices bool

If True, also return one index tuple per chunk that records the original logical sample order. This can be used downstream to reassemble outputs in the original order.

False
target_length int

If given, pad every chunk to this fixed node length instead of the local maximum. Useful when downstream code requires shape-stable batches (e.g. to avoid JIT recompilation). Raises if any path is longer.

None

Returns:

Type Description
list[Array]

Dense padded chunks, each of shape (n_chunk, max_len, dim) ((n_chunk, target_length, dim) when target_length is given).

or
tuple[list[Array], list[tuple[int, ...]]]

If return_indices=True, also return the original logical indices for each chunk.

tensordev.util.velocity_to_increments

velocity_to_increments(
    velocity: Callable[[Array], tuple[Array, ...]],
    grid: Array,
    *,
    quadrature: Literal[
        "left", "midpoint", "trapezoid"
    ] = "trapezoid",
    dyadic_order: int = 0,
) -> tuple[Array, ...]

Convert a characteristic velocity to tensor-valued interval increments.

For each interval [t_{i-1}, t_i] of the (optionally refined) grid, the velocity is numerically integrated by the chosen quadrature rule to produce one increment per tensor level.

Parameters:

Name Type Description Default
velocity Callable[[Array], tuple[Array, ...]]

Callable mapping a 1-D array of time-points to a tuple of tensor level arrays.

required
grid Array

1-D node grid with at least two nodes.

required
quadrature ('left', 'midpoint', 'trapezoid')

Quadrature rule.

"left"
dyadic_order int

If positive, the node grid is dyadically refined (midpoints inserted dyadic_order times) before integration.

0

Returns:

Type Description
tuple of Array

One array per tensor level, each with shape (S_fine, width).