Function sequant::prune_to_matches

Function Documentation

ExprPtr sequant::prune_to_matches(const Expr &expr, const ExpressionFilter &filter)

Recursively rebuilds expr, keeping only the parts relevant to filter: for a Sum, keeps (and further prunes) only those summands that (recursively) contain a match, dropping the rest; for a Product, keeps every factor (dropping one would change what the product computes), pruning each factor in turn; leaves are returned unchanged.