Improve pinv2 and pinvh.

Avoid matrix operations on array elements that are multiplied by 0
in the process of calculation.