Avoid unnecessary matrix copy in BDCSVD and JacobiSVD

Reference issue

#2838 (closed)

What does this implement/fix?

This change addresses an unnecessary matrix copy that occurs when passing an Eigen::Map to BDCSVD::compute. Previously, only an overload taking const MatrixType& was available, which triggered a copy constructor call for non-MatrixType inputs.

By adding a compute(const MatrixBase<Derived>&) overload, the deepcopy at the boundary is avoided. Unfortunately, this function cannot be generalized to accept EigenBase because BDCSVD requires functions such as cwiseAbs().

After these changes, I verified with the debugger that the copy was not triggered.

Additional information

I am not sure if keeping both overloaded and original functions is the best approach for performance reasons or if it is more straightforward to keep only the overloaded ones. In the current MR, I am keeping both.

Edited by Damiano Franzò

Merge request reports

Loading