view m-toolbox/classes/@ssm/blockMatFillDiag.m @ 44:409a22968d5e default

Add unit tests
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Tue, 06 Dec 2011 18:42:11 +0100
parents f0afece42f48
children
line wrap: on
line source

% adds corresponding matrices of same sizes or empty inside cell array
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: blockMatFillDiag ensures the extended diagonal terms contain
%              the matrix size information
%
% CALL: a = blockMatFillDiag(a, isizes, jsizes)
% INPUTS:
%       a      - cell array of matrices representing a matrix by blocs.
%                blocs may be empty
%       isizes - heigth of the elements in the lines
%       jsizes - width of the elements in the rows
%
%
% OUTPUTS:
%       cell3 - cell array of matrices representing a matrix by blocs.
%               blocs may be empty
%
% NOTE : function is private to the ssm class
%
% VERSION: '$Id: blockMatFillDiag.m,v 1.4 2011/04/08 08:56:23 hewitson Exp $'
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function a = blockMatFillDiag(a, isizes, jsizes)
  if ~isempty(a) % checking the cell array is not of empty size
    ni = numel(isizes);
    nj = numel(jsizes);
    for p=1:(max(ni, nj))
      ii = min(p, ni);
      jj = min(p, nj);
      if isempty(a{ii,jj})
        a{ii,jj} = zeros(isizes(ii), jsizes(jj));
      end
    end
  end
end