{
  "format": 1,
  "method": "uidd",
  "version": "0.1.0",
  "interface": "Column vectors, row-major real matrices, absolute tolerances. decompose(grad_v,sigma,bands,div_m,div_w) returns [reversible,irreversible,total], with M=sigma*sigma^T/2, W[i,i+1]=bands[i], W[i+1,i]=-bands[i], div row-wise. rev=div_m-M*grad_v, irr=div_w-W*grad_v, total=rev+irr. local_epr(irreversible,sigma) returns irreversible^T M^-1 irreversible. transition(start,end,dt,total,sigma) returns the normalized Gaussian negative log density at end with mean start+dt*total and covariance dt*sigma*sigma^T. diffusion_loss_gradient(pairs,weights) uses the scalar state q and weights [k,s]. V=k*q^2/2, sigma=s*(1+0.2*tanh(q)), W=0. Return [mean normalized transition loss,[d/dk,d/ds]] across [start,end,lag] triples. Differentiate the mobility divergence in the drift and both the drift and covariance in the loss. variable_drift(state) returns [reversible,irreversible,total] with no supplied derivatives. For state [q,p], use V=(1.2*q^2+0.7*p^2)/2+0.25*q*p, sigma=[[1+0.2*q,0],[0.3+0.1*p,0.8+0.15*q]], and upper skew band 0.4+0.2*q-0.3*p. Evaluate the state gradient and both matrix divergences. Export all five functions from port_adapter.py.",
  "cases": [
    {
      "name": "state-dependent reversible drift",
      "operation": "decompose",
      "tol": 1e-12,
      "inputs": {
        "grad_v": [
          2.0
        ],
        "sigma": [
          [
            3.1622776601683795
          ]
        ],
        "bands": [],
        "div_m": [
          4.0
        ],
        "div_w": [
          0.0
        ]
      },
      "expected": [
        [
          -6.000000000000002
        ],
        [
          0.0
        ],
        [
          -6.000000000000002
        ]
      ]
    },
    {
      "name": "two coupled skew bands with oriented row divergences",
      "operation": "decompose",
      "tol": 1e-12,
      "inputs": {
        "grad_v": [
          1.0,
          -0.5,
          0.2
        ],
        "sigma": [
          [
            1.0,
            0.3,
            0.0
          ],
          [
            -0.2,
            0.8,
            0.4
          ],
          [
            0.0,
            -0.1,
            1.3
          ]
        ],
        "bands": [
          0.6,
          -0.7
        ],
        "div_m": [
          0.1,
          0.4,
          -0.2
        ],
        "div_w": [
          0.2,
          -0.3,
          0.5
        ]
      },
      "expected": [
        [
          -0.43200000000000005,
          0.546,
          -0.24500000000000005
        ],
        [
          0.5,
          0.44,
          0.85
        ],
        [
          0.06799999999999995,
          0.986,
          0.605
        ]
      ]
    },
    {
      "name": "correlated mobility and positive rate",
      "operation": "local_epr",
      "tol": 1e-12,
      "inputs": {
        "irreversible": [
          0.6,
          -0.8
        ],
        "sigma": [
          [
            1.2,
            -0.1
          ],
          [
            0.4,
            0.7
          ]
        ]
      },
      "expected": 4.017561983471076
    },
    {
      "name": "normalized short-lag conditional likelihood",
      "operation": "transition",
      "tol": 1e-12,
      "inputs": {
        "start": [
          0.5,
          -0.3
        ],
        "end": [
          0.28,
          -0.15
        ],
        "dt": 0.12,
        "total": [
          -0.7,
          0.4
        ],
        "sigma": [
          [
            1.0,
            0.3
          ],
          [
            -0.2,
            0.9
          ]
        ]
      },
      "expected": -0.1920776411049821
    },
    {
      "name": "variable-diffusion loss and two weight derivatives",
      "operation": "diffusion_loss_gradient",
      "tol": 1e-10,
      "inputs": {
        "pairs": [
          [
            [
              0.55
            ],
            [
              0.39
            ],
            0.12
          ],
          [
            [
              -0.6
            ],
            [
              -0.28
            ],
            0.21
          ]
        ],
        "weights": [
          1.4,
          0.8
        ]
      },
      "expected": [
        -0.02779494262444014,
        [
          -0.05751417242170667,
          0.5062296738185836
        ]
      ]
    },
    {
      "name": "row divergence through two-dimensional variable fields",
      "operation": "variable_drift",
      "tol": 1e-09,
      "inputs": {
        "state": [
          0.65,
          -0.4
        ]
      },
      "expected": [
        [
          -0.13438525000645096,
          0.0034029921877280905
        ],
        [
          -0.22362499999803442,
          0.24199999999897912
        ],
        [
          -0.3580102500044854,
          0.2454029921867072
        ]
      ]
    }
  ]
}
