mba icon indicating copy to clipboard operation
mba copied to clipboard

Refinement level h

Open lizrmn opened this issue 3 years ago • 4 comments

Hi @ddemidov, I would love to know if there is a possibility to set the refinement parameter h in this code (regarding the python implementation)?
I get slightly different results comparing the MBA package in R (provided from SINTEF) and yours.

lizrmn avatar Jul 21 '21 11:07 lizrmn

There is the tol parameter that specifies the target relative approximation error (||mba(x_i) - z_i|| / ||z||):

https://github.com/ddemidov/mba/blob/420bc7f4d0717a1f66eee05f61122ff2dd28d65a/mba/mba.hpp#L721

The parameter is also exposed to the python wrapper:

https://github.com/ddemidov/mba/blob/420bc7f4d0717a1f66eee05f61122ff2dd28d65a/python/pymba.cpp#L30

so you can do something like

interp = mba2(..., tol=1e-12)

Re differences with the SINTEF version, I am not familiar with the implementation, so can not comment on the possible reason. If I had to guess, I would say there are probably some minor details, like initial grid size, and what is exactly meant by the grid size in each implementation (for example, number of cells vs number of points).

ddemidov avatar Jul 21 '21 13:07 ddemidov

Thank you for your fast reply. This is what I was looking for. But I won't help with the differences regarding the algorithm in R. But thanks for your input on that as well.

lizrmn avatar Jul 21 '21 14:07 lizrmn

I have just tested the rygg1.dat example from SINTEF MBA, see results in the following notebook: https://nbviewer.jupyter.org/gist/ddemidov/6fcd134909d674669f6dffc2066bf739

The test point (5,5) has a minor discrepancy, but the data points are interpolated within the required tolerance (1e-8 by default).

ddemidov avatar Jul 21 '21 15:07 ddemidov

Note that python interface assumes that all input arrays have C-layout, hence the .copy() in cell [2] in the above notebook.

ddemidov avatar Jul 21 '21 16:07 ddemidov