#include <ExprOptimizer.h>
Static Public Member Functions | |
static StkConst * | reuseConst (tvector< StkConst * > &nums, const string &name, GReal_t value) |
Tries to reuse an already existing constant. | |
static void | performAll (tvector< StkOp * > &program, tvector< StkConst * > &nums, GReal_t *stack, StkOpRepository &rep) |
Performs all optimizations. | |
static void | inlineExprs (tvector< StkOp * > &program) |
Make everything inline if possible. | |
static void | precalc (tvector< StkOp * > &program, tvector< StkConst * > &nums, GReal_t *stack) |
Precalculates constant subexpressions. | |
static void | optimizePow (tvector< StkOp * > &program, StkOpRepository &rep) |
Replaces x^(+-y) by one-argument functions. | |
static void | optimizeMult (tvector< StkOp * > &program, StkOpRepository &rep) |
Replaces (. | |
static void | optimizeDiv (tvector< StkOp * > &program, StkOpRepository &rep) |
Replaces const/(. | |
static void | optimizePlus (tvector< StkOp * > &program, StkOpRepository &rep) |
Replaces const+(. | |
static void | optimizeMinus (tvector< StkOp * > &program, StkOpRepository &rep) |
Replaces const-(. |
static StkConst* gridripper::math::expr::ExprOptimizer::reuseConst | ( | tvector< StkConst * > & | nums, | |
const string & | name, | |||
GReal_t | value | |||
) | [static] |
Tries to reuse an already existing constant.
It creates a new object only if the constant is not found in the repository.
nums | a repository of existing constants | |
name | the constant name | |
value | the constant value |
static void gridripper::math::expr::ExprOptimizer::inlineExprs | ( | tvector< StkOp * > & | program | ) | [static] |
Make everything inline if possible.
static void gridripper::math::expr::ExprOptimizer::precalc | ( | tvector< StkOp * > & | program, | |
tvector< StkConst * > & | nums, | |||
GReal_t * | stack | |||
) | [static] |
Precalculates constant subexpressions.
static void gridripper::math::expr::ExprOptimizer::optimizePow | ( | tvector< StkOp * > & | program, | |
StkOpRepository & | rep | |||
) | [static] |
Replaces x^(+-y) by one-argument functions.
Optimized y values: 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 6, 7, 8.
static void gridripper::math::expr::ExprOptimizer::optimizeMult | ( | tvector< StkOp * > & | program, | |
StkOpRepository & | rep | |||
) | [static] |
Replaces (.
..)*(...), const*(...), and (...)*const by one-argument functions.
static void gridripper::math::expr::ExprOptimizer::optimizeDiv | ( | tvector< StkOp * > & | program, | |
StkOpRepository & | rep | |||
) | [static] |
Replaces const/(.
..) and (...)/const by one-argument functions, 1/(...) by (...)^-1.
static void gridripper::math::expr::ExprOptimizer::optimizePlus | ( | tvector< StkOp * > & | program, | |
StkOpRepository & | rep | |||
) | [static] |
Replaces const+(.
..) and (...)+const by one-argument functions.
static void gridripper::math::expr::ExprOptimizer::optimizeMinus | ( | tvector< StkOp * > & | program, | |
StkOpRepository & | rep | |||
) | [static] |
Replaces const-(.
..) and (...)-const by one-argument functions.