import { adjointFormula, formatNumber, tangentFormula } from "./formula";
import { expressionOf } from "./layout";
import MathText from "./MathText";
import type { Graph, Mode, State } from "./types";
// z-10 keeps it above the rows' subscripts, which sit in their own layer
const headerClass = "sticky top-0 z-10 whitespace-nowrap bg-white pb-2 text-xs font-semibold uppercase tracking-widest text-ink-muted";
// Rounded for reading; a cell's title holds the full value
function NumberCell({ value, className }: { value: number | undefined; className: string }) {
return (
{value === undefined ? "—" : formatNumber(value)}
|
);
}
export default function EvaluationTable({
graph,
state,
mode,
seed,
}: {
graph: Graph;
state: State | undefined;
mode: Mode;
seed: string;
}) {
const forward = mode === "forward";
const symbolName = forward ? "Tangent" : "Adjoint";
return (
|
Definition |
Value |
|
Rule |
Value |
{graph.nodes.map((node) => {
const [derivative, rule] = (forward ? tangentFormula(graph, node, seed) : adjointFormula(graph, node)).split(" = ");
return (
row?.scrollIntoView({ block: "nearest" }) : undefined}
className={`scroll-mt-8 border-t border-grid ${node.id === state?.step?.node ? "bg-marker-soft" : ""}`}
>
|
|
|
|
);
})}
);
}