From 20b31fc019822c850e7beacf7c9cc16a4704cd1b Mon Sep 17 00:00:00 2001 From: Mitchell Clark <45748401+ModestMC@users.noreply.github.com> Date: Thu, 26 Sep 2024 18:09:32 -0700 Subject: [PATCH] Update interpolate.fun to match interpolate_ga.fun This appears to be some more efficient approach to array creation that was previously handled by a while loop. --- tdi/math/interpolate.fun | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tdi/math/interpolate.fun b/tdi/math/interpolate.fun index bef0cbec75..0782b88310 100644 --- a/tdi/math/interpolate.fun +++ b/tdi/math/interpolate.fun @@ -13,8 +13,7 @@ public fun interpolate(in _x, in _xarr, in _yarr) if(_x <= _xarr[0]) return (_yarr[0]); if(_x >= _xarr[_n - 1]) return (_yarr[_n - 1]); - _i = 0; - while(_x > _xarr[_i]) _i++; + _i = size(pack(_xarr,_xarr<=_x)); return (_yarr[_i - 1] + (_x - _xarr[_i - 1]) * (_yarr[_i] - _yarr [_i - 1])/(_xarr[_i] - _xarr[_i - 1])); -} \ No newline at end of file +}