sparseToVec function

Convert Matrix to vector