Home > freetb4matlab > sparse > spalloc.m

spalloc

PURPOSE ^

% Returns an empty sparse matrix of size @var{r}-by-@var{c}. As Octave

SYNOPSIS ^

function s = spalloc (r, c, nz)

DESCRIPTION ^

% -*- texinfo -*-
% @deftypefn {Function File} {@var{s} =} spalloc (@var{r}, @var{c}, @var{nz})
% Returns an empty sparse matrix of size @var{r}-by-@var{c}.  As Octave
% resizes sparse matrices at the first opportunity, so that no additional 
% space is needed, the argument @var{nz} is ignored.  This function is 
% provided only for compatibility reasons.
%
% It should be noted that this means that code like
%
% @example
% @group
% k = 5;
% nz = r * k;
% s = spalloc (r, c, nz)
% for j = 1:c
%   idx = randperm (r);
%   s (:, j) = [zeros(r - k, 1); rand(k, 1)] (idx);
% end
% @end group
% @end example
%
% will reallocate memory at each step.  It is therefore vitally important
% that code like this is vectorized as much as possible.
% @seealso{sparse, nzmax}
% @end deftypefn

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:
Generated on Sat 16-May-2009 00:04:49 by m2html © 2003