Class Sym

java.lang.Object
org.ddogleg.chainrule.sym.Sym

public class Sym extends Object

One node of a symbolic expression that SymGraphBuilder compiles onto a chain graph. An interior node wraps an operator with its inputs bound by index; a terminal names a value that arrives from outside the graph.

Terminal kinds and their contract:

Only what a param supplies, or what flows through operators, is ever differentiated: a terminal without a column mapping is structurally constant, no flag involved.

  • Field Details

    • kind

      public final Sym.Kind kind
    • name

      public final String name
      Label for build errors and the wiring dump, not used for lookup
    • size

      public final int size
      Number of values a terminal supplies. Interior nodes get their size from the operator
    • op

      @Nullable public final @Nullable CROperatorBackwardsJac<double[]> op
      The operator an interior node wraps, one instance per node
    • bound

      public final Map<Integer,Sym> bound
      Which expression feeds each input slot, by the operator's own input index
    • values

      public final double @Nullable [] values
      Values of a constant(double...) terminal
    • extension

      @Nullable public @Nullable SymExtension extension
      Set when the node needs hooks of its own, e.g. a composite choosing parameters per evaluation. The builder installs it and otherwise knows nothing about what it does
  • Method Details

    • of

      public static Sym of(CROperatorBackwardsJac<double[]> op)
      Interior node wrapping the operator. Bind its inputs with in(int, Sym); slots left unbound must be terminals the caller feeds, and the builder rejects anything else
    • input

      public static Sym input(String name, int size)
      Per-observation value, updated by the caller inside its loop
    • setting

      public static Sym setting(String name)
      Known per-dataset scalar, updated by the caller between datasets
    • param

      public static Sym param(String name, int size)

      A slice of the parameter array, the only terminal that is differentiated.

      Keep size to what one evaluation actually touches and re-bind the feed offset per item (per view, per frame): the backwards pass carries a dense matrix as wide as the node, so a param spanning a whole block turns a diagonal dependency into width-squared work

    • constant

      public static Sym constant(double... values)
    • in

      public Sym in(int index, Sym value)
      Binds input slot index of this node's operator, using the operator's own input indexes. Binding a slot twice is an error rather than a silent overwrite
    • in0

      public Sym in0(Sym value)
    • in1

      public Sym in1(Sym value)
    • in2

      public Sym in2(Sym value)
    • in3

      public Sym in3(Sym value)
    • in4

      public Sym in4(Sym value)
    • in5

      public Sym in5(Sym value)
    • in6

      public Sym in6(Sym value)
    • in7

      public Sym in7(Sym value)
    • in8

      public Sym in8(Sym value)