using DynArray for sparse matrix construction