Sergey.Bochkanov wrote:
For example, you've forgot to clear state after you used it (in the current version it is OK, but in future versions of ALGLIB it can lead to memory leaks).
Sergey, thank you for your answer! And could you please tell me what function clears a state and when it should be called?
Today I faced another problem, now with the spline1dbuildlinear function on such x and y vectors:
Code:
i=0, x=-1.000000e+001, y=4.506061e-009
i=1, x=-9.300000e+000, y=1.820550e-008
i=2, x=-8.600000e+000, y=7.352574e-008
i=3, x=-7.900000e+000, y=2.968071e-007
i=4, x=-7.200000e+000, y=1.197468e-006
i=5, x=-6.500000e+000, y=4.827799e-006
i=6, x=-5.800000e+000, y=1.944683e-005
i=7, x=-5.100000e+000, y=7.824295e-005
i=8, x=-4.400000e+000, y=3.143099e-004
i=9, x=-3.700000e+000, y=1.259774e-003
i=10, x=-3.000000e+000, y=5.031704e-003
i=11, x=-2.880000e+000, y=6.376730e-003
i=12, x=-2.760000e+000, y=8.079761e-003
i=13, x=-2.640000e+000, y=1.023544e-002
i=14, x=-2.520000e+000, y=1.296314e-002
i=15, x=-2.400000e+000, y=1.641328e-002
i=16, x=-2.280000e+000, y=2.077518e-002
i=17, x=-2.160000e+000, y=2.628679e-002
i=18, x=-2.040000e+000, y=3.324660e-002
i=19, x=-1.920000e+000, y=4.202824e-002
i=20, x=-1.800000e+000, y=5.309789e-002
i=21, x=-1.680000e+000, y=6.703490e-002
i=22, x=-1.560000e+000, y=8.455517e-002
i=23, x=-1.440000e+000, y=1.065362e-001
i=24, x=-1.320000e+000, y=1.340411e-001
i=25, x=-1.200000e+000, y=1.683336e-001
i=26, x=-1.080000e+000, y=2.108710e-001
i=27, x=-9.600000e-001, y=2.632419e-001
i=28, x=-8.400000e-001, y=3.269837e-001
i=29, x=-7.200000e-001, y=4.031410e-001
i=30, x=-6.000000e-001, y=4.912729e-001
i=31, x=-4.800000e-001, y=5.873412e-001
i=32, x=-3.600000e-001, y=6.795966e-001
i=33, x=-2.400000e-001, y=7.423721e-001
i=34, x=-1.200000e-001, y=7.341857e-001
i=35, x=0.000000e+000, y=6.210876e-001
i=36, x=1.200000e-001, y=4.258490e-001
i=37, x=2.400000e-001, y=2.228184e-001
i=38, x=3.600000e-001, y=6.719326e-002
i=39, x=4.800000e-001, y=-3.072114e-002
i=40, x=6.000000e-001, y=-8.318193e-002
i=41, x=7.200000e-001, y=-1.056627e-001
i=42, x=8.400000e-001, y=-1.102537e-001
i=43, x=9.600000e-001, y=-1.050420e-001
i=44, x=1.080000e+000, y=-9.505269e-002
i=45, x=1.200000e+000, y=-8.325916e-002
i=46, x=1.320000e+000, y=-7.133737e-002
i=47, x=1.440000e+000, y=-6.016893e-002
i=48, x=1.560000e+000, y=-5.016170e-002
i=49, x=1.680000e+000, y=-4.144936e-002
i=50, x=1.800000e+000, y=-3.401360e-002
i=51, x=1.920000e+000, y=-2.775799e-002
i=52, x=2.040000e+000, y=-2.255166e-002
i=53, x=2.160000e+000, y=-1.825448e-002
i=54, x=2.280000e+000, y=-1.473085e-002
i=55, x=2.400000e+000, y=-1.185671e-002
i=56, x=2.520000e+000, y=-9.522383e-003
i=57, x=2.640000e+000, y=-7.633225e-003
i=58, x=2.760000e+000, y=-6.108885e-003
i=59, x=2.880000e+000, y=-4.882010e-003
i=60, x=3.000000e+000, y=-3.896677e-003
i=61, x=3.700000e+000, y=-1.027049e-003
i=62, x=4.400000e+000, y=-2.652145e-004
i=63, x=5.100000e+000, y=-6.766669e-005
i=64, x=5.800000e+000, y=-1.713168e-005
i=65, x=6.500000e+000, y=-4.314561e-006
i=66, x=7.200000e+000, y=-1.082521e-006
i=67, x=7.900000e+000, y=-2.708450e-007
i=68, x=8.600000e+000, y=-6.762023e-008
i=69, x=9.300000e+000, y=-1.685407e-008
i=70, x=1.000000e+001, y=-4.195189e-009
spline1dbuildlinear and spline1dbuildakima work with them OK, but spline1dbuildcubic rises exception:
ae_assert(isfinitevector(d, n, _state), "Spline1DBuildHermite: D contains infinite or NAN values!", _state);through this code:
Code:
void spline1dbuildhermite(/* Real */ ae_vector* x,.........................................
/*
* check and sort points
*/
ae_assert(isfinitevector(x, n, _state), "Spline1DBuildHermite: X contains infinite or NAN values!", _state);
ae_assert(isfinitevector(y, n, _state), "Spline1DBuildHermite: Y contains infinite or NAN values!", _state);
ae_assert(isfinitevector(d, n, _state), "Spline1DBuildHermite: D contains infinite or NAN values!", _state);
heapsortdpoints(x, y, d, n, _state);
ae_assert(aredistinct(x, n, _state), "Spline1DBuildHermite: at least two consequent points are too close!", _state);
My code generating this is following:
Code:
for(i=0;i<y.length();i++)
{
y(i) = _ZXcorr(x(i),k*d,_state);
printf("i=%d, x=%e, y=%e\n",i,x(i),y(i));
}
spline1dbuildcubic(x.c_ptr(), y.c_ptr(), n, 2, 0.0, 2, 0.0, &ZXcorr_ipt, _state);
//spline1dbuildlinear(x.c_ptr(), y.c_ptr(), n, &ZXcorr_ipt, _state);