view assertSize.m @ 888:8732d6bd9890 feature/timesteppers

Add general Runge-Kutta class - Add a general Runge-Kutta class which time integrates the solution based on coefficients obtained from a Butcher tableau - Add butcher tableau which returns coefficents for the specified Runge-Kutta method - Remove RungKutta4proper, since obsolete
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 15 Nov 2018 17:10:01 -0800
parents dec0447cbf2c
children a72038b1f709
line wrap: on
line source

% Assert that array A has the size s.
function assertSize(A,varargin)
    if length(varargin) == 1
        s = varargin{1};
        errmsg = sprintf('Expected %s to have size %s, got: %s',inputname(1), toString(s), toString(size(A)));
        assert(all(size(A) == s), errmsg);
    elseif length(varargin) == 2
        dim = varargin{1};
        s = varargin{2};

        errmsg = sprintf('Expected %s to have size %d along dimension %d, got: %d',inputname(1), s, dim, size(A,dim));
        assert(size(A,dim) == s, errmsg);
    else
        error('Expected 2 or 3 arguments to assertSize()');
    end
end