braintools.tree.mul#
- braintools.tree.mul(tree, x, is_leaf=<function is_quantity>)[source]#
Elementwise multiplication of a PyTree with a value or another PyTree.
- Parameters:
tree (
Quantity]) – Left operand; PyTree whose leaves are multiplied.x (
Quantity]|Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Right operand. If a PyTree, its structure must match tree and corresponding leaves are multiplied elementwise. If a value (scalar/array_like), it is broadcast to each leaf of tree.is_leaf (
Callable[[Any],bool] |None) – Predicate to treat a node as a leaf during traversal. Defaults to u.math.is_quantity.
- Returns:
PyTree with elementwise products.
- Return type:
PyTree
See also
Notes
When x is a PyTree, both tree and x must have identical PyTree structures. Broadcasting applies per-leaf when x is array_like.