As_TsparseMatrix function

Transform to TsparseMatrix/dgTMatrix