flopscope.

flopscope.accounting.matrix_power_cost

flopscope.accounting.matrix_power_cost(n, k)[flopscope source]

Weighted FLOP cost of matrix power A**k.

Parameters

n:int

Number of columns in the input matrix.

k:int

Target rank or number of singular components to estimate.

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.

Uses exponentiation by repeated squaring. For $k < 0$, adds $n^3$ for the initial matrix inversion.