support for sparse matrix and flags