function C = multi_block_inverse(A, B)
%MULTI_BLOCK_INVERSE Summary of this function goes here
%   Detailed explanation goes here

[m, n] = size(A);
p = size(B, 1);
k = m / n;

if p ~= m
    error('multi_block_inverse:incompatible_sizes', ...
        'The number of rows of A and B must match');
end

r = repmat((1:m).', n, 1);
c = bsxfun(@plus, kron(n*(0:k-1).', ones(n,1)), 1:n);
As = sparse(r, c, A(:), m, m);
C = As \ B;

end

