If the same sub-expression appears in multiple places within one numexpr expression, will it be recalculated multiple times (or is numexpr clever enough to detect this and reuse the result)?
Is there any way to declare temporary variables within a numexpr expression? This would have two aims:
- encourage numexpr to consider caching and re-using, rather than re-calculating, the result;
- simplify the expression (making the source code easier to read and maintain).
I am trying to calculate f(g(x)) where f and g are themselves both complicated expressions (e.g. for pixel-based thematic classification, f is a nested decision tree involving multiple thresholds, g is a set of normalised difference ratios, and x is a multi-band raster image).