[ https://issues.apache.org/jira/browse/MATH1138?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=14135979#comment14135979
]
Gilles commented on MATH1138:

bq. I reimplemented \[...\] rederived \[...\] confirmed
Thanks a lot for this thorough review.
bq. It's just not working though. \[...\] I looked into how Octave performs the same function.
They do not do it this way.
It would be interesting to go to the reference mentioned in the Wikipedia article. Maybe
it will reveal where the bugs are.
A web search came up with this site:
{noformat}
http://www.paulinternet.nl/?page=bicubic
{noformat}
At first sight, there would seem to be a discrepancy with the contents of the matrix...
bq. I have a mechanism for implementing it in that way and could take a crack at it if you
would like.
That would be nice but be careful to not use a reference that would forbid inclusion in Commons
Math.
bq. let me know what the proper path forward would be to get this assigned to me and contribute
it back.
One way would be to generate the expected values from another package (e.g. Octave) and create
a unit test that will miserably fail with the current code when "reasonable" tolerances are
used.
Then, you are most welcome to fix the implementation, trying to not change the public API.
> BicubicSplineInterpolator is returning incorrect interpolated values
> 
>
> Key: MATH1138
> URL: https://issues.apache.org/jira/browse/MATH1138
> Project: Commons Math
> Issue Type: Bug
> Affects Versions: 3.3
> Reporter: Adam Bedrossian
> Attachments: Interpolated Values from CM and MatLab.docx
>
>
> I have encountered a use case with the BicubicSplineInterpolator where the interpolated
values that are being returned seem incorrect. Furthermore, the values do not match those
generated by MatLab using the interp2 'cubic' method.
> Here is a snippet of code that uses the interpolator:
> double[] xValues = new double[] {36, 36.001, 36.002};
> double[] yValues = new double[] {108.00, 107.999, 107.998};
> double[][] fValues = new double[][] {{1915, 1906, 1931},
> {1877, 1889, 1894},
> {1878, 1873, 1888}};
> BicubicSplineInterpolator interpolator = new BicubicSplineInterpolator();
> BicubicSplineInterpolatingFunction interpolatorFunction = interpolator.interpolate(xValues,
yValues, fValues);
> double[][] results = new double[9][9];
> double x = 36;
> int arrayIndexX = 0, arrayIndexY = 0;
> while(x <= 36.002) {
> double y = 108;
> arrayIndexY = 0;
> while (y <= 107.998) {
> results[arrayIndexX][arrayIndexY] = interpolatorFunction.value(x, y);
> System.out.println(results[arrayIndexX][arrayIndexY]);
> y = y + 0.00025;
> arrayIndexY++;
> }
> x = x + 0.00025;
> arrayIndexX++;
> }
> Attached is a grid showing x and y values and the corresponding interpolated value from
both commons math and MatLab.
> The values produced by commons math are far off from those created by MatLab.

This message was sent by Atlassian JIRA
(v6.3.4#6332)
