Code covered by the BSD License  

Highlights from
SparsePack

image thumbnail
from SparsePack by Sebastiaan
Packs a sparse matrix into a single uint8 array, reducing memory usage.

SparsePack.m
% SparsePack - Packs a sparse array into an array of bytes.
%
% It reduces the size because it only uses the number of bytes required 
% for the sparse indexing pointers, which are 8 by default on 64 bit 
% systems. So, if the number of rows and/or elements is less than 2^48
% you will get some fine reduction in size.
%
% Additionally, you can change the datatype of the data. Matlab only 
% supports double type.
%
% Usage: B = SparsePack(A[,options]);
%
%  A is a sparse matrix
%  B is a packed sparse type, of uint8
%  options is used for type conversion.
%    If options is: int8, uint8, int16, uint16, int32, uint32, single
%      -> data is converted
%    If options is: double, int64, uint64
%      -> data is not converted
%    If options is: cat
%      -> data is not converted, pointers are not converted: all 3 
%         indexing/value vectors are concatenated
%    If options is: logical
%      -> nonzero data is converted to 1
%    If options is: pattern
%      -> only the pointers are stored: al indexed elements (which can be
%         0) will become 1 when unpacked
%    A second option is: keep
%      -> when specified, the number of nonzeros is determined by
%         mxGetNzmax and therefor respects additional reserved memory for
%         the sparse matrix. Otherwise, the number of elements indexed is
%         used.
%
%  This program only works on Little Endian machines!
%
%  Compile with -D_DEBUG_ for some debugging information:
%   mex -largeArrayDims SparsePack.c [-D_DEBUG_]
%   mex -largeArrayDims SparseUnPack.c [-D_DEBUG_]
%
% (c) Sebastiaan Breedveld, 2009
%
%

Contact us at files@mathworks.com