Skip to content
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

Multivariate interpolation #13

Open
ajg12 opened this issue Apr 12, 2021 · 1 comment
Open

Multivariate interpolation #13

ajg12 opened this issue Apr 12, 2021 · 1 comment

Comments

@ajg12
Copy link

ajg12 commented Apr 12, 2021

Is it possible to interpolate several different variables at the same time?

#include <mba.hpp>

int main() {
// Coordinates of data points.
std::vector<mba::point<2>> coo = {
{0.0, 0.0},
{0.0, 1.0},
{1.0, 0.0},
{1.0, 1.0},
{0.4, 0.4},
{0.6, 0.6}
};

**// Data values.
std::vector<double> val = {
    0.2, 0.0, 0.0, -0.2, -1.0, 1.0
};**

// Bounding box containing the data points.
mba::point<2> lo = {-0.1, -0.1};
mba::point<2> hi = { 1.1,  1.1};

// Initial grid size.
mba::index<2> grid = {3, 3};

// Algorithm setup.
mba::MBA<2> interp(lo, hi, grid, coo, val);

// Get interpolated value at arbitrary location.
double w = interp(mba::point<2>{0.3, 0.7});

}

I mean, if for example in the example of the introduction the variable "val" could be an array with different variables to interpolate instead of a vector that only has space for one variable (regardless of how long it is).

I know that the algorithm can be initialized with the different variables, but if it could be initialized with all the variables to interpolate at the same time, it would be more optimal, I think, can this be done?

@ddemidov
Copy link
Owner

I am sorry, I don't think I understand the question. Do you want to interpolate vector fields as opposed to scalar (double) fields? I think it should be possible to replace the value type (double) with a template parameter. So, with some minor modifications to the mba code, you could in principle use something like Eigen::Vector3d, or any type that provides overloaded arithmetic operations, instead of double. This is not something I am willing to do currently, but I would gladly accept a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants