
- SciPy - Home
- SciPy - Introduction
- SciPy - Environment Setup
- SciPy - Basic Functionality
- SciPy - Relationship with NumPy
- SciPy Clusters
- SciPy - Clusters
- SciPy - Hierarchical Clustering
- SciPy - K-means Clustering
- SciPy - Distance Metrics
- SciPy Constants
- SciPy - Constants
- SciPy - Mathematical Constants
- SciPy - Physical Constants
- SciPy - Unit Conversion
- SciPy - Astronomical Constants
- SciPy - Fourier Transforms
- SciPy - FFTpack
- SciPy - Discrete Fourier Transform (DFT)
- SciPy - Fast Fourier Transform (FFT)
- SciPy Integration Equations
- SciPy - Integrate Module
- SciPy - Single Integration
- SciPy - Double Integration
- SciPy - Triple Integration
- SciPy - Multiple Integration
- SciPy Differential Equations
- SciPy - Differential Equations
- SciPy - Integration of Stochastic Differential Equations
- SciPy - Integration of Ordinary Differential Equations
- SciPy - Discontinuous Functions
- SciPy - Oscillatory Functions
- SciPy - Partial Differential Equations
- SciPy Interpolation
- SciPy - Interpolate
- SciPy - Linear 1-D Interpolation
- SciPy - Polynomial 1-D Interpolation
- SciPy - Spline 1-D Interpolation
- SciPy - Grid Data Multi-Dimensional Interpolation
- SciPy - RBF Multi-Dimensional Interpolation
- SciPy - Polynomial & Spline Interpolation
- SciPy Curve Fitting
- SciPy - Curve Fitting
- SciPy - Linear Curve Fitting
- SciPy - Non-Linear Curve Fitting
- SciPy - Input & Output
- SciPy - Input & Output
- SciPy - Reading & Writing Files
- SciPy - Working with Different File Formats
- SciPy - Efficient Data Storage with HDF5
- SciPy - Data Serialization
- SciPy Linear Algebra
- SciPy - Linalg
- SciPy - Matrix Creation & Basic Operations
- SciPy - Matrix LU Decomposition
- SciPy - Matrix QU Decomposition
- SciPy - Singular Value Decomposition
- SciPy - Cholesky Decomposition
- SciPy - Solving Linear Systems
- SciPy - Eigenvalues & Eigenvectors
- SciPy Image Processing
- SciPy - Ndimage
- SciPy - Reading & Writing Images
- SciPy - Image Transformation
- SciPy - Filtering & Edge Detection
- SciPy - Top Hat Filters
- SciPy - Morphological Filters
- SciPy - Low Pass Filters
- SciPy - High Pass Filters
- SciPy - Bilateral Filter
- SciPy - Median Filter
- SciPy - Non - Linear Filters in Image Processing
- SciPy - High Boost Filter
- SciPy - Laplacian Filter
- SciPy - Morphological Operations
- SciPy - Image Segmentation
- SciPy - Thresholding in Image Segmentation
- SciPy - Region-Based Segmentation
- SciPy - Connected Component Labeling
- SciPy Optimize
- SciPy - Optimize
- SciPy - Special Matrices & Functions
- SciPy - Unconstrained Optimization
- SciPy - Constrained Optimization
- SciPy - Matrix Norms
- SciPy - Sparse Matrix
- SciPy - Frobenius Norm
- SciPy - Spectral Norm
- SciPy Condition Numbers
- SciPy - Condition Numbers
- SciPy - Linear Least Squares
- SciPy - Non-Linear Least Squares
- SciPy - Finding Roots of Scalar Functions
- SciPy - Finding Roots of Multivariate Functions
- SciPy - Signal Processing
- SciPy - Signal Filtering & Smoothing
- SciPy - Short-Time Fourier Transform
- SciPy - Wavelet Transform
- SciPy - Continuous Wavelet Transform
- SciPy - Discrete Wavelet Transform
- SciPy - Wavelet Packet Transform
- SciPy - Multi-Resolution Analysis
- SciPy - Stationary Wavelet Transform
- SciPy - Statistical Functions
- SciPy - Stats
- SciPy - Descriptive Statistics
- SciPy - Continuous Probability Distributions
- SciPy - Discrete Probability Distributions
- SciPy - Statistical Tests & Inference
- SciPy - Generating Random Samples
- SciPy - Kaplan-Meier Estimator Survival Analysis
- SciPy - Cox Proportional Hazards Model Survival Analysis
- SciPy Spatial Data
- SciPy - Spatial
- SciPy - Special Functions
- SciPy - Special Package
- SciPy Advanced Topics
- SciPy - CSGraph
- SciPy - ODR
- SciPy Useful Resources
- SciPy - Reference
- SciPy - Quick Guide
- SciPy - Cheatsheet
- SciPy - Useful Resources
- SciPy - Discussion
SciPy - matmul_toeplitz() Function
The scipy.linalg.matmul_toeplitz() function figures out the result of multiplying a Toeplitz matrix A with a vector or matrix x. It does this without creating the whole matrix. Instead, it takes advantage of how Toeplitz matrices are set up to use less memory and work faster.
This approach is helpful in areas where you often see Toeplitz matrices such as processing signals looking at data over time, and doing convolution tasks. It can handle inputs with one dimension or many dimensions, which means it's handy for all sorts of number-crunching jobs.
We can pair matmul_toeplitz() with toeplitz() to get a complete picture of the matrix and verify your results. For large-scale projects, you can boost speed by using the workers argument for parallel processing. It also works well with solve_toeplitz(), which finds answers to Toeplitz systems.
This method eliminates the need to construct the entire matrix by making use of the Toeplitz structure to make calculations faster. The workers parameter enables multi-threading making it suitable for big matrix jobs.
Syntax
Following is the syntax of the SciPy matmul_toeplitz() method −
.matmul_toeplitz(c_or_cr, x, check_finite=False, workers=None)
Parameters
Following are the parameters of matmul_toeplitz() method
c_or_cr − The Toeplitz matrix A is represented by its first column c and optionally its first row r. If a tuple (c,r) is provided, the first element of c and r must be the same to ensure consistency.
x − The vector or matrix to be multiplied by A.
check_finite − If True, checks if inputs contain only finite values. Disabling this can improve performance but risks errors if inputs are invalid. Default is False.
workers − Specifies the number of threads to use for parallel computation. Default is None, meaning a single thread.
Return Value
result (ndarray) − The result of the multiplication Ax.
Example 1
In the below example we have created a Toeplitz matrix using its first column.Instead of forming the full matrix, the matmul_toeplitz function directly computes the product of implicit matric and the vector.
import numpy as np import scipy.linalg from scipy.linalg import matmul_toeplitz # First column of the Toeplitz matrix c = [1, 2, 3] # Input vector x = [4, 5, 6] result = scipy.linalg.matmul_toeplitz(c, x) print(result)
When we run above program, it produces following result
[32. 25. 28.]
Example 2
This method bypasses the whole process of a matrix formation and effectively multiplies a Toeplitz matrix A with a vector x.
The following example shows how a multiplication of a vector with a Toeplitz matrix can be performed when the matrix is defined with its first column and row.
import numpy as np from scipy.linalg import matmul_toeplitz # Define the first column and row of the Toeplitz matrix c = np.array([2, -1, 0]) r = np.array([2, 3, 4]) # Define the vector x = np.array([1, 2, 3]) # Perform the multiplication result = matmul_toeplitz((c, r), x, check_finite=True) print("Result of A @ x:", result)
Following is an output of the above code
Result of A @ x: [20. 12. 4.]
Example 3
The function matmul_toeplitz() is highly efficient for large-scale matrix-matrix multiplications, particularly when the workers parameter allows for parallel computing.
To enhance computation speed, this example utilizes multiple threads to multiply a Toeplitz matrix A with a matrix X.
import numpy as np from scipy.linalg import matmul_toeplitz # Define the first column and row of the Toeplitz matrix c = np.array([3, 1, 2]) # First column r = np.array([3, 4, 5]) # First row # Define the matrix X = np.array([[1, 2], [3, 4], [5, 6]]) # Perform the multiplication with multi-threading result = matmul_toeplitz((c, r), X, workers=4) print("Result of A @ X:\n", result)
Output of the above code is as follows
Result of A @ X: [[40. 52.] [30. 38.] [20. 26.]]