chore: optimize sparse matrix casting with python tuple (#4064) * optimize casting of sparse Eigen arrays * move array * Revert for safety