Giter Site home page Giter Site logo

libinterpolate's People

Contributors

afhoffman92 avatar cd3 avatar finnbsch avatar gjacquenot avatar lewinjh avatar orgonth avatar yter2016 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libinterpolate's Issues

can set a scalar factor to zoom ?

The function like "scipy.ndimage.interpolation.zoom" which implemented the spline interpolation
can just easily give a scale factor to zoom in or out the original array
How can I implement this with your excellent jobs ?

Thanks !

It always turns out to be zero. the principle of use is unclear.

Hello! First of all, thank you for the work done!

here is a code example:

	std::vector<double> lon;
	std::vector<double> lat;
	//0
	lat.push_back(-39.363024);
	lon.push_back(52.872388);
	//1
	lat.push_back(-37.615071); // maximum lat
	lon.push_back(119.453522);
	//2
	lat.push_back(-75.928);
	lon.push_back(119.754988);
	//3
	lat.push_back(-75.93703); // minimum lat
	lon.push_back(119.689077);
	//4
	lat.push_back(-69.968429);
	lon.push_back(76.1259);
	//5
	lat.push_back(-58.196226);
	lon.push_back(59.691912);
	//6
	lat.push_back(-44.978186);
	lon.push_back(53.709062);
	//7
	lat.push_back(-39.363024);
	lon.push_back(52.872388);

	_1D::CubicSplineInterpolator<double> interp;
	interp.setData(lat, lon);

	double minLat = -75.93703;
	double maxLat = -37.615071;

	std::vector<double> lon2;
	std::vector<double> lat2;

 // now I want to go from the minimum lat value to the maximum and generate new lon lat pairs
	for (auto m(minLat); m < maxLat; m+=0.5)	{
		double valLon = interp(m);
		if (valLon == 0) {
			std::cout << " 0 " << std::endl; // in every step :(			
		}
		else {
			lon2.push_back(valLon);
			lat2.push_back(m);
		}
	}
	std::cout << "new lat size: " << lat2.size() << " | new lon size: " << lon2.size() << std::endl;

I have a polygon that doesn't have many points and because of this it has sharp edges, I need to make it smoother.
But for some reason I always get 0 when interpolating.

2D cubic interpolation

Dear,

I wanted to use the 2D cubic interpolation, and came across an issue regarding the output. The input vectors x and y in my example, are formed by the array of doubles [0 1 2 3 4]. When applying the BicubicInterpolator with [xi yi] = [2.5 2.5], I get an aswer of 5.9375, while I expected 6.25. E.g. the BilinearInterpolator provides the correct answer. I added an attachement with the code I used to test the 2D interpolators.
2D_Example.txt

Kind regards,
Laurent Keersmaekers

Bilinear interpolation doesn't work.

I am trying to use bilinear interpolation for inpainting a part of an image.

	vector<double> ztrain;
	for (int i = 0; i < img.rows; i++) {
		for (int j = 0; j < img.cols; j++) {
			if (img.at<Vec3b>(i, j)[channel] != 0) {
				xtrain.push_back(j);
				ytrain.push_back(i);
				ztrain.push_back(img.at<Vec3b>(i, j)[channel]);
			}
			else {
				xinter.push_back(j);
				yinter.push_back(i);
			}
		}
	}
	_2D::BilinearInterpolator<double> interp = 
		_2D::BilinearInterpolator<double>(xtrain.size(), xtrain.data(), ytrain.data(), ztrain.data());
	vector<double> zans;
	for (int i = 0; i < xinter.size(); i++) {
		double res = interp(xinter[i], yinter[i]);
		img.at<Vec3b>(yinter[i], xinter[i])[channel] = res;
	}

It doesn't do anything. Debugger showed me it happens because y is outside of the Ys boundaries in BilinearInterpolator<Real>::operator()( Real x, Real y ). And these boundaries are between 0 and 0((*Y)(0) and (*Y)(Y->size()-1) )

xData, yData, zData are the same size and correct.

How to fix it?

Monotonic interpolator does not work with single precision

The linear and cubic spline interpolators can interpolate float and double data, but the monotonic interpolator fails to compile.

_1D::MonotonicInterpolator<float> interp;
std::vector<float> x,y;
interp.setData(x,y);

gives a long error about type mismatches.

Getting errors on MSVC C++20

Hello,

Trying to use libInterpolate with msvc c++20 standard on Windows and getting tons of erros like these. Am I doing anything wrong?
Is the library supposed to work on windows/msvc ?
Thanks

------ Build All started: Project: FinEngLech, Configuration: x64-Debug ------
[1/3] Building CXX object CMakeFiles\YieldCurveTest.dir\src\YieldCurve.cpp.obj
FAILED: CMakeFiles/YieldCurveTest.dir/src/YieldCurve.cpp.obj
"C:\PROGRA~1\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.30.30705\bin\Hostx64\x64\cl.exe" /nologo /TP -DFMT_LOCALE -DFMT_SHARED -IC:\Users\suhasghorp\source\repos\FinEngLech\extern -IC:\Users\suhasghorp\source\repos\FinEngLech\include -IC:\vcpkg\installed\x64-windows\include -IC:\eigen-3.4.0 /DWIN32 /D_WINDOWS /W3 /GR /EHsc /MDd /Zi /Ob0 /Od /RTC1 /std:c++latest -std:c++20 /showIncludes /FoCMakeFiles\YieldCurveTest.dir\src\YieldCurve.cpp.obj /FdCMakeFiles\YieldCurveTest.dir\ /FS -c C:\Users\suhasghorp\source\repos\FinEngLech\src\YieldCurve.cpp
C:\Users\suhasghorp\source\repos\FinEngLech\out\build\x64-Debug\cl : Command line warning D9025: overriding '/std:c++latest' with '/std:c++20'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\InterpolatorBase.hpp(223): warning C4068: unknown pragma 'parallel'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(146): note: error recovery skipped: '( ( identifier'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(146): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(146): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(146): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(146): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(146): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(147): note: error recovery skipped: '( ( identifier'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(147): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(147): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_1D\CubicSplineInterpolator.hpp(147): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(147): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_1D/CubicSplineInterpolator.hpp(147): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(149): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(149): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(149): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(149): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(149): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(149): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(150): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(150): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(150): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(150): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(150): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(150): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(163): note: error recovery skipped: '( ( identifier'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(163): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(163): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(163): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(163): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(163): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(164): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(164): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(164): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(164): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(164): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(164): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(179): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(179): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(179): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(179): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(179): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(179): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(180): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(180): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(180): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(180): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(180): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(180): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(193): note: error recovery skipped: '( ( identifier'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(193): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(193): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(193): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(193): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(193): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(194): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(194): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(194): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(194): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(194): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(194): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(208): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(208): note: error recovery skipped: ') >'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(208): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(208): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(208): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(208): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C3878: syntax error: unexpected token '(' following 'expression'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(209): note: error recovery skipped: '( ( identifier . . . constant'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C3878: syntax error: unexpected token ')' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(209): note: error recovery skipped: ') <'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(209): note: error recovery skipped: ') ?'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C2760: syntax error: ':' was unexpected here; expected ';'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(209): error C3878: syntax error: unexpected token ':' following 'expression_statement'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(209): note: error recovery skipped: ':'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate./Interpolators/_2D/BicubicInterpolator.hpp(209): note: error recovery skipped: ')'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(210): error C2589: '(': illegal token on right side of '::'
C:\Users\suhasghorp\source\repos\FinEngLech\extern\libInterpolate\Interpolators_2D\BicubicInterpolator.hpp(210): error C3878: syntax error: unexpected token '(' following 'expression'

Poor performance on large data

I have noticed poor performance while trying to interpolate thousands of values form a function with thousands of points. I suspect that the issue is with finding the points that should be used for interpolation. There has been no effort to optimize this step.

I believe other libraries, such as GSL, store the previously used index and use it as a starting point for the next call, which can speed up calls when you interpolate to several x values in order. However, this would require the interpolators to carry around more internal state, and I'm not sure what that would be for calling an interpolator from multiple threads.

Perhaps an optional argument(s) that allowed the caller to restrict the range or even provide a function that would do the search would be better.

cmake ignores -DBUILD_TESTS=OFF

Here is what I did (possible that I need a newer version of Boost or some other issue; I tried various --std=cc++ options to no avail).

git clone https://github.com/CD3/libInterpolate.git
cd libInterpolate
git checkout 2.5
mkdir build2.5
cd build2.5
cmake -DCMAKE_CXX_FLAGS=-std=c++14 -DBUILD_TESTS=OFF ..
make

This worked completed (but it built the tests).

cd ..
git checkout 2.6
mkdir build2.6
cd build2.6
cmake -DCMAKE_CXX_FLAGS=-std=c++14 -DBUILD_TESTS=OFF ..
make

Here is the output from cmake

-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git (found version "2.32.0")
-- libInterpolate version: 2.6
-- Found Boost: /usr/local/lib/cmake/Boost-1.77.0/BoostConfig.cmake (found version "1.77.0")
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2")
-- Found GSL: /usr/local/include (found version "2.7")
-- Detected Catch-based Unit Test Sources:
-- CatchTests/1D/AnyInterpolator.cpp
-- CatchTests/1D/Constructors.cpp
-- CatchTests/1D/CubicSplineInterpolatorTests.cpp
-- CatchTests/1D/InterpolatorBaseTests.cpp
-- CatchTests/1D/LinearInterpolatorTests.cpp
-- CatchTests/1D/MonotonicInterpolatorTests.cpp
-- CatchTests/1D/Performance.cpp
-- CatchTests/1D/RuntimePolymorphism.cpp
-- CatchTests/1D/Semantics.cpp
-- CatchTests/2D/AnyInterpolator.cpp
-- CatchTests/2D/BicubicInterpolatorTests.cpp
-- CatchTests/2D/BilinearInterpolatorTests.cpp
-- CatchTests/2D/Constructors.cpp
-- CatchTests/2D/InterpolatorBaseTests.cpp
-- CatchTests/2D/LinearDelaunayTriangleInterpolator.cpp
-- CatchTests/2D/Performance.cpp
-- CatchTests/2D/RuntimePolymorphism.cpp
-- CatchTests/2D/Semantics.cpp
-- CatchTests/2D/ThinPlateSplineInterpolatorTests.cpp
-- CatchTests/2D/TriangleInterpolatorBaseTests.cpp
-- CatchTests/Bugs/MonotonicInterpolatorWithFloat.cpp
-- CatchTests/Devel.cpp
-- CatchTests/Examples.cpp
-- CatchTests/UtilsTests.cpp
-- CatchTests/main.cpp
-- Configuring done
-- Generating done

This errored out with lots of STL issues in building the tests.

/usr/bin/c++ -DHAVE_GSL -DTESTING -I/home/priestwilliaml/libinterp/libInterpolate/testing/include -I/home/priestwilliaml/libinterp/libInterpolate/src -I/home/priestwilliaml/libinterp/libInterpolate/build2.6/include -isystem /usr/local/include/eigen3 -std=c++14 -Wall -Wextra -pedantic -Wno-unknown-pragmas -Wno-unused-parameter -Wno-gnu-zero-variadic-macro-arguments -Werror -std=gnu++11 -o CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/Performance.cpp.o -c /home/priestwilliaml/libinterp/libInterpolate/testing/CatchTests/1D/Performance.cpp
In file included from /usr/local/include/boost/geometry/geometry.hpp:26,
from /usr/local/include/boost/geometry.hpp:17,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/./Interpolators/_2D/DelaunayTriangulationInterpolatorBase.hpp:12,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/./Interpolators/_2D/LinearDelaunayTriangleInterpolator.hpp:3,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/Interpolate.hpp:8,
from /home/priestwilliaml/libinterp/libInterpolate/testing/CatchTests/1D/Performance.cpp:4:
/usr/local/include/boost/geometry/geometry.hpp:27:1: note: ‘#pragma message: CAUTION: Boost.Geometry in Boost 1.73 deprecates support for C++03 and will require C++14 from Boost 1.75 onwards.’
27 | BOOST_PRAGMA_MESSAGE("CAUTION: Boost.Geometry in Boost 1.73 deprecates support for C++03 and will require C++14 from Boost 1.75 onwards.")
| ^~~~~~~~~~~~~~~~~~~~
/usr/local/include/boost/geometry/geometry.hpp:28:1: note: ‘#pragma message: CAUTION: Define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING to suppress this message.’
28 | BOOST_PRAGMA_MESSAGE("CAUTION: Define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING to suppress this message.")
| ^~~~~~~~~~~~~~~~~~~~
In file included from /usr/local/include/boost/geometry/core/tag.hpp:23,
from /usr/local/include/boost/geometry/core/ring_type.hpp:28,
from /usr/local/include/boost/geometry/core/closure.hpp:23,
from /usr/local/include/boost/geometry/geometry.hpp:34,
from /usr/local/include/boost/geometry.hpp:17,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/./Interpolators/_2D/DelaunayTriangulationInterpolatorBase.hpp:12,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/./Interpolators/_2D/LinearDelaunayTriangleInterpolator.hpp:3,
from /home/priestwilliaml/libinterp/libInterpolate/src/libInterpolate/Interpolate.hpp:8,
from /home/priestwilliaml/libinterp/libInterpolate/testing/CatchTests/1D/Performance.cpp:4:
/usr/local/include/boost/geometry/util/type_traits_std.hpp:54:25: error: expected template-name before ‘<’ token
54 | : std::conditional_t<Trait::value, conjunction<Traits...>, Trait>
| ^
/usr/local/include/boost/geometry/util/type_traits_std.hpp:54:25: error: expected ‘{’ before ‘<’ token
/usr/local/include/boost/geometry/util/type_traits_std.hpp:68:25: error: expected template-name before ‘<’ token
68 | : std::conditional_t<Trait::value, Trait, disjunction<Traits...>>
| ^
/usr/local/include/boost/geometry/util/type_traits_std.hpp:68:25: error: expected ‘{’ before ‘<’ token
/usr/local/include/boost/geometry/util/type_traits_std.hpp:95:23: error: ‘remove_cv_t’ in namespace ‘std’ does not name a template type; did you mean ‘remove_cv’?
95 | using type = std::remove_cv_t<std::remove_reference_t>;
| ^~~~~~~~~~~
| remove_cv

Add constructors that accept data as arguments to interpolators

Currently, the interpolators only support default construction. The data to interpolate is set with the setData() method. It would be useful, especially when runtime binding with std::function, to allow the interpolators be constructed with the data.

Fails to build on OSX: std::iterator is deprecated

`➜ cmake --build . --target install
[ 3%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/AnyInterpolator.cpp.o
[ 7%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/Constructors.cpp.o
[ 11%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/CubicSplineInterpolatorTests.cpp.o
[ 15%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/InterpolatorBaseTests.cpp.o
[ 19%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/LinearInterpolatorTests.cpp.o
[ 23%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/MonotonicInterpolatorTests.cpp.o
[ 26%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/Performance.cpp.o
[ 30%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/RuntimePolymorphism.cpp.o
[ 34%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/1D/Semantics.cpp.o
[ 38%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/AnyInterpolator.cpp.o
[ 42%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/BicubicInterpolatorTests.cpp.o
[ 46%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/BilinearInterpolatorTests.cpp.o
[ 50%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/Constructors.cpp.o
[ 53%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/InterpolatorBaseTests.cpp.o
[ 57%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/LinearDelaunayTriangleInterpolator.cpp.o
[ 61%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/Performance.cpp.o
[ 65%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/RuntimePolymorphism.cpp.o
[ 69%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/Semantics.cpp.o
[ 73%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/ThinPlateSplineInterpolatorTests.cpp.o
[ 76%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/2D/TriangleInterpolatorBaseTests.cpp.o
[ 80%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/Bugs/MonotonicInterpolatorWithFloat.cpp.o
[ 84%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/Devel.cpp.o
[ 88%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/Examples.cpp.o
[ 92%] Building CXX object testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/UtilsTests.cpp.o
/Users/dutsov_c/Documents/Year-2022/libInterpolate/testing/CatchTests/UtilsTests.cpp:287:38: error: 'iterator<std::forward_iterator_tag, double>' is deprecated [-Werror,-Wdeprecated-declarations]
struct StridedIterator : public std::iterator<std::forward_iterator_tag, T> {
^
/.../libInterpolate/testing/CatchTests/UtilsTests.cpp:409:27: note: in instantiation of template class 'StridedIterator' requested here
StridedIterator begin(v.data(),2);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__iterator/iterator.h:27:29: note: 'iterator<std::forward_iterator_tag, double>' has been explicitly marked deprecated here
struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__config:1066:39: note: expanded from macro '_LIBCPP_DEPRECATED_IN_CXX17'

define _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_DEPRECATED

                                  ^

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__config:1043:48: note: expanded from macro '_LIBCPP_DEPRECATED'

define _LIBCPP_DEPRECATED attribute ((deprecated))

                                           ^

1 error generated.
make[2]: *** [testing/CMakeFiles/libInterpolate_CatchTests.dir/CatchTests/UtilsTests.cpp.o] Error 1
make[1]: *** [testing/CMakeFiles/libInterpolate_CatchTests.dir/all] Error 2
make: *** [all] Error 2`

I rarely use OSX, but if needed I can provide you with more info

Add support for passing vector of x and y coordinates to 2D interpolators

The 2D interpolators currently take a vector of x, y and z values for each data points. However, 2 of the 3 interpolators that are implemented require data to be on a regular grid, so the x and y coordinates are repeated.

Should add support for passing a vector of x coordinates, a vector of y coordinates, and a vector of z coordinates. in this case, Nx*Ny must equal Nz, and we would assume that the z values are given in order of increasing y first (like gnuplot).

Removes all trailing spaces ?

Thanks for this library!

Code contains multiple trailing spaces. This means that an edition with an IDE configured to remove trailing spaces modifies lot of files...

Are you interested in a pull request that removes all trailing spaces ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.