Before this patch the return type was implicitly defined by the
ExpressionType. This patch separates this connection and allows
each Expression to have one of the predefined types (scalar,
boolean, void).
This patch is required to add support for the functions isfinite,
isinf, isnan, and isnormal. These are function taking a double and
returning a bool.
This also moves some complexity of the code generator to the
Expression, because the generator can direclty get the c++ type.
Change-Id: I8b32bab1bfab2f668875e506d6f3b789a5d1f3fd
- Move codegen tests to a sub directory
- Add tests for all functions of Expression, ExpressionRef, and ExpressionGraph
- Respect dependencies during tests: The ExpressionGraph test doesn't
use ExpressionRef anymore.
The new tests revealed a few bugs so the following changes were made:
- Expression::MakeNop now resets the current expression with the default
constructed NOP expression
- ExpressionGraph::Insert now updates the lhs_id the same way as
InsertBack()
Change-Id: I6a18925c1e4d972c29ec1219f2073b4eaf2df737
Objects of 'Expression' can now be freely created and copied around.
This creation does NOT add them to the active ExpressionGraph any
more. The insertion into the graph is now done by ExpressionRef,
which explicitly call graph.add(...) in each operation.
This change brings the following advantages:
1. 'Expression' is now stand-alone and side-effect free
- Remove the dependency Expression->ExpressionGraph
- Expressions can be created by the optimizer
2. Explicit graph insertion
- Previously CreateCompileTimeConstant not only created an
expression, but also inserted it into the active graph. Now
this insertion is done explicitly by ExpressionRef
3. It is now easier to insert new types and members
- Should be straight forward now, because we got rid of the
3-way dependency
- This is a preparation patch for the new return-type member in
https://ceres-solver-review.googlesource.com/c/ceres-solver/+/16224
Change-Id: Icef2fe529a4db001a10d1fb6816c9dc681b14ff2
User defined cost functors have to include this new header
instead of internal/expression_ref.h. This hides some
complexity of ExpressionRef and reduces compile time outside
of code generation mode.
This patch also removes the dependency ExpressionRef->Jet.
Change-Id: Ie3f93648775e14881dc5cfab213bbc983c6cfeee