braintools.tree.dot

Contents

braintools.tree.dot#

braintools.tree.dot(a, b, is_leaf=<function is_quantity>)[source]#

Inner product over all leaves of two PyTrees.

For each pair of corresponding leaves, compute the elementwise product, reduce with a full sum over all axes, and then sum across leaves.

Parameters:
  • a (PyTree) – First operand.

  • b (PyTree) – Second operand with the same PyTree structure as a.

  • is_leaf (Callable[[Any], bool] | None) – Predicate to treat a node as a leaf during traversal. Defaults to u.math.is_quantity.

Returns:

Scalar representing the inner product across the entire PyTree.

Return type:

Array

See also

sum

Sum of all elements in a PyTree.

squared_norm

Sum of squares of all elements (i.e., dot(x, x)).

Notes

  • Leaf arrays must be broadcast-compatible for multiplication.

  • When leaves carry units (brainunit quantities), units propagate through the multiplications and sums according to quantity rules.