matmul_toeplitz(c_or_cr, x, check_finite=False, workers=None)
This function returns the matrix multiplication between a Toeplitz matrix and a dense matrix.
The Toeplitz matrix has constant diagonals, with c as its first column and r as its first row. If r is not given, r == conjugate(c)
is assumed.
The Toeplitz matrix is embedded in a circulant matrix and the FFT is used to efficiently calculate the matrix-matrix product.
Because the computation is based on the FFT, integer inputs will result in floating point outputs. This is unlike NumPy's :None:None:`matmul`
, which preserves the data type of the input.
This is partly based on the implementation that can be found in , licensed under the MIT license. More information about the method can be found in reference . References and have more reference implementations in Python.
The vector c
, or a tuple of arrays ( c
, r
). Whatever the actual shape of c
, it will be converted to a 1-D array. If not supplied, r = conjugate(c)
is assumed; in this case, if c[0] is real, the Toeplitz matrix is Hermitian. r[0] is ignored; the first row of the Toeplitz matrix is [c[0], r[1:]]
. Whatever the actual shape of r
, it will be converted to a 1-D array.
Matrix with which to multiply.
Whether to check that the input matrices contain only finite numbers. Disabling may give a performance gain, but may result in problems (result entirely NaNs) if the inputs do contain infinities or NaNs.
To pass to scipy.fft.fft and ifft. Maximum number of workers to use for parallel computation. If negative, the value wraps around from os.cpu_count()
. See scipy.fft.fft for more details.
The result of the matrix multiplication T @ x
. Shape of return matches shape of x
.
Efficient Toeplitz Matrix-Matrix Multiplication using FFT
solve_toeplitz
Solve a Toeplitz system using Levinson Recursion
toeplitz
Toeplitz matrix
[ 1 -1 -2 -3] [1 10]
T = [ 3 1 -1 -2] x = [2 11]
[ 6 3 1 -1] [2 11] [10 6 3 1] [5 19]
To specify the Toeplitz matrix, only the first column and the first row are needed.
>>> c = np.array([1, 3, 6, 10]) # First column of T
... r = np.array([1, -1, -2, -3]) # First row of T
... x = np.array([[1, 10], [2, 11], [2, 11], [5, 19]])
>>> from scipy.linalg import toeplitz, matmul_toeplitz
... matmul_toeplitz((c, r), x) array([[-20., -80.], [ -7., -8.], [ 9., 85.], [ 33., 218.]])
Check the result by creating the full Toeplitz matrix and multiplying it by x
.
>>> toeplitz(c, r) @ x array([[-20, -80], [ -7, -8], [ 9, 85], [ 33, 218]])
The full matrix is never formed explicitly, so this routine is suitable for very large Toeplitz matrices.
>>> n = 1000000See :
... matmul_toeplitz([1] + [0]*(n-1), np.ones(n)) array([1., 1., 1., ..., 1., 1., 1.])
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.linalg._basic.matmul_toeplitz
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them