Add Cubic Spline Interpolation classes #183
Open
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.
Cubic Spline is an interpolator that is quick and useful for 1D data. The Lagrange class could be used for interpolating 1D data, but Cubic Spline allows easily for non-uniform spacing 1D grid. This then can be used to interpolate data that exist in params.txt via the FileInterpolator1D. For instance, I have used this to solve 1D constraints in spherical symmetry elsewhere and then importing the data to the 3D grid.
It requires a matrix inversion, and that is done by a LU solver with the TriDiagonalMatrix class.
Two tests added. CubicSplineInterpolatorTest, to test the cubic spline interpolation, and FileInterpolator1DTest, to test the importing of file data to interpolate. The later can be also useful as an example of how to use these classes.
If "N", "x" and "y" are set in a separate file 'fileWithData.txt', one easy way to import them to the 'params.txt' without changing the file is running with the command:
'Main.ex params.txt FILE=fileWithData.txt'
I had this around my code and @mirenradia said it could be a nice addition, so I'll mark him as reviewer :P