view isEquidistant.m @ 1016:4b42999874c0 feature/advectionRV

Add lower level for boot-strapping to RungeKuttaExteriorRV - Add a lower level to RungeKuttaExteriorRV for which bootstrapping starts, e.g start bootstrapping from time level 3 using a 3rd order BDF - Clean up ResidualViscosity
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Fri, 07 Dec 2018 13:11:53 +0100
parents b43c4d841afe
children
line wrap: on
line source

% Tests if consecutive elements of vector v are euidistant
function b = isEquidistant(v)
    if length(v) < 2
        error('sbplib:isEquidistant:inputTooShort', 'Input vector is too short');
    end

    tol = 1e-8;

    d = v(2:end) - v(1:end-1);
    err = abs(d - d(1));

    relErr = err./abs(d);

    I_zero = find(d < tol);

    relErr(I_zero) = err(I_zero);

    b = all(relErr < tol);
end