Skip to content

general_bch_program

from tensorsig.offset_coded_signatures.rolling_logsignature import general_bch_program

Compile BCH for two Lie values in the supplied quotient coordinates.

right_degree_one restricts the right operand to generator coordinates. compiled compiles the polynomial and its owned derivative kernels.

Source code in src/tensorsig/offset_coded_signatures/rolling_logsignature/_joint.py
def general_bch_program(plan, compiled=False, right_degree_one=False):
    """Compile BCH for two Lie values in the supplied quotient coordinates.

    ``right_degree_one`` restricts the right operand to generator coordinates.
    ``compiled`` compiles the polynomial and its owned derivative kernels.
    """
    support = range(plan.dimension)
    right = (
        torch.where(plan.basis_depths == 1)[0].cpu().tolist()
        if right_degree_one
        else support
    )
    program = PolynomialProgram(plan, [support, right])
    result = program.bch(0, 1)
    program.finish(result, range(plan.dimension))
    return program.compile() if compiled else program