Revert "Fix inv for triangular matrices"

This reverts commit 247af6bd28773243e9a7dc8437cf1d3780688603.
Revert "Fix #3622"

This reverts commit c339b44a372cc996563a59c50f961eda979632c0.
Fix inv for triangular matrices