# 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....
• 265k
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. ...
• 96.5k
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: ...
• 96.5k
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 ...
• 42.9k
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 ...
• 96.5k
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 ...
• 7,249
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)$$ ...
• 114k

### 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-...
• 96.5k
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 ...
• 96.5k
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 ...
• 42.9k
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 ...
• 63.6k
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. ...
• 96.5k

### 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: ...
• 125k
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 ...
• 36.8k

...
• 350k
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 ...
• 36.9k
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 ...
• 10.5k
Accepted

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

List @@ s will do the trick: ...
• 67.3k
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 ...
• 95.4k

### 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 ...
• 96.5k
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 ...
• 12.5k
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 ...
• 96.5k
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: ...
• 36.8k

### 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 ...
• 36.8k

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

Not faster, but maybe easier to implement ...
• 96.5k
Accepted

### Elegant method of generating this matrix?

Update: here Table is faster and more user-friendly then Array. ...
• 42.9k
Accepted

### When are sparse arrays effective?

You have shown that when the arrays are not sparse, using SparseArray is futile. Let's look at a case when it is sparse: ...
• 65.8k
Accepted

### Efficiently populate a Sparsearray for a set of rules for a constrained basis

There are a couple of things that can be improved: Binary search can simply be replaced by a lookup table that is very cheap to build. Moreover, IntegerPart[i/len] ...
• 96.5k

Only top scored, non community-wiki answers of a minimum length are eligible