Table Integration#10
Open
HunterBelanger wants to merge 31 commits intonjoy:masterfrom
Open
Conversation
…ic with decorators
Member
|
@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. |
jlconlin
reviewed
Mar 1, 2021
| 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;}; |
Member
There was a problem hiding this comment.
You create F1 and F2 here, but do you use them anywhere?
Author
There was a problem hiding this comment.
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds the
integratemethod 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
leftorright), 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 theVectortype, 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
leftandrightdecorators 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
leftorrightdecorators 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.