The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [sparse-arrays]

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

234 questions
Filter by
Sorted by
Tagged with
22 views

Filling Regions (Blocks) of a Binary Matrix with Different Probabilities

This is an extension of the following question: How to generate binary array whose elements with values 1 are randomly drawn, where the most elegant answer was posted in the comments: ...
82 views

Efficiently calculating matrix exponential of a recursively generated matrix

Given a matrix $A$ of size $N \times N$, I want to evaluate the function \begin{equation} F(t) = |Tr(\exp^{-i A t})|^2 \end{equation} as a function of $t$. Here, $A[n]$ is constructed recursively ...
39 views

Efficient Linear Operators on SparseArrays

I have a rank four SparseArray of dimension {40, 40, 40, 40}. I wish to apply a linear operator to it, whose form I know abstractly. That is, I have a simple closed form for the action of the operator ...
63 views

How to RowReduce a sparse matrix?

I want to compute the reduced row echelon form of a sparse matrix, but RowReduce returns a dense matrix. Is there a build-in function that computes the reduced form ...
98 views

Sparse matrix processing: flip sign of top-left entries of the matrix

I have a 12k X 12k sparse array (~1% density) and I need to: take the square root of all the elements flip the sign of all the elements in the top-left half of the matrix For example, say that the ...
97 views

Finding the null space of a large sparse matrix

I am trying to compute the null space of a large $n\times n$ sparse matrix. No matter how large the dimension of the matrix is, it will always look like as below: The figure on the left shows the ...
63 views

ParametricNDSolveValue with SparseArrays

I want to solve large, sparse matrix systems with ParametricNDSolveValue and was hoping to use SparseArray to speed up the computation. However I find that ParametricNDSolveValue doesn't seem to work ...
64 views

Signed cell adjacency matrices (boundary operators)

In How to obtain the cell-adjacency graph of a mesh? there are some great answers that show how to obtain the cell adjacency matrix of a mesh. How would one generalize these to incorporate the ...
374 views

Efficiently defining a SparseArray function

I've got a fairly large SparseMatrix (~60,000 entries in a ~10,000-by-10,000 matrix) that depends on two parameters (im1 and <...
131 views

461 views

Replace diagonal elements in sparse matrix

I am interested in replacing all elements in a diagonal of a sparse matrix with zero. Currently, I do it in the following manner: ...
362 views

How to find k largest element and their position in a matrix?

I have a sparse matrix, and I am interested in find k largest elements and their positions in the matrix. I do it in the following manner: ...
96 views

Optimization of a slow function - reason to why it is slow

Edit: Okay, my question was viewed quite a few times but not answered so I assume I phrased/presented in a confusing way. I'll try to rephrase my problem to make it more accessible because luckily I ...
106 views

Efficiently fill sparse matrix involving BSpline

Context In order to implement regularised fitting in 2 or 3 dimensions (as is done say here) using BSplineBasis one needs to evaluate a basis over a set of data. ...