# \#sparse

**URL:** https://discourse.julialang.org/tag/sparse/368.md?page=3

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 4

---

## [How to output selective elements from Matrix?](https://discourse.julialang.org/t/how-to-output-selective-elements-from-matrix/85110)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 11\
**Last updated:** [August 2, 2022, 7:29pm UTC](https://discourse.julialang.org/t/how-to-output-selective-elements-from-matrix/85110 "2022-08-02T19:29:36Z")

</div>

I have the below configuration. I am trying to output selective elements from matrix L.sl based on values of L.Seg. More specifically, I want to write syntax such as L.sl\[L.Seg\] to give me the same results as S. Any simp…

---

## [How to build this sparsematrix in Julia](https://discourse.julialang.org/t/how-to-build-this-sparsematrix-in-julia/84608)

<div class="topic-metadata">

**Author:** [@Amro](https://discourse.julialang.org/u/Amro)\
**Replies:** 43\
**Last updated:** [July 30, 2022, 3:27pm UTC](https://discourse.julialang.org/t/how-to-build-this-sparsematrix-in-julia/84608 "2022-07-30T15:27:24Z")

</div>

I have the below command in Matlab, I could not find how to do it in Julia. Any suggestion please? sparse((1:5)', \[11,22,33,44,55\], \[1,2,3,4,5\])

---

## [\[ANN\] Fast SpMv with CompressedSparseBlocks.jl](https://discourse.julialang.org/t/ann-fast-spmv-with-compressedsparseblocks-jl/84680)

<div class="topic-metadata">

**Author:** [@pitsianis](https://discourse.julialang.org/u/pitsianis)\
**Replies:** 9\
**Last updated:** [July 26, 2022, 1:01pm UTC](https://discourse.julialang.org/t/ann-fast-spmv-with-compressedsparseblocks-jl/84680 "2022-07-26T13:01:51Z")

</div>

If you have a computation with an iteration where the time is dominated by a large sparse matrix multiplication, julia\> using LinearAlgebra, SparseArrays, BenchmarkTools julia\> n = 2^22; d = 10; A = sprand(n,n,d/n); x …

---

## [Weighted graph using SparseCSC julia](https://discourse.julialang.org/t/weighted-graph-using-sparsecsc-julia/84071)

<div class="topic-metadata">

**Author:** [@ayodyas](https://discourse.julialang.org/u/ayodyas)\
**Replies:** 8\
**Last updated:** [July 19, 2022, 7:31am UTC](https://discourse.julialang.org/t/weighted-graph-using-sparsecsc-julia/84071 "2022-07-19T07:31:43Z")

</div>

I am new to julia and was trying to do weighted graph partition using metis in Julia. I coudnt undertstand how the SparseCSc for graph creation with edge and vertex weight as required for format of the metis (graph parti…

---

## [Sparse jacobians of matrix models](https://discourse.julialang.org/t/sparse-jacobians-of-matrix-models/82537)

<div class="topic-metadata">

**Author:** [@gianmariomanca](https://discourse.julialang.org/u/gianmariomanca)\
**Replies:** 37\
**Last updated:** [July 3, 2022, 6:16pm UTC](https://discourse.julialang.org/t/sparse-jacobians-of-matrix-models/82537 "2022-07-03T18:16:47Z")

</div>

Hi all, I would like to use sparsity to speed up an optimization problem. I have a NxM matrix of data Z and a model m(A) = A - k\*sum(A, dims=2)\*sum(A,dims=1) where A is a matrix of the same dimensions of Z, sum(A, dims…

---

## [Bug with initializing extra rows in sparse arrays](https://discourse.julialang.org/t/bug-with-initializing-extra-rows-in-sparse-arrays/83594)

<div class="topic-metadata">

**Author:** [@jsbryan4](https://discourse.julialang.org/u/jsbryan4)\
**Replies:** 1\
**Last updated:** [July 1, 2022, 2:36am UTC](https://discourse.julialang.org/t/bug-with-initializing-extra-rows-in-sparse-arrays/83594 "2022-07-01T02:36:59Z")

</div>

I found what I believe to be a bug in SparseArrays. If I try to make a sparse array with more rows than the max row number It fails with the error: 11×10 SparseMatrixCSC{Any, Int64} with 100 stored entries: ERROR: Metho…

---

## [How to add Padding/Zero Rows to OneHotArray in Flux](https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239)

<div class="topic-metadata">

**Author:** [@Jack\_N](https://discourse.julialang.org/u/Jack_N)\
**Replies:** 1\
**Last updated:** [June 28, 2022, 10:42pm UTC](https://discourse.julialang.org/t/how-to-add-padding-zero-rows-to-onehotarray-in-flux/83239 "2022-06-28T22:42:23Z")

</div>

The input data to my model is 1-hot encoded, and of different lengths, and it is 3D. Therefore it must be represented with a sparse datatype and padded to the same length. Currently, I am using multidimensional Flux One…

---

## [Solving Sparse Linear Systems fast](https://discourse.julialang.org/t/solving-sparse-linear-systems-fast/83071)

<div class="topic-metadata">

**Author:** [@pushkar\_khandare](https://discourse.julialang.org/u/pushkar_khandare)\
**Replies:** 11\
**Last updated:** [June 23, 2022, 11:22am UTC](https://discourse.julialang.org/t/solving-sparse-linear-systems-fast/83071 "2022-06-23T11:22:30Z")

</div>

I want to solve Ax = b where A is a sparse matrix of size 10^5 x 10^5 (around 18 non-zero entries per row), x and b are vectors. A is constant throughout my simulation, while b changes at every step in my loop, and I hav…

---

## [CUDA.jl - Memory Efficient Operations, Manipulations and Calculations on Large Sparse Arrays](https://discourse.julialang.org/t/cuda-jl-memory-efficient-operations-manipulations-and-calculations-on-large-sparse-arrays/83091)

<div class="topic-metadata">

**Author:** [@moukann](https://discourse.julialang.org/u/moukann)\
**Replies:** 6\
**Last updated:** [June 21, 2022, 7:54pm UTC](https://discourse.julialang.org/t/cuda-jl-memory-efficient-operations-manipulations-and-calculations-on-large-sparse-arrays/83091 "2022-06-21T19:54:00Z")

</div>

Hello all, I formerly created this topic, my problem is continuing until this day: The problem is related to GPU RAM and its size. The global system is a square matrix, consisting of Float64 values. However, it is mos…

---

## [Contents of the function run well when timed alone, but not when they are in a loop inside the function](https://discourse.julialang.org/t/contents-of-the-function-run-well-when-timed-alone-but-not-when-they-are-in-a-loop-inside-the-function/76886)

<div class="topic-metadata">

**Author:** [@ayushinav](https://discourse.julialang.org/u/ayushinav)\
**Replies:** 8\
**Last updated:** [May 31, 2022, 5:02am UTC](https://discourse.julialang.org/t/contents-of-the-function-run-well-when-timed-alone-but-not-when-they-are-in-a-loop-inside-the-function/76886 "2022-05-31T05:02:21Z")

</div>

Hello all, I am new to Julia and have been making progress with implementing its performance utilities. Generally, I am able to get some results or an understanding of how things are going, but not in this case. The fol…

---

## [Julia can't solve sparse linear system, MATLAB can](https://discourse.julialang.org/t/julia-cant-solve-sparse-linear-system-matlab-can/81692)

<div class="topic-metadata">

**Author:** [@Arrigo\_Benedetti](https://discourse.julialang.org/u/Arrigo_Benedetti)\
**Replies:** 5\
**Last updated:** [May 26, 2022, 10:12pm UTC](https://discourse.julialang.org/t/julia-cant-solve-sparse-linear-system-matlab-can/81692 "2022-05-26T22:12:46Z")

</div>

I am trying to solve a sparse linear system, but Julia 1.7.2 crashes (I believe it’s an OutOfMemoryError()): infil\> size(A) (2938746, 6906) infil\> nnz(A) 17591409 infil\> nnz(A)/prod(size(A)) 0.0008667862253365853 inf…

---

## [How to efficiently construct a large SparseArray? Packages for this?](https://discourse.julialang.org/t/how-to-efficiently-construct-a-large-sparsearray-packages-for-this/64863)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 20\
**Last updated:** [May 15, 2022, 12:16pm UTC](https://discourse.julialang.org/t/how-to-efficiently-construct-a-large-sparsearray-packages-for-this/64863 "2022-05-15T12:16:10Z")

</div>

Problem Does Julia have an efficient way of constructing a huge sparse matrix from a given list of entries u,v,w, some of which can have the same locations u,v, and in that case, their weights w must be summed. Thus u,v,…

---

## [Products of sparse by dense matrices don't revert to specialized methods](https://discourse.julialang.org/t/products-of-sparse-by-dense-matrices-dont-revert-to-specialized-methods/80894)

<div class="topic-metadata">

**Author:** [@Arrigo\_Benedetti](https://discourse.julialang.org/u/Arrigo_Benedetti)\
**Replies:** 1\
**Last updated:** [May 11, 2022, 3:58pm UTC](https://discourse.julialang.org/t/products-of-sparse-by-dense-matrices-dont-revert-to-specialized-methods/80894 "2022-05-11T15:58:40Z")

</div>

Apparently in 1.7.2 the product of a sparse (SparseMatrixCSC) and a dense matrix (both directions) never use the specialized method. Looking at this old discussion it seems that at least the sparse by dense product shou…

---

## [Feedback for efficiency of Sparse Matrix operations](https://discourse.julialang.org/t/feedback-for-efficiency-of-sparse-matrix-operations/80362)

<div class="topic-metadata">

**Author:** [@danielw2904](https://discourse.julialang.org/u/danielw2904)\
**Replies:** 7\
**Last updated:** [May 2, 2022, 4:24pm UTC](https://discourse.julialang.org/t/feedback-for-efficiency-of-sparse-matrix-operations/80362 "2022-05-02T16:24:57Z")

</div>

This is my first time working with SparseArrays in Julia. I needed a few operations and was wondering if I am as efficient as I can be. I do want to preserve the original matrices (explicitly not doing anything in-place)…

---

## [Best current approach for working with sparse tensors?](https://discourse.julialang.org/t/best-current-approach-for-working-with-sparse-tensors/79937)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 2\
**Last updated:** [April 24, 2022, 3:11pm UTC](https://discourse.julialang.org/t/best-current-approach-for-working-with-sparse-tensors/79937 "2022-04-24T15:11:09Z")

</div>

I would like to hear ideas about how to work with this kind of application right now in Julia. Some previous posts seem to be in line with what I’m looking for, but I’m not sure what’s the conclusion, and what’s the stat…

---

## [Pivoting in sparse QR](https://discourse.julialang.org/t/pivoting-in-sparse-qr/79306)

<div class="topic-metadata">

**Author:** [@00shiv](https://discourse.julialang.org/u/00shiv)\
**Replies:** 6\
**Last updated:** [April 11, 2022, 3:11am UTC](https://discourse.julialang.org/t/pivoting-in-sparse-qr/79306 "2022-04-11T03:11:43Z")

</div>

I have a skinny sparse matrix that I have taken care to order its rows and columns in such a way as to ensure that the sparse QR factorization should be fast \[O(n) space and time\]. However when I call qr in Julia 1.7.2 i…

---

## [CUDA.jl - Atomic Addition Error To A Sparse Array Inside CUDA Kernel](https://discourse.julialang.org/t/cuda-jl-atomic-addition-error-to-a-sparse-array-inside-cuda-kernel/78789)

<div class="topic-metadata">

**Author:** [@moukann](https://discourse.julialang.org/u/moukann)\
**Replies:** 4\
**Last updated:** [March 31, 2022, 11:18am UTC](https://discourse.julialang.org/t/cuda-jl-atomic-addition-error-to-a-sparse-array-inside-cuda-kernel/78789 "2022-03-31T11:18:47Z")

</div>

Hello all, I am trying to assemble many individual elements of a huge system to a global system. The global system is sparse, It is a certain thing. Also it is wasteful to store all zero elements in memory, I just need …

---

## [Drop specific elements of sparse arrays](https://discourse.julialang.org/t/drop-specific-elements-of-sparse-arrays/78583)

<div class="topic-metadata">

**Author:** [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Replies:** 0\
**Last updated:** [March 28, 2022, 3:58am UTC](https://discourse.julialang.org/t/drop-specific-elements-of-sparse-arrays/78583 "2022-03-28T03:58:59Z")

</div>

Hi, I was wondering if it is possible to drop the i-th element of a sparse vector x (i.e., setting it to zero) in-place. I am aware that you can do something like x\[i\]=0.0; dropzeros!(x), but I was wondering if there is…

---

## [Column pointers of sparse array in case of empty columns](https://discourse.julialang.org/t/column-pointers-of-sparse-array-in-case-of-empty-columns/77924)

<div class="topic-metadata">

**Author:** [@mmeer](https://discourse.julialang.org/u/mmeer)\
**Replies:** 1\
**Last updated:** [March 15, 2022, 6:28pm UTC](https://discourse.julialang.org/t/column-pointers-of-sparse-array-in-case-of-empty-columns/77924 "2022-03-15T18:28:46Z")

</div>

Hi there, I’ve noticed something that isn’t well-documented imho. When a sparse matrix has an empty column i, what is colptr\[i\]? Example: sparse(Matrix(S)) 3×3 SparseMatrixCSC{Float64, Int64} with 3 stored entries: …

---

## [Operation between two large N-dimensional arrays](https://discourse.julialang.org/t/operation-between-two-large-n-dimensional-arrays/77141)

<div class="topic-metadata">

**Author:** [@Tzaki](https://discourse.julialang.org/u/Tzaki)\
**Replies:** 2\
**Last updated:** [February 27, 2022, 10:41am UTC](https://discourse.julialang.org/t/operation-between-two-large-n-dimensional-arrays/77141 "2022-02-27T10:41:10Z")

</div>

Hello, I am pretty much new to Julia. I am now trying to do an operation between two large N-dimensional sparse arrays of the same size (typically something like 8-dimensional array with 5 to 10 elements for each dimens…

---

## [How to construct non-square sparse matrix with multiple diagonals](https://discourse.julialang.org/t/how-to-construct-non-square-sparse-matrix-with-multiple-diagonals/76456)

<div class="topic-metadata">

**Author:** [@jinml](https://discourse.julialang.org/u/jinml)\
**Replies:** 6\
**Last updated:** [February 14, 2022, 11:56pm UTC](https://discourse.julialang.org/t/how-to-construct-non-square-sparse-matrix-with-multiple-diagonals/76456 "2022-02-14T23:56:40Z")

</div>

I need to construct a non-square (N by N+2) matrix with 3 diagonal vectors of length N each, I can’t seem to use Tridiagonal(vsub,v0,vsuper) as this function wants to form a square matrix. What is the function that does …

---

## [Performance of large sparse discrete map problems in DifferentialEquations](https://discourse.julialang.org/t/performance-of-large-sparse-discrete-map-problems-in-differentialequations/76382)

<div class="topic-metadata">

**Author:** [@roryh](https://discourse.julialang.org/u/roryh)\
**Replies:** 8\
**Last updated:** [February 14, 2022, 2:12pm UTC](https://discourse.julialang.org/t/performance-of-large-sparse-discrete-map-problems-in-differentialequations/76382 "2022-02-14T14:12:55Z")

</div>

Hello, I normally deal with dynamics on networks, so I have giant sparse systems of coupled ODE’s. The problem I have at the moment is that for a simple discrete map, a naive implementation is significantly faster than …

---

## [Antisymmetric matrices?](https://discourse.julialang.org/t/antisymmetric-matrices/75829)

<div class="topic-metadata">

**Author:** [@akriegman](https://discourse.julialang.org/u/akriegman)\
**Replies:** 4\
**Last updated:** [February 5, 2022, 10:14pm UTC](https://discourse.julialang.org/t/antisymmetric-matrices/75829 "2022-02-05T22:14:57Z")

</div>

The LinearAlgebra module in the standard library has several special matrix types which represent various sparse matrix types, like symmetric or upper-triangular. This allows for reduced memory usage as you can avoid sto…

---

## [Sparsity Detection in Jacobian](https://discourse.julialang.org/t/sparsity-detection-in-jacobian/75756)

<div class="topic-metadata">

**Author:** [@ziolai](https://discourse.julialang.org/u/ziolai)\
**Replies:** 1\
**Last updated:** [February 4, 2022, 4:53pm UTC](https://discourse.julialang.org/t/sparsity-detection-in-jacobian/75756 "2022-02-04T16:53:11Z")

</div>

When trying to run https://diffeq.sciml.ai/stable/tutorials/advanced\_ode\_example/#Declaring-a-Sparse-Jacobian-with-Automatic-Sparsity-Detection I obtain MethodError: no method matching jacobian\_sparsity(::var"#7#8", :…

---

## [Computation of eigenvalues of a sparse matrix that is given by a file in COO format](https://discourse.julialang.org/t/computation-of-eigenvalues-of-a-sparse-matrix-that-is-given-by-a-file-in-coo-format/75214)

<div class="topic-metadata">

**Author:** [@Eustace](https://discourse.julialang.org/u/Eustace)\
**Replies:** 5\
**Last updated:** [January 27, 2022, 7:35am UTC](https://discourse.julialang.org/t/computation-of-eigenvalues-of-a-sparse-matrix-that-is-given-by-a-file-in-coo-format/75214 "2022-01-27T07:35:31Z")

</div>

Hi everyone, I am pretty new to Julia, and I would appreciate your help in the following. I have a complex, non-symmetric yet sparse matrix (800,000x800,000 with ~10M nnz) that is stored in a file in COO format, i.e., …

---

## [Matrix multiplication of a view of QR.Q with Vector{VariableRef} is slow](https://discourse.julialang.org/t/matrix-multiplication-of-a-view-of-qr-q-with-vector-variableref-is-slow/74480)

<div class="topic-metadata">

**Author:** [@Thomas](https://discourse.julialang.org/u/Thomas)\
**Replies:** 6\
**Last updated:** [January 12, 2022, 3:17pm UTC](https://discourse.julialang.org/t/matrix-multiplication-of-a-view-of-qr-q-with-vector-variableref-is-slow/74480 "2022-01-12T15:17:55Z")

</div>

To assist with formulating a JuMP model for an SDP, I need to create affine expressions y (then the objectives and constraints can be cheaply constructed by getindex into y): F = qr(m::SparseMatrixCSC) # call to SuiteSp…

---

## [Improving performance on nested for loops (SparseArrays, LibGEOS)](https://discourse.julialang.org/t/improving-performance-on-nested-for-loops-sparsearrays-libgeos/74038)

<div class="topic-metadata">

**Author:** [@nbalasus](https://discourse.julialang.org/u/nbalasus)\
**Replies:** 10\
**Last updated:** [January 7, 2022, 4:41am UTC](https://discourse.julialang.org/t/improving-performance-on-nested-for-loops-sparsearrays-libgeos/74038 "2022-01-07T04:41:15Z")

</div>

I have two arrays of polygons, one with 9,000,000 polygons and the other with 60,000 polygons. I would like to find the intersecting area of each of these. In the MWE example below where I have reduced the example to 201…

---

## [Inversion and multiplication of sparse matrices](https://discourse.julialang.org/t/inversion-and-multiplication-of-sparse-matrices/73819)

<div class="topic-metadata">

**Author:** [@Rajesh\_Nakka](https://discourse.julialang.org/u/Rajesh_Nakka)\
**Replies:** 7\
**Last updated:** [December 30, 2021, 9:52pm UTC](https://discourse.julialang.org/t/inversion-and-multiplication-of-sparse-matrices/73819 "2021-12-30T21:52:21Z")

</div>

I have encountered a problem of the following kind. C = A^-1 \* B where A is a very large nxn sparse banded symmetric matrix (of SparseMatrixCSC type) and B is nx5 matrix. I have read on this forum and somewhere else…

---

## [CUDA porting to shift-inverse eigenvalues](https://discourse.julialang.org/t/cuda-porting-to-shift-inverse-eigenvalues/73691)

<div class="topic-metadata">

**Author:** [@albertomercurio](https://discourse.julialang.org/u/albertomercurio)\
**Replies:** 0\
**Last updated:** [December 28, 2021, 12:26am UTC](https://discourse.julialang.org/t/cuda-porting-to-shift-inverse-eigenvalues/73691 "2021-12-28T00:26:22Z")

</div>

The Arpack eigenvalues solver is very fast. With a 100000x100000 sparse matrix, I can get a few eigenvalues with the shift-invert method in 20-30 seconds approximately! Since I always want the best performances, I wonde…

---

## [MATLABs \`sprandsym\` in Julia](https://discourse.julialang.org/t/matlabs-sprandsym-in-julia/72251)

<div class="topic-metadata">

**Author:** [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Replies:** 1\
**Last updated:** [November 29, 2021, 6:50pm UTC](https://discourse.julialang.org/t/matlabs-sprandsym-in-julia/72251 "2021-11-29T18:50:39Z")

</div>

Hello everyone! I need a function that generates a random sparse matrix of size (n,n) with the following properties: issymmetric isposdef has approximately p \* n^2 non-zero elements (for given p) has a condition numbe…

[Previous page](https://discourse.julialang.org/tag/sparse/368.md?match_all_tags=true&page=2&tags%5B%5D=sparse)

[Next page](https://discourse.julialang.org/tag/sparse/368.md?match_all_tags=true&page=4&tags%5B%5D=sparse)
