-
Notifications
You must be signed in to change notification settings - Fork 14
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
Using multidimensional interpolation #2
Comments
You are correct, there is no good tensor example, so I will work on it and get back to you as soon as I can. In the mean time, you may find src/base/tensor_ts.cpp helpful. However, I should warn you, O2scl includes only a very basic scheme for grid-based interpolation in higher dimensions in the tensor_grid class, but I don't recommend it's use for anything other than linear interpolation. (The classes interpm_neigh and interpm_idw work best on data which is not specified on a grid.) What rank tensor do you have? Oh and I forgot: extrapolation is essentially always supported in O2scl for all of the interpolation methods. |
Thank you for your reply! I have 6 D interpolation with around 1000000 sample points on a regular grid. There is a more sophisticated Bspline library called "splinter", BUT it takes enormous time even for linear BSpline. That's why I need a good FAST implementation of linear interpolation or some inverse square interpolation. Hope that your library will be helpful, but an example would be very helpful. |
Thank you for referring to tensor_ts.cpp! I will try to write my example myself and will hopefully share it here. |
Ok. Check out https://github.com/awsteiner/o2scl/blob/master/examples/ex_tensor.cpp . I try to make my classes agnostic with regard to the base vector type, so tensor_grid::interp_linear() always works. However, tensor_grid::interpolate() only works if the base vector types are from ublas. |
That is a helpful example! Are there any save/load methods in tensor_grid class? I have read from the manual that you use HDF library for that. Is it hard to make a simple example that would save/load the tensor_grid with http://web.utk.edu/~asteine1/o2scl/html/classo2scl__hdf_1_1hdf__file.html functions? |
The file ex_tensor.cpp now demonstrates this as well (the I/O functions are at the bottom of hdf_io.h). Note however that HDF5 I/O only works if the tensor is built upon std::vector types, since ublas vectors are not (so far as I know) guaranteed to be contiguous in memory. |
Thank you! This is really helpful!
|
Dear Andrew, a useful improvement for the future could be the functions to integrate and differentiate on the (possibly non-equally spaced) tensor grid. This is not easy in general, but, at least the linear interpolation can be easily integrated. |
Dear Andrew, On 09/12/15 15:20, Andrew W. Steiner wrote:
|
I'm not sure....let me try this later this week. |
Dear Andrew, I am facing the problem of calculating the proton fraction of a neutron star where Gravitation is irrelevant (zero pressure). Can your work be applied to that scenario? By the way, I also had trouble in the make all for o2scl on ubuntu 18.04 Marco |
Marco,
Take care, |
Dear Andrew,
Could you extend the documentation by providing a simple example for multidimensional interpolation on a regular grid, please. In particular, how to enter and allocate space for tensor elements and how to save/load them. I suppose, this is done in the third-party libraries, but a basic example will be very helpful anyway.
Would the interpolation work a bit outside the domain (as extrapolation)? This could have been a useful feature.
Thank you!
Sergey
The text was updated successfully, but these errors were encountered: