bundles / scipy latest / scipy / sparse / linalg / _expm_multiply / expm_multiply
function
scipy.sparse.linalg._expm_multiply:expm_multiply
source: build-install/usr/lib/python3.14/site-packages/scipy/sparse/linalg/_expm_multiply.py:109
Signature
def expm_multiply(A, B, start = None, stop = None, num = None, endpoint = None, traceA = None)Summary
Compute the action of the matrix exponential of A on B.
Parameters
A: transposable linear operatorThe operator whose exponential is of interest.
B: ndarray, sparse arrayThe matrix or vector to be multiplied by the matrix exponential of A.
start: scalar, optionalThe starting time point of the sequence.
stop: scalar, optionalThe end time point of the sequence, unless
endpointis set to False. In that case, the sequence consists of all but the last ofnum + 1evenly spaced time points, so thatstopis excluded. Note that the step size changes whenendpointis False.num: int, optionalNumber of time points to use.
endpoint: bool, optionalIf True,
stopis the last time point. Otherwise, it is not included.traceA: scalar, optionalTrace of
A. If not given the trace is estimated for linear operators, or calculated exactly for sparse matrices. It is used to preconditionA, thus an approximate trace is acceptable. For linear operators,traceAshould be provided to ensure performance as the estimation is not guaranteed to be reliable for all cases.
Returns
expm_A_B: ndarrayThe result of the action .
Warns
: UserWarningIf
Ais a linear operator andtraceA=None(default).
Notes
The optional arguments defining the sequence of evenly spaced time points are compatible with the arguments of numpy.linspace.
The output ndarray shape is somewhat complicated so I explain it here. The ndim of the output could be either 1, 2, or 3. It would be 1 if you are computing the expm action on a single vector at a single time point. It would be 2 if you are computing the expm action on a vector at multiple time points, or if you are computing the expm action on a matrix at a single time point. It would be 3 if you want the action on a matrix with multiple columns at multiple time points. If multiple time points are requested, expm_A_B[0] will always be the action of the expm at the first time point, regardless of whether the action is on a vector or a matrix.
Examples
import numpy as np from scipy.sparse import csc_array from scipy.sparse.linalg import expm, expm_multiply A = csc_array([[1, 0], [0, 1]])✓
A.toarray()
✗array([[1, 0],
[0, 1]])
B = np.array([np.exp(-1.), np.exp(-2.)])
✓B expm_multiply(A, B, start=1, stop=2, num=3, endpoint=True) expm(A).dot(B) # Verify 1st timestep expm(1.5*A).dot(B) # Verify 2nd timestep expm(2*A).dot(B) # Verify 3rd timestep✗
array([2.71828, 1. ])
Aliases
scipy.sparse.linalg.expm_multiply