Cadabra
a field-theory motivated approach to computer algebra

WeightInherit

Make object inherit weights from child nodes
Indicates that the object inherits all weights of its child nodes. The label indicates which weights are inherited; use all to inherit all weights. The type of inheritance determines whether weights of the child nodes should be added or multiplied. Additive weight inheritance is used to assign a weight to sum-like objects. For example, if we declare
f{#}::WeightInherit(label=all, type=Additive); A::Weight(label=field, value=3);
\(\displaystyle{}\text{Attached property WeightInherit to }f\left(\#\right).\)
\(\displaystyle{}\text{Attached property Weight to }A.\)
then the expression f{A}{A} has weight 3. This is what would happen if 'f' would be a sum: the weight of the sum is the same as the weight of the terms (and is only defined if the weight of the all terms is equal). Multiplicative weight inheritance is used to assign a weight to product-like objects. For example, if we declare
g{#}::WeightInherit(label=all, type=Multiplicative); B::Weight(label=field, value=3);
\(\displaystyle{}\text{Attached property WeightInherit to }g\left(\#\right).\)
\(\displaystyle{}\text{Attached property Weight to }B.\)
then the expression g{B}{B} has weight 6. This is what would happen if 'g' would be a product: the weight of the product is the same as the sum of the weights of the factors. Terms can be selected based on their weight by using the keep_weight or drop_weight algorithms.
Copyright © 2001-2024 Kasper Peeters
Questions? info@cadabra.science