view +blockmatrix/isBlockmatrixTest.m @ 1031:2ef20d00b386 feature/advectionRV

For easier comparison, return both the first order and residual viscosity when evaluating the residual. Add the first order and residual viscosity to the state of the RungekuttaRV time steppers
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Thu, 17 Jan 2019 10:25:06 +0100
parents f0f4ca946068
children
line wrap: on
line source

function tests = isBlockmatrixTest()
    tests = functiontests(localfunctions);
end

function testIsBlockmatrix(testCase)
    cases = {
        {
            magic(3),
            false % Must be a cell array
        }
        {
            {[2 2 2];{1,2}},
            false % All elements of the cell matrix must be regular matrices
        },
        {
            {[2 2 2];[1 2]},
            false % Row dimensions must match
        },
        {
            {[2; 2; 2], [1; 2]},
            false % Column dimensions must match
        },
        {
            {},
            true % An empty matrix is a matrix too
        },
        {
            {
            [2 2; 2 1], [1; 2];
            [2 2], [1]
            },
            true % A simple valid one
        },
        {
            {
            [2 2; 2 1], [];
            [2 2], [1]
            },
            true % Empty blocks assumed to be zero and match dimensions
        },
        {
            {
            [2 2; 2 1], [];
            [2 2], []
            },
            true % Empty blocks allowed.
        },
        {
            {
            [2 2; 2 1], [1; 2];
            [], []
            },
            true % Empty blocks allowed.
        },
        {
            blockmatrix.zero({[1 2 3],[2 3]}),
            true % A zero block matrix is a block matrix
        },
    };

    for i = 1:length(cases)
        in = cases{i}{1};
        out = blockmatrix.isBlockmatrix(in);
        expected = cases{i}{2};
        testCase.verifyEqual(out, expected, sprintf('Should return %d for %s', expected, toString(in)));
    end
end