<p dir="auto">I would like to compute the matrix exponential of many small matrices at once.  This works, but is slow:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import scipy.linalg


A = np.random.rand(3, 3, 777)

exp_A = np.array([
    scipy.linalg.expm(dt * W[..., k])
    for k in range(m)
])

scipy.linalg.expm(A)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">linalg</span>


<span class="pl-v">A</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">rand</span>(<span class="pl-c1">3</span>, <span class="pl-c1">3</span>, <span class="pl-c1">777</span>)

<span class="pl-s1">exp_A</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([
    <span class="pl-s1">scipy</span>.<span class="pl-s1">linalg</span>.<span class="pl-en">expm</span>(<span class="pl-s1">dt</span> <span class="pl-c1">*</span> <span class="pl-v">W</span>[..., <span class="pl-s1">k</span>])
    <span class="pl-k">for</span> <span class="pl-s1">k</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-s1">m</span>)
])

<span class="pl-s1">scipy</span>.<span class="pl-s1">linalg</span>.<span class="pl-en">expm</span>(<span class="pl-v">A</span>)</pre></div>
<p dir="auto">It'd be great of <code class="notranslate">expm</code> could be vectorized.</p>
<p dir="auto">Continuation of discussion from <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="473661751" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/10534" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/10534/hovercard" href="https://github.com/scipy/scipy/pull/10534">#10534</a>. Several suggestions from <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/rlucas7/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/rlucas7">@rlucas7</a> there:</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> <a href="https://blogs.sas.com/content/iml/2018/03/07/fit-distribution-matching-quantile.html" rel="nofollow">Quantile fits</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> post-hoc "tests", including Bayesian methods (e.g. <a href="https://arxiv.org/pdf/1506.06101.pdf" rel="nofollow">https://arxiv.org/pdf/1506.06101.pdf</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> meta-analysis along the lines of <code class="notranslate">scipy.stats.combine_pvalues</code></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> more options for censoring / truncation</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> bootstrapping (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="782478074" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/13371" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/13371/hovercard" href="https://github.com/scipy/scipy/pull/13371">gh-13371</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> non-parametric versions of hypothesis tests (e.g. several in Hollander and Wolf)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> intervals beyond confidence intervals (prediction intervals, tolerance intervals, HPD (Bayesian))</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> <code class="notranslate">fit</code> methods for <code class="notranslate">rv_discrete</code> classes - (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="1108630552" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/15436" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/15436/hovercard" href="https://github.com/scipy/scipy/pull/15436">gh-15436</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/chrisb83/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/chrisb83">@chrisb83</a>) exact calculation of <code class="notranslate">p</code>-values, where possible (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="861690498" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/13899" data-hovercard-type="pull_request" data-hovercard-url="/scipy/scipy/pull/13899/hovercard" href="https://github.com/scipy/scipy/pull/13899">gh-13899</a>), (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a>) especially for ties</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a>) distribution-specific documentation of each distribution method (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="457750785" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/10328" data-hovercard-type="issue" data-hovercard-url="/scipy/scipy/issues/10328/hovercard" href="https://github.com/scipy/scipy/issues/10328">gh-10328</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a>) overhaul of distribution test suite (e.g. tests of every method with array input)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a>) unify stats and mstats with consistent support for <code class="notranslate">axis</code>, <code class="notranslate">nan_policy</code>, and masked arrays (see <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="980914393" data-permission-text="Title is private" data-url="https://github.com/scipy/scipy/issues/14651" data-hovercard-type="issue" data-hovercard-url="/scipy/scipy/issues/14651/hovercard" href="https://github.com/scipy/scipy/issues/14651">gh-14651</a>)</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> (<a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/mdhaber/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/mdhaber">@mdhaber</a>) overhaul of <code class="notranslate">rv_generic</code> and subclasses</li>
</ul>