Add memory impl for sparse matrix state