flopscope.

flopscope.accounting.pinv_cost

flopscope.accounting.pinv_cost(m, n)[flopscope source]

Weighted FLOP cost of Moore-Penrose pseudoinverse.

Parameters

m:int

Number of rows in the input matrix.

n:int

Number of columns in the input matrix.

Returns

:int

Weighted public cost estimate, floored to match runtime accounting.

Notes

This helper multiplies the analytical FLOP count by the active weight from flopscope._weights and then applies int(...) so public estimates match budget deductions.

NumPy implements pinv as: svd(A, full_matrices=False) → threshold tiny singular values → multiply vt.T by s_inv broadcasted → matmul with u.T. We compose the cost from svd_cost and matmul_cost so this formula tracks those helpers automatically (issue #69; was previously missing the post-SVD reconstruction).

Total: svd(m,n) + threshold(min(m,n)) + diag_scale(n*min(m,n)) + matmul(n, min(m,n), m).

The SVD term uses with_vectors=True (the reconstruction needs U/V); the 4.0 linalg weight is gone, so this composed value is exactly what is charged.