-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table Integration #10
base: master
Are you sure you want to change the base?
Conversation
…ic with decorators
@HunterBelanger I do plan on taking a look at this. I just wanted to respond and let you know that we haven't forgotten about you. |
@@ -52,7 +52,9 @@ SCENARIO("The LinearLogarithmic interpolant computes is compatible with units", | |||
std::vector< double > xValues{ 1E-2, 1, 10 }; | |||
auto f1 = []( auto x ){ return 13.2 * std::log(3.2 * x.value) * barn; }; | |||
auto f2 = []( auto x ){ return -5.6 * std::log(2.4 * x.value) * barn; }; | |||
|
|||
auto F1 = []( auto x ){return 13.2*x.value*(std::log(3.2*x.value)-1.) * barn * electronVolts;}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You create F1
and F2
here, but do you use them anywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, those should be removed from there. Initially, I had put the integration tests in the interpolate.test.cpp
file, but later moved them to the integration.test.cpp
file to keep things somewhat separated. I must have forgotten to remove these two lines. I will add a commit to remove them.
This pull request adds the
integrate
method to tables, allowing them to be integrated according to their interpolation laws. This works with all three of the possible tables (Type
,Variant
, andVector
). The method takes a lower limit, and upper limit, and optionally a search algorithm (similar to evaluation). In addition to adding verification of the integration algorithm to the existing unit tests, I also added integration to a few of the examples provided in the source.Integration Bounds
When no table decorations are used (such as
left
orright
), the integration bounds will automatically be shorten to the limits of the table (without message or error). Currently, when evaluating a table outside of the x-grid bounds, no error is given, so the behavior is undefined. I chose to reduce the limits to the table bounds to facilitate use with theVector
type, as well as other decorators. I feel this is reasonable as a user should be ensuring the limits are valid for the table when not using decorators, and the implementation of the evaluation is already undefined in such a case.Domain Decorators
When domain decorators are used, an error is thrown if one of the integration bounds is outside of the given domain. If
left
andright
decorators have not been used however, and the domain is larger than the x-grid, the integration bounds will still be truncated to fit the x-grid, as the function is undefined between the end of the domain, and the last valid point in the x-grid.Left and Right Decorators
If
left
orright
decorators are used on the table, histogram integration is used to calculate the portion of the integral which lies outside of the x-grid values. The table's interpolation law is then used for the x-grid values.Transformations
I do not believe there is any meaning for the integration of a table which has a transform applied to it. As such, attempting to integrate a table with a transformation is not supported, and results in an error being thrown.
Floating Point Error for LogarithmicLinear Integration
I was not able to come up with a formulation which could calculate the integral for LogarithmicLinear interpolations with an error of less than 1E-15 (the bound used in the other unit tests). In order to have a passing unit test, I bumped up the acceptable error for the integration tests to be 1E-13. With this condition, the tests pass. If this is too high of an acceptable error bound, a new formulation of the algorithm will need to be implemented for that integration law.