Dec
08

Understanding Sparse Matrix Storage

Sparse matrices are powerful tools that can be used to save memory when processing and storing matrices that contain a lot of zero values. Within a sparse matrix, only the non-zero values are stored which can mean significant memory savings. For example, a 501-by-501 tri-diagonal matrix contains 251,001 values as a full matrix while it… Continue reading »

Dec
08

Sparse and Automatic Accumulation

The sparse function is normally used to create sparse matrices but it has a trick up its sleeve! ¬†This post reveals one of my favorite MATLAB tricks. When used with the tuple syntax, sparse(i,j,v) or sparse(i,j,v,m,n), any repeated (i,j) elements are automatically accumulated! In other words, the sparse function automatically sums any values that are… Continue reading »