# Questions tagged [sparse-matrix]

Questions related to storage, assembly, operations, and other aspects of dealing with sparse matrices, for which only non-zero elements are stored. Questions that do not with sparse matrices directly, but other means of using sparsity should be tagged with [sparse-operator].

330 questions
Filter by
Sorted by
Tagged with
123 views

### what does cusparse<t>csrsv2_analysis() do?

In cuSPARSE, you can solve a sparse triangular linear system by calling cusparse<t>csrsv2_solve(). However, you need to call ...
336 views

### Fast way to build stiffness directly as CSC matrix

I have been working on finite element code in Fortran 2008, and have implemented my own sparse matrix types. I have found that mapping local stiffness matrices (real type) to a global COO sparse type ...
324 views

### How to delete $n^{th}$ row and $n^{th}$ column of a matrix K in Petsc and restructure it?

I have a matrix K in Petsc. I want to delete the $n^{th}$ row and $n^{th}$ column of this matrix and restructure it. I am a beginner in Petsc. Can you suggest how to do it? Example: I have matrix K ...
1k views

### Why is 'scipy.sparse.linalg.spilu' less efficient than 'scipy.linalg.lu' for sparse matrix?

I have a matrix B which is sparse and try to utilize a function scipy.sparse.linalg.spilu specialized for sparse matrix to ...
1k views

### Fast nonzero indices per row/column for (sparse) 2D numpy array

I am looking for the fastest way to obtain a list of the nonzero indices of a 2D array per row and per column. The following is a working piece of code: ...
274 views

### How to fill matrix entries for two-dimensional implicit finite-difference for the general case

If I have derived a finite-difference formula for a 2D problem, for example something like: $af_{i,j}+bf_{i-1,j}+cf_{i,j-1}+df_{i-1,j-1}=g_{i,j}$ where f is the unknown function on a grid and ...
1 vote
161 views

### Evaluating a quadratic form with an inverse of a sparse PD matrix, comparison between using the inverse vs using a Cholseky decomposition

I have the following quadratic form I need to evaluate: $x^T A^{-1} y$, where $A$ is a sparse positive definite matrix, $x, y$ are sparse vectors. Now assume that I am given for free both $A^{-1}$ ...
260 views

### Best way to convert a sparse (containing zeros) covariance matrix into a correlation matrix?

I have a $100$x$100$ covariance matrix that looks like this. Some rows/cols are all-zero because those corresponding elements are not present in the sample from which covariance is calculated. I'm ...
2k views

### How to reorder variables to produce a banded matrix of minimum bandwidth?

I'm trying to solve a 2D Poisson equation by finite differences. In the process, I obtain a sparse matrix with only $5$ variables in each equation. For example, if the variables were $U$, then the ...
596 views

### What is the algorithm to convert an adjacency matrix to a block diagonal structure?

I'm a little at loss as to what my supervisor meant by the "hierarchical block decomposition" of a matrix, but the goal is to put a sparse symmetric adjacency matrix into a block diagonal structure to ...
126 views

### How to determine the finite difference coefficient matrix in 2D with periodic BC?

I'm solving a PDE in matlab using ode15s, and since the spatial dimension is 2, and number of variables grow large very quickly, I need to supply the structure of ...
127 views

### What is the state-of-the-art in parallel sparse matrix and dense vector multiplication?

For sure, there has been many highly optimized library on this. But I am working on a matrix-free context since the problem size does not allow explicit storage of sparse matrix elements. I'd love ...
409 views

### Sparse matrix-matrix multiplication using AVX2

I have two sparse general matrices stored in CSR format I need to multiply. Is there any chance to gain performance using AVX2? In general the matrices are big (hundreds of millions of non-zeros and ...
1 vote
1k views

### How to compute all the eigenvalues of a large sparse matrix using matlab?

In matlab, there are 2 commands named "eig" for full matrices and "eigs" for sparse matrices to compute eigenvalues of a matrix. And eig(A) computes all the eigenvalues of a full matrix and eigs(A) ...
629 views

### Block-matrix: optimal fill-in reduction for LU factorization

Consider a square $N \times N$ block-matrix $\mathbf{A}$, where each $n \times n$ block $\mathbf{A}_{ii}$ is either a dense block or a zero-block. So, $N$ denotes the number of blocks, $n$ denotes the ...
131 views

### Matrix requirements for cusparse*csrgemm2

I would like to perform a matrix multiplication like: $C=A*B*A'$ using cusparse library function cusparseDcsrgemm2. To do this I split it into two matrix-matrix multiplications where all matrices ...
2k views

### Which SciPy nonlinear solver when Jacobian is analytically known and sparse?

I have a nonlinear function fun with n inputs and n outputs. I also have a function jac which calculates the Jacobian, which is ...
145 views

### CSC Sparse Matrices: Why sort row data for Ax=b problems?

I have a matrix in Coordinate format and I will convert it to CSC. As a reference, the format I am using looks like this, but I am not using the pointerE matrix, which I think is superfluous. My ...
651 views

### Assembling sparse matrix in PETSC for Poisson equation

I am a novice at PETSC, and I have been trying to write an FVM code for steady heat conduction in 2D using PETSC (square, regular grid, Dirichlet boundaries) Since the large matrix , say A, will be ...
1 vote
165 views

### How to understand the storage of the Hessenberg matrix of Krylov subspace matrix?

For the Krylov subspace method to solve the large sparse linear system, we first need to generate a subspace Km = span{v,Av,...A^{m-1}v}, which indeed a process ...
2k views

### Inverting really big symmetric block diagonal matrix

I have a really big symmetric 7.000.000 X 7.000.000 matrix that i would like to invert. The matrix is extremely sparse and it can be rearranged as to become a block diagonal matrix. The biggest blocks ...
3k views

### Eigen - store sparse matrix as binary

I need to store large sparse matrices in Eigen. I cannot find anything in the library except the function below, in Eigen/Unsupported. The problem with saveMarket is, that it saves in text format. Due ...
1 vote
79 views

### Numerical methods. MDF (ILU) implementation

I am trying to implement Minimum Discarded Fill (MDF) Ordering algorithm for incomplete matrix factorization. The algorithm description is here on page 60 Preconditioning Techniques for a Newton–...
1 vote
31 views

### Multibody Systems modeling disadvantages [closed]

Multibody Systems modeling is a very systematic approach usually results in large sparse Jacbian matrix. I am working to model a system consisting of 11 bodies and 63 constraint equations as soon as i ...
1 vote
258 views

### When should I write a matrix-vector function to handle the sparse matrix vector multiplication?

This semster, I have been studying the iterative methods for large sparse matrix system. But I have some questions. For large sparse matrix, we must use an economic storage to store them. The most ...
98 views

### Fast algorithm for computing lower mode shapes and natural frequencies in MATLAB using sparse stiffness and mass matrices

I am looking for a fast algorithm for computing eigenvalues and eigenvectors from sparse stiffness and mass matrices in MATLAB. The eig(K, M) doesn't work with ...
320 views

### What method to solve a sparse complex symmetric (non-Hermitian) system?

I have a sparse system (about 78% of zero entries) that is complex and symmetric (but not Hermitian). The following figure shows the structure of the problem. The off-diagonal blocks are incidence ...
311 views

### Is there any other sparse matrix data in matlab built-in file?

I want to do some numerical examples solving large sparse linear system Ax=b. And I want to use some data from Maltab itself because this experiments are easily ...
1 vote
135 views

922 views

### Sparse matrix format and sparse-matrix sparse-matrix multiplication

I'm having some performance problems with my code dealing with the multiplication of big sparse matrices (stiffness and aerodynamic influence coefficient matrices). Mainly I have to multiply such ...
I wanted to multiply two simple (big and sparse) matrix with numpy. And I saw that the calculation fails when matrices are too big. If i take $X$ a random vector (size $n$). With pandas, I ...
I am wondering how Dirichlet boundary conditions in global sparse finite element matrices are actually implemented efficiently. For example lets say that our global finite element matrix was: K = \...