Skip to content

mccube._term

Defines custom terms for performing MCC in diffrax.

See diffrax.AbstractTerm for further information on the terms API.

MCCTerm ¤

MCCTerm(ode: ODETerm, cde: WeaklyDiagonalControlTerm)

Bases: AbstractTerm

Provides a convenience interface for CDEs whose control is a Cubature Path.

Performs shape coercion to ensure the ode and cde terms can be broadcast together. One can achive the same result with a diffrax.MultiTerm providing suitable modifcations are made to the input and vector field shapes.

Example
cubature = mccube.Hadamard(mccube.GaussianRegion(10))
ode = ODETerm(lambda t, y, args: -y)
cde = WeaklyDiagonalControlTerm(
    lambda t, y, args: 2.0,
    mccube.LocalLinearCubaturePath(cubature)
)
term = MCCTerm(ode, cde)
sol = diffrax.diffeqsolve(term, ...)

Parameters:

Source code in mccube/_term.py
def __init__(self, ode: ODETerm, cde: WeaklyDiagonalControlTerm):
    """
    Args:
        ode: is a [`diffrax.ODETerm`][].
        cde: is a [`diffrax.WeaklyDiagonalControlTerm`][], driven by a
            [`mccube.AbstractCubaturePath`][].
    """
    self.ode = ode
    self.cde = cde