# Extend SparseMatrixCSC interface (nzrange - rowvals - nonzeros) to views of sparse matrices

**URL:** <https://discourse.julialang.org/t/extend-sparsematrixcsc-interface-nzrange-rowvals-nonzeros-to-views-of-sparse-matrices/19837>\
**Category:** Numerics\
**Created:** [January 20, 2019, 10:23am UTC](https://discourse.julialang.org/t/extend-sparsematrixcsc-interface-nzrange-rowvals-nonzeros-to-views-of-sparse-matrices/19837 "2019-01-20T10:23:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [January 20, 2019, 10:23am UTC](https://discourse.julialang.org/t/extend-sparsematrixcsc-interface-nzrange-rowvals-nonzeros-to-views-of-sparse-matrices/19837/1 "2019-01-20T10:23:47Z")

</div>

I want to extend the `nzrange - rowvals - nonzeros` interface from `SparseMatrixCSC` to views of sparse matrices. That would allow to re-formulate many of the standard algorithms for `SparseMatrixCSC` and extend them to the views without further effort.

The existing exported functions `SparseArrays.nzrange` … are currently only defined for `SparseMatrixCSC`. Most existing algorithms for `SparseMatrixCSC` access the data fields `colptr`, `rowval` and `nzval` of `SparseMatrixCSC` directly. It would be easy to replace the access by calls to the interface functions. The implementations of these is trivial for `SparseMatrixCSC`. For a certain class of views of `SparseMatrixCSC` it is also possible to define the functions in a way, that makes the re-written algorithms working for the views as well. I think, that was the original idea for defining the interface functions, which was not completed yet.

At the same time, some unexported functions have been defined to access the fields (`getcolptr, getrowval, getnzval`), which are essentially equivalent to `nzrange, rowvals, nonzeros`, which could be deprecated.
