Tagged Questions

Questions on the construction and manipulation of sparse arrays in Mathematica, with functions like SparseArray[] and Band[].

484 views

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

A strange undocumented form of SparseArray is increasingly used in answers on this site: ...
1k views

Using the Krylov method for Solve: Speeding up a SparseArray calculation

I'm trying to implement this Total Variation Regularized Numerical Differentiation (TVDiff) code in MMA (which I found through this SO answer): essentially I want to differentiate noisy data. The full ...
159 views

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

I found a few references to something called a "pattern sparse array" that does not contain any values, only positions. What is this data structure? How and when do I use it? From the ...
1k views

Efficient way to combine SparseArray objects?

I have several SparseArray objects, say sa11, sa12, sa21, sa22, which I would like to combine into the equivalent of {{sa11, sa12}, {sa21, sa22}}. As an example, I ...
410 views

Sparse Cholesky Decomposition

I am working with square matrices with a special form, which for large rank ($> 100,000$) would be best stored and manipulated as a SparseArray. I believe that ...
182 views

Speeding up generation of block diagonal matrix

I'm struggling with the following problem. I have $48$ square matrices (full, filled with real machine precision numbers, thus are packed, all different) of size $128$. I wolud like to place them on a ...
294 views

Simple Matrix multiplication takes very long

Bug introduced in 10.1.0 and fixed in 10.3.0 I came across some strange behaviour during a computation involving matrices with symbolic values. It is reproduced below. Multiplying a random 30x30 ...
365 views

Adding three integer sparse matrices is very slow. Adding only two is fast

Bug introduced in 9.0.0 and fixed in 10.0.0 Adding more than two sparse matrices in one step in Mathematica 9 is very slow (in fact I couldn't even wait for it to finish). Here's an example. ...
768 views

232 views

Summing tensors in mathematica

How do I perform the following summation in mathematica? $$\Sigma_{m=1}^5 e_{ijklm}A^{mn}$$ I have the $e_{ijklm}$ tensor of rank 5 in 5 dimension as a array and $A^{mn}$ ...
113 views

SparseArray internal structure [duplicate]

According to the documentation: SparseArray is treated as a raw object by functions like AtomQ and for purposes of pattern ...
714 views

Finding elements from a sparse matrix

I am dealing sparse matrices of very large dimensions. I need to locate the positive and negative elements of the matrices and make lists of their corresponding positions. Of course I can write a ...
298 views

Constructing Tri-Diagonal Matrices

Fractional Calculus Course, we are instructed to create an $n \times n$ Tri-Diagonal matrix in the form of: \begin{array} a A &= \begin{bmatrix} 2 & -1 & 0 & 0 & ... ...
472 views

SparseArray row operations

Given a large (very) sparse matrix, A, how can I efficiently "operate" on only the nonzeros in a given row? For example: For each row in A, generate a list of column indices that have a magnitude ...
245 views

Upsampling matrix by inserting zeros inbetween elements

I want to essentially take an image with $n \times n$ pixels and expand it into a sparse array, spacing out the pixels by a factor $2$ or $3$. Each pixel in the input image occupies one of the corners ...
152 views

Problem with Conditionals: Why does mathematica add an extra empty list to my output

I have a set of positions where I want to slice a list of numbers. If I Total the values in that list, and they are greater than or equal to 1, I want to remember ...