view +blockmatrix/isBlockmatrix.m @ 360:447ceb41fb65 feature/beams

Fixed penalty parameter in Wave2Dcurve.
author Jonatan Werpers <jonatan@werpers.com>
date Thu, 08 Dec 2016 11:11:28 +0100
parents 764438b52541
children a5f1b0267dba
line wrap: on
line source

function b = isBlockmatrix(bm)
    if ~iscell(bm)
        b = false;
        return
    end

    % Make sure all blocks are numerica matrices
    for i = 1:length(bm)
        if ~isnumeric(bm{i})
            b = false;
            return
        end
    end

    [N,M] = size(bm);
    % Make sure column dimensions agree
    for i = 1:N
        d = [];
        for j = 1:M
            d_ij = size(bm{i,j},1);
            if d_ij == 0
                continue
            end

            if isempty(d)
                d = d_ij;
                continue
            end

            if d ~= d_ij
                b = false;
                return
            end
        end
    end

    % Make sure row dimensions agree
    for j = 1:M
        d = [];
        for i = 1:N
            d_ij = size(bm{i,j},2);
            if d_ij == 0
                continue
            end

            if isempty(d)
                d = d_ij;
                continue
            end

            if d ~= d_ij
                b = false;
                return
            end
        end
    end

    b = true;
end