Code covered by the BSD License  

Highlights from
N-dimensional Sparse Matrices

N-dimensional Sparse Matrices

by

 

11 Jan 2011 (Updated )

N-dimensional sparse matrix and circular sparse matrix classes for arbitrary N.

example.m
import edu.stanford.covert.util.SparseMat;
import edu.stanford.covert.util.CircularSparseMat;

addpath('src');

%builtin matrix
mat = zeros(4,3);
mat(4, 3)=1;
mat(3, 2)=2;
mat(1, 1)=3;
mat(3, 1)=4;

%% sparse mat
%syntax #1
spmat = SparseMat(mat);

%syntax #2
[i,j,vals] = find(mat);
spmat = SparseMat([i j], vals, size(mat));

%% circular sparse mat

%% sparse mat
%syntax #1
cspmat = CircularSparseMat(mat, 1);

%syntax #2
[i,j,vals] = find(mat);
cspmat = CircularSparseMat([i j], vals, size(mat), 1);

Contact us