# Tag Info

### What are SparseArray Properties? How and when should they be used?

Introduction This post is long overdue as I have been repeatedly asked to explain code of mine containing these things. As I see increased use of this construct by others perhaps it is past due also....
Accepted

### A geometric multigrid solver for Mathematica?

Background Details about multigrid solvers can be found in this pretty neat script by Volker John. That's basically the source from which I drew the information to implement the V-cycle solver below. ...
Accepted

### Complex eigenvalues from a sparse Hermitian matrix

Very good observation. Indeed, this issue is really frustrating. To single out the issue: It seems that Arnoldi's method is to blame: ...
Accepted

### Speeding up generation of block diagonal matrix

You are right, it can be done in a fraction of second. One can explicitly construct an array of indexes ...
Accepted

### Efficiently defining a SparseArray function

The way the code is written, you can neither exploit packed arrays nor any vectorization. There are two major reasons: Using Rule prevents using packed arrays ...
Accepted

### Sparse Cholesky Decomposition

LinearSolve[] actually computes a permuted Cholesky decomposition; that is, it performs the decomposition $\mathbf P^\top\mathbf A\mathbf P=\mathbf G^\top\mathbf G$....
Accepted

### Implementation of MATLAB's "numgrid" function

The source code of some of the MATLAB functions is available to its users. In this example, if you type edit numgrid, its file will be open, and to my surprise, it ...
Accepted

### Analytic determinant of a sparse 25x25 matrix?

Using the properties of Block matrices: $$\det\begin{pmatrix}\mathbf A&\mathbf B\\\mathbf C&\mathbf D\end{pmatrix}=\det(\mathbf A)\det\left(\mathbf D-\mathbf C\mathbf A^{-1}\mathbf B\right)$$ ...

### A geometric multigrid solver for Mathematica?

3D Example The problem with direct solvers is that starting in 3 dimensions, their performance for dealing with matrices stemming from PDEs drops rapidly. This is why I wanted to show at least one 3-...
Accepted

### Solving "Resistance between two nodes on a grid" problem in Mathematica

In addition to Carl Woll's post: Computing the pseudoinverse of a the graph Laplacian matrix (a.k.a. the KirchhoffMatrix) is very expensive and in general leads to ...
Accepted

### How to use SparseArray in CUDA?

Yes, it is possible! There is a WorframGPULibrary (WGL), which I discover recently. It is undocumented, however there are beautiful examples in ...
Accepted

### Quickly creating a sparse array

You can use the first documented usage for SparseArray: So what you want to do is collect all of the rules {i,j}->val before ...
Accepted

### Most efficient way to build block / banded SparseArray

This is definitely faster. It took me some time to figure out the combinatorics and there might still be some potential for improvement within the compiled functions. ...

### Solving "Resistance between two nodes on a grid" problem in Mathematica

Based on rcampion2012's answer to Efficient Implementation of Resistance Distance for graphs?, you could use: ...
Accepted

### What are pattern sparse arrays and how do I use them?

Pattern sparse arrays are used, for example, in NDSolve to specify the structure of a Jacobian. This can save significant time while integrating a differential equation. In other words pattern sparse ...

...
Accepted

### SparseArray output triggers "unsafe dynamic content" warning

In version 10 Wolfram introduced some dynamic panels in output objects. These are intended to provide some useful brief information (I guess) about what is stored. Because these panels are dynamic ...
Accepted

### Why won't SparseArray let me store values with the head List?

The basic reason is that once you convert a tensor expression into a SparseArray, you've "given control" of all levels of that expression to ...
Accepted

### How to convert a sparse matrix to a list of sparse arrays?

List @@ s will do the trick: ...
Accepted

### Why is IdentityMatrix not defined as a SparseArray by default?

The fastest way to get the identity matrix as a sparse array is simply this: IdentityMatrix[10000, SparseArray]; // AbsoluteTiming Here are just some thoughts on ...

### Using dense matrix is faster than sparse matrix in LinearSolve

You cannot benefit from SparseArray if your matrix is not sparse! The data structure storing a SparseArray needs a certain ...
Accepted

### Set every element to zero in matrix unless it's 1 or 1/2

Be careful with assigning a "form" (e.g. MatrixForm) to a variable. Another observation is that a is a ...
Accepted

### Reusing PARDISO symbolic factorization

No, this is not built-in and I have been waiting quite long for such a feature. PardisoLink With the help of Szabolcs's package "LTemplate`" I had written such an interface for the Intel MKL ...
Accepted

### How can I efficiently ArrayFlatten a matrix of sparse matrices?

Everything needs to be of the same precision including the background element. Then this: ...

### Speeding up generation of block diagonal matrix

There is an undocumented built-in solution: ...
Accepted

### What are valid settings for the TreatRepeatedEntries sparse array option?

The complete list is (V11.2) First or symbolic 0 Total or symbolic 1 List or symbolic 2 ...

### Most efficient way to build block / banded SparseArray

Not faster, but maybe easier to implement ...
Accepted

### Elegant method of generating this matrix?

Update: here Table is faster and more user-friendly then Array. ...