add matrix_toarray, rewrite vector_toarray