scipy/scipy — pull request #2478 by argriffing (2013-05-10 20:33:02+00:00)
Title: TST: expm sparse and dense matrix benchmark

Add an expm benchmark.

This is for the default version of expm; it doesn't depend on anything added to scipy in recent history, or at least since expm was extended to support sparse matrices.

In the table below I've pasted some benchmark times up to a minute, but the python code in the PR does not attempt the slowest of these iterations. I've prefixed this PR with "TST" but "BENCH" could have been better if that were a thing.

The benchmark shows that sparse expm is relatively slow compared to dense expm. This is what I expected to see, at least when the sparsity does not have any particular structure. No replication is attempted for the purposes of accounting for runtime variance; this is a rough benchmark that shows large (orders of magnitude) differences.

```
Sparse and Dense Matrix Exponential
==============================================================
shape | nnz | operation | time
| per row | | (seconds)
--------------------------------------------------------------
(30, 30) | 4 | matrix sampling | 0.00
(30, 30) | 4 | fmt conversions | 0.00
(30, 30) | 4 | sparse expm | 0.12
(30, 30) | 4 | dense expm | 0.01
(100, 100) | 5 | matrix sampling | 0.00
(100, 100) | 5 | fmt conversions | 0.01
(100, 100) | 5 | sparse expm | 0.82
(100, 100) | 5 | dense expm | 0.01
(300, 300) | 6 | matrix sampling | 0.00
(300, 300) | 6 | fmt conversions | 0.01
(300, 300) | 6 | sparse expm | 2.81
(300, 300) | 6 | dense expm | 0.10
(1000, 1000) | 7 | matrix sampling | 0.00
(1000, 1000) | 7 | fmt conversions | 0.15
(1000, 1000) | 7 | sparse expm | 62.43
(1000, 1000) | 7 | dense expm | 2.42
```