All Questions
Tagged with sparse-matrix matlab
442 questions
5
votes
1
answer
105
views
Efficient filtering of sparse matrix from full
I have a large, full, dense, symmetric matrix (eg 30k² or 60k² positive elements, ~100% density). I want to extract either (i) the top (eg) 1% highest values; or (2) the values above a user-specified ...
4
votes
1
answer
110
views
need to vectorize efficiently calculating only certain values in the matrix multiplication A * B, using a logical array L the size of A * B
I have matrices A (m by v) and B (v by n). I also have a logical matrix L (m by n).
I am interested in calculating only the values in A * B that correspond to logical values in L (values of 1s). ...
3
votes
2
answers
97
views
Fastest way to find first ZERO element of a sparse matrix
When using sparse matrices, it's easy to find non-zero entries quickly (as these are the only elements stored). However, what's the best way to find the first ZERO entry? Using approaches like find(X==...
0
votes
1
answer
98
views
Reading from MAT files(or similarly from other options) to CUDA/C
For a project I need sparse matrices retrieved from this website: https://www.cise.ufl.edu/research/sparse/matrices/list_by_id.html
Where matrices are in the form of .MAT and other formats which I am ...
2
votes
1
answer
43
views
Create blockwise shifted sparse matrix in matlab directly
I struggle to create a sparse matrix efficiently in matlab.
The problem looks like this:
Let's take a square matrix
a = 4;
b = 2;
t = rand(a,a);
What I want is equivalent to
P = sparse(kron(eye(a),...
0
votes
0
answers
63
views
Reodrering a massive sparse stiffness matrix
I have assembled a massive sparse stiffness matrix using its DOFs and some rules of assembly. In order to do an efficient Bragg scattering analysis, I would now like to reorder them based on 3 zones: ...
0
votes
1
answer
40
views
Eigenvalue Slowdown in Sparse Matrices
Is there conditions (besides just sparsity) regarding the structure or contents of a matrix that can lead to significant slowdown in eigenvalue calculations? Such as in eig or eigs in Matlab.
I'm ...
0
votes
0
answers
200
views
How to speed up the sparse matrix multiplication when using Eigen?
I need to use Eigen to do some huge sparse matrices multiplication or addition/subtraction. It is much slower than using MATLAB for some cases. For example, for the following code
Eigen::SparseMatrix&...
0
votes
1
answer
585
views
How to speed up the multiplication between a sparse matrix and a dense ndarray vector in SciPy
I am trying to speed up an algorithm. The bottleneck in the algorithm is computing "Ax", where, A is a large sparse-matrix with n X m dimension and x is a dense vector with m dimension.
My ...
1
vote
1
answer
69
views
Python correspondent for MATLAB matrix operation
I have a vector of indices (let's call it peo), a sparse matrix P and a matrix W. In MATLAB I can do an operation of this kind:
P(peo, peo) = W(peo, peo)
Is there a way to do the same in Python ...
0
votes
1
answer
105
views
function for language C which has same as sparse in Matlab
I want to assemble a lot of small local matrices into one global sparse matrix.
And also after assembly process I need another functions for deleting some specific row and column at the global sparse ...
0
votes
0
answers
101
views
Why is dense format better than sparse format for small sizes?
We consider the following code on Matlab with N an integer.
diag = 3*speye(N,N); % diagonal
subd=-sparse(2:N,1:N-1,1,N,N);
A=diag+subd+2*subd';
C=full(A);
If I am not wrong, sparse format ...
4
votes
2
answers
140
views
Sum of sparse vectors: bug or feature?
I recently stumbled upon the following behavior in MATLAB R2022a:
>> a = sparse(1,2,1)
a =
(1,2) 1
>> b = sparse(2,1,18)
b =
(2,1) 18
>> a+b
ans =
(2,1) ...
0
votes
2
answers
67
views
matlab spare matrix to python
I want to get a sparse matrix of dimension 16995 by 16995 in python. I have the syntax in matlab and I am not sure how can I write in python to get the same syntax as well as the output like matlab.
...
2
votes
2
answers
78
views
How to change all matrix values according to a list
I have a 500x500 sparse matrix with values ranging from 0 to a.
I want to change its elements according to a list working as a dictionary. Elements that equal 1 become the value of list(1), that equal ...