Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AbstractSparseMatrixCSC #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/SparseXX.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ using LinearAlgebra
using LinearAlgebra: AdjOrTrans
using SparseArrays

if isdefined(SparseArrays, :AbstractSparseMatrixCSC)
using SparseArrays: AbstractSparseMatrixCSC
else
const AbstractSparseMatrixCSC = AbstractSparseMatrix
end

using FillArrays
using SIMD

Expand Down
12 changes: 10 additions & 2 deletions src/matrix.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""
SparseXXMatrixCSC{Tv,Ti<:Integer} <: AbstractSparseMatrix{Tv,Ti}
SparseXXMatrixCSC{Tv,Ti<:Integer} <: AbstractSparseMatrixCSC{Tv,Ti}
"""
struct SparseXXMatrixCSC{Tv, Ti<:Integer,
Tc<:AbstractVector{Ti},
Tr<:AbstractVector{Ti},
Tz<:AbstractVector{Tv}} <: AbstractSparseMatrix{Tv,Ti}
Tz<:AbstractVector{Tv}} <: AbstractSparseMatrixCSC{Tv,Ti}
m::Int # Number of rows
n::Int # Number of columns
colptr::Tc # Column i is in colptr[i]:(colptr[i+1]-1)
Expand Down Expand Up @@ -71,6 +71,14 @@ SparseArrays.rowvals(S::SparseXXMatrixCSC) = S.rowval
Base.@propagate_inbounds SparseArrays.nzrange(S::SparseXXMatrixCSC, col::Integer) =
S.colptr[col]:(S.colptr[col+1]-1)

if isdefined(SparseArrays, :getcolptr)
SparseArrays.getcolptr(S::SparseXXMatrixCSC) = S.colptr
end

if isdefined(SparseArrays, :colptrs)
SparseArrays.colptrs(S::SparseXXMatrixCSC) = S.colptr
end


function Base.getindex(S::SparseXXMatrixCSC, i::Integer, j::Integer)
nzr = nzrange(S, j)
Expand Down