New answers tagged sparse-arrays
1
vote
2
votes
Nonzero element positions of a matrix
Using SequencePosition:
First /@ SequencePosition[#, {Except[0]}] & /@ m
{{1, 2}, {1, 3}}
2
votes
Nonzero element positions of a matrix
m = {{1, 2, 0}, {4, 0, 9}};
Flatten @* Values @* KeyDrop[0] @* PositionIndex /@ m
{1, 2}, {1, 3}}
Top 50 recent answers are included
Related Tags
sparse-arrays × 317matrix × 115
performance-tuning × 71
list-manipulation × 69
linear-algebra × 66
bugs × 23
memory × 12
eigenvalues × 12
parallelization × 8
export × 7
replacement × 7
crash × 7
import × 6
associations × 6
tensors × 6
functions × 5
graphs-and-networks × 5
finite-element-method × 5
librarylink × 5
differential-equations × 4
numerics × 4
pattern-matching × 4
algorithm × 4
data-structures × 4
matlab × 4