Comments (5)
I think I may have found the issue. Lines 198 to 204 now are:
fp = (*Z)(i,jp);
fm = (*Z)(i,jm);
fy01 = (fp - fm) / yL; // <<<<<<
fp = (*Z)(i+1,jp);
fm = (*Z)(i+1,jm);
fy11 = (fp - fm) / yL; // <<<<<<
And should be replaced by:
fp = (*Z)(i,jp);
fm = (*Z)(i,jm);
fy01 = (fp - fm) / dy; // <<<<<<
fp = (*Z)(i+1,jp);
fm = (*Z)(i+1,jm);
fy11 = (fp - fm) / dy; // <<<<<<
Kind regards,
Laurent Keersmaekers
from libinterpolate.
Thank you for the issue, the 2D interpolators are not nearly as well tested as 1D.
I will not be able to look at this very soon, but when I have time I will go back through the derivation of the 2D cubic spline method.
In the mean time, would you be able to implement a unit test that fails on this bug so I can implement a fix that gives the desired behavior?
from libinterpolate.
#include "pch.h"
#include "CppUnitTest.h"
#include <libInterpolate/Interpolate.hpp>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
namespace UnitTest1
{
TEST_CLASS(UnitTest1)
{
public:
TEST_METHOD(TestMethod1)
{
std::vector<double> x2, y2, z2;
double valTest = 2.5;
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
x2.push_back((double)i);
y2.push_back((double)j);
z2.push_back((double)i * (double)j);
}
}
_2D::BicubicInterpolator<double> interpBiCub;
interpBiCub.setData(x2, y2, z2);
double valBiCub = interpBiCub(valTest, valTest);
double valBiTh = valTest * valTest;
bool success = false;
if (fabs(valBiTh - valBiCub) < 1.0e-8)
{
success = true;
}
Assert::AreEqual(success, true);
}
};
}
from libinterpolate.
In the above code, I used a tolerance of 1.0e-8. Since the function I used is quadratic w.r.t. to the combination of x and y, the cubic interpolator should always be able to stay within this accuracy without any issues. The original interpolator will fail, because the difference between the theoretical value and the interpolated value will exceed 1.0e-8 (by far).
from libinterpolate.
Thanks for reporting the issue. I went through the method this weekend and implemented your fix.
from libinterpolate.
Related Issues (13)
- Monotonic interpolator does not work with single precision HOT 1
- cmake ignores -DBUILD_TESTS=OFF HOT 3
- Fails to build on OSX: std::iterator is deprecated HOT 2
- can set a scalar factor to zoom ? HOT 4
- Add support for Windows and MacOS HOT 1
- Add constructors that accept data as arguments to interpolators HOT 1
- Bilinear interpolation doesn't work. HOT 5
- Document data format requirments for 2D interpolators HOT 1
- Add support for passing vector of x and y coordinates to 2D interpolators HOT 1
- Poor performance on large data HOT 2
- catch.hpp:10735 assumes that MINSIGSTKSZ is a constant which isn't true for glibc 2.34 HOT 6
- Getting errors on MSVC C++20 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libinterpolate.