Performance guide¶
Method selection¶
Small/medium matrices:
svdsgives the most accurate result.Large sparse matrices:
golub-kahanorlanczosis usually faster.1-norm estimation:
hager-highamwithsolver='lu'is typically the fastest stable option.
Practical tips¶
Keep matrix format in CSR/CSC for sparse operations.
Start with
method='auto'to get a good baseline.Reduce
max_iterwhen rough estimates are acceptable.Use
return_dict=Trueto inspect convergence metadata and debug bottlenecks.
Benchmark template¶
import time
candidates = ['svds', 'lanczos', 'golub-kahan']
for name in candidates:
t0 = time.time()
cond = cond_estimate(A, norm=2, method=name)
dt = time.time() - t0
print(f"{name:12s} cond={cond:.3e} time={dt:.3f}s")