NumCpp icon indicating copy to clipboard operation
NumCpp copied to clipboard

nc::linalg::pinv doesn't support non square matrix

Open siferati opened this issue 5 months ago • 0 comments

Description

nc::linalg::pinv results in error when calling it with non square matrix.

File: /usr/local/include/NumCpp/NdArray/NdArrayCore.hpp
	Function: dot
	Line: 2751
	Error: shapes of [2, 9] and [2, 9] are not consistent.
Input:
[[0.11111111 1.        ]
 [0.22222222 1.        ]
 [0.33333333 1.        ]
 [0.44444444 1.        ]
 [0.55555556 1.        ]
 [0.66666667 1.        ]
 [0.77777778 1.        ]
 [0.88888889 1.        ]
 [1.         1.        ]]

Expected output (i.e. result of Python numpy.linalg.pinv):
[[-6.00000000e-01 -4.50000000e-01 -3.00000000e-01 -1.50000000e-01 6.97053522e-17  1.50000000e-01  3.00000000e-01  4.50000000e-01 6.00000000e-01]
 [ 4.44444444e-01  3.61111111e-01  2.77777778e-01  1.94444444e-01 1.11111111e-01  2.77777778e-02 -5.55555556e-02 -1.38888889e-01 -2.22222222e-01]]

siferati avatar Sep 03 '24 06:09 siferati