Skip to content

Commit facc207

Browse files
authored
Merge pull request #27 from gridap/release-0.6.8
Release 0.6.8
2 parents 18ef38f + 06b4343 commit facc207

File tree

10 files changed

+115
-36
lines changed

10 files changed

+115
-36
lines changed

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/" # Location of package manifests
6+
schedule:
7+
interval: "monthly"

.github/workflows/ci.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,37 @@ jobs:
88
fail-fast: false
99
matrix:
1010
version:
11+
- '1.8'
1112
- '1.9'
13+
- '1.10'
1214
os:
1315
- ubuntu-latest
16+
- windows-latest
1417
arch:
1518
- x64
1619
steps:
17-
- uses: actions/checkout@v2
18-
- uses: julia-actions/setup-julia@v1
20+
- uses: actions/checkout@v4
21+
- uses: julia-actions/setup-julia@v2
1922
with:
2023
version: ${{ matrix.version }}
2124
arch: ${{ matrix.arch }}
22-
- uses: actions/cache@v1
23-
env:
24-
cache-name: cache-artifacts
25-
with:
26-
path: ~/.julia/artifacts
27-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
28-
restore-keys: |
29-
${{ runner.os }}-test-${{ env.cache-name }}-
30-
${{ runner.os }}-test-
31-
${{ runner.os }}-
25+
- uses: julia-actions/cache@v2
3226
- uses: julia-actions/julia-buildpkg@v1
3327
- uses: julia-actions/julia-runtest@v1
3428
- uses: julia-actions/julia-processcoverage@v1
35-
- uses: codecov/codecov-action@v1
29+
- uses: codecov/codecov-action@v4
3630
with:
3731
file: lcov.info
32+
verbose: true
33+
3834
docs:
3935
name: Documentation
4036
runs-on: ubuntu-latest
4137
steps:
4238
- uses: actions/checkout@v2
4339
- uses: julia-actions/setup-julia@v1
4440
with:
45-
version: '1.9'
41+
version: '1.10'
4642
- run: |
4743
julia --project=docs -e '
4844
using Pkg
@@ -52,3 +48,30 @@ jobs:
5248
env:
5349
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5450
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
51+
52+
downgrade:
53+
name: Downgrade ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
version:
59+
- '1.10'
60+
os:
61+
- ubuntu-latest
62+
arch:
63+
- x64
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: julia-actions/setup-julia@v2
67+
with:
68+
version: ${{ matrix.version }}
69+
arch: ${{ matrix.arch }}
70+
- uses: julia-actions/cache@v2
71+
- uses: julia-actions/julia-downgrade-compat@v1
72+
with: # As per documentation, we exclude packages within the Julia standard library
73+
skip: LinearAlgebra,SparseArrays
74+
- uses: julia-actions/julia-buildpkg@v1
75+
- uses: julia-actions/julia-runtest@v1
76+
with:
77+
coverage: false

NEWS.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
# Changelog
2+
23
All notable changes to this project will be documented in this file.
34

45
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
56
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
67

78
## [0.6.8] - 2024.08.29
89

10+
### Added
11+
12+
- Added `SparseMatrixCSC` and `AbstractMatrix` constructors.
13+
914
### Fixed
10-
- Fixed show method for SparseMatrixCSR
15+
16+
- Fixed show method for SparseMatrixCSR.
17+
- Fixes related to `TransposeFactorization` (see https://github.com/JuliaLang/julia/pull/46874).
1118

1219
## [0.6.6] - 2021.11.26
1320

1421
### Added
22+
1523
- Implemented `Base.setindex!`.
1624

1725
## [0.6.5] - 2021.10.20
1826

1927
### Fixed
28+
2029
- Return value of `LinearAlbegra.fillstored!`.
2130

2231
### Added
32+
2333
- Implemented `LinearAlbegra.rmul!`.
2434

2535
## [0.6.4] - 2021.10.20
2636

2737
### Added
38+
2839
- Implemented `LinearAlbegra.fillstored!`.
2940

3041
*Previous releases are not included in this Changelog*

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ Sparse matrices in CSR format (symmetric and non-symmetric) for Julia computatio
77
| [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://gridap.github.io/SparseMatricesCSR.jl/stable) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://gridap.github.io/SparseMatricesCSR.jl/dev) |
88
|**Build Status** |
99
| [![Build Status](https://github.com/gridap/SparseMatricesCSR.jl/workflows/CI/badge.svg?branch=master)](https://github.com/gridap/SparseMatricesCSR.jl/actions?query=workflow%3ACI) [![Codecov](https://codecov.io/gh/gridap/SparseMatricesCSR.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/gridap/SparseMatricesCSR.jl) |
10-
11-

docs/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Manifest.toml
2+
build

docs/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3+
DocumenterInterLinks = "d12716ef-a0f6-4df4-a9f1-a5a34e75c656"
34
SparseMatricesCSR = "a0a7dd2c-ebf4-11e9-1f05-cf50bc540ca1"

docs/make.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
using Documenter, SparseMatricesCSR
1+
using Documenter, DocumenterInterLinks
2+
using SparseMatricesCSR
3+
4+
links = InterLinks(
5+
"SparseArrays" => "https://docs.julialang.org/en/v1/"
6+
)
27

38
makedocs(;
49
modules=[SparseMatricesCSR],
@@ -9,6 +14,7 @@ makedocs(;
914
repo="https://github.com/gridap/SparseMatricesCSR.jl/blob/{commit}{path}#L{line}",
1015
sitename="SparseMatricesCSR.jl",
1116
authors="Víctor Sande <[email protected]> and Francesc Verdugo <[email protected]>",
17+
plugins=[links],
1218
)
1319

1420
deploydocs(;

src/SparseMatricesCSR.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using SuiteSparse
66

77
import Base: convert, copy, size, getindex, setindex!, show, count, *, IndexStyle
88
import LinearAlgebra: mul!, lu, lu!
9-
import SparseArrays: nnz, getnzval, nonzeros, nzrange
9+
import SparseArrays: nnz, getnzval, nonzeros, nzvalview, nzrange
1010
import SparseArrays: findnz, rowvals, getnzval, issparse
1111

1212
export SparseMatrixCSR

src/SparseMatrixCSR.jl

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ function SparseMatrixCSR(a::Transpose{Tv,<:SparseMatrixCSC} where Tv)
5555
SparseMatrixCSR{1}(size(a,1),size(a,2),at.colptr,rowvals(at),nonzeros(at))
5656
end
5757

58+
"""
59+
SparseMatrixCSR(a::SparseMatrixCSC}
60+
61+
Build a 1-based `SparseMatrixCSR` from a `SparseMatrixCSC`.
62+
"""
63+
SparseMatrixCSR(a::SparseMatrixCSC) = SparseMatrixCSR(transpose(sparse(transpose(a))))
64+
65+
"""
66+
SparseMatrixCSR(a::AbstractMatrix}
67+
68+
Build a 1-based `SparseMatrixCSR` from an `AbstractMatrix`.
69+
"""
70+
SparseMatrixCSR(a::AbstractMatrix) = SparseMatrixCSR(sparse(a))
71+
5872
"""
5973
SparseMatrixCSR{Bi}(a::Transpose{Tv,<:SparseMatrixCSC} where Tv) where Bi
6074
@@ -77,7 +91,7 @@ SparseMatrixCSR{1}(a::Transpose{Tv,<:SparseMatrixCSC} where Tv) = SparseMatrixCS
7791
7892
Create a `SparseMatrixCSR` with `Bi`-based indexing (1 by default)
7993
from the same `args...` as one constructs a `SparseMatrixCSC`
80-
with the [`sparse`](@ref) function.
94+
with the [`SparseArrays.sparse`](@extref) function.
8195
"""
8296
sparsecsr(I,J,V) = SparseMatrixCSR(transpose(sparse(J,I,V,dimlub(J),dimlub(I))))
8397
sparsecsr(I,J,V,m,n) = SparseMatrixCSR(transpose(sparse(J,I,V,n,m)))
@@ -133,27 +147,31 @@ end
133147
function LinearAlgebra.lu(a::SparseMatrixCSR{0})
134148
rowptr = _copy_and_increment(a.rowptr)
135149
colval = _copy_and_increment(a.colval)
136-
Transpose(lu(SparseMatrixCSC(a.m,a.n,rowptr,colval,a.nzval)))
150+
transpose(lu(SparseMatrixCSC(a.m,a.n,rowptr,colval,a.nzval)))
137151
end
138152

139153
function LinearAlgebra.lu(a::SparseMatrixCSR{1})
140-
Transpose(lu(SparseMatrixCSC(a.m,a.n,a.rowptr,a.colval,a.nzval)))
154+
transpose(lu(SparseMatrixCSC(a.m,a.n,a.rowptr,a.colval,a.nzval)))
141155
end
142156

143157
if Base.USE_GPL_LIBS
144158

159+
const TransposeFact = isdefined(LinearAlgebra, :TransposeFactorization) ?
160+
LinearAlgebra.TransposeFactorization :
161+
Transpose
162+
145163
function LinearAlgebra.lu!(
146-
translu::Transpose{T,<:SuiteSparse.UMFPACK.UmfpackLU{T}},
164+
translu::TransposeFact{T,<:SuiteSparse.UMFPACK.UmfpackLU{T}},
147165
a::SparseMatrixCSR{1}) where {T}
148-
Transpose(lu!(translu.parent,SparseMatrixCSC(a.m,a.n,a.rowptr,a.colval,a.nzval)))
166+
transpose(lu!(translu.parent,SparseMatrixCSC(a.m,a.n,a.rowptr,a.colval,a.nzval)))
149167
end
150168

151169
function LinearAlgebra.lu!(
152-
translu::Transpose{T,<:SuiteSparse.UMFPACK.UmfpackLU{T}},
170+
translu::TransposeFact{T,<:SuiteSparse.UMFPACK.UmfpackLU{T}},
153171
a::SparseMatrixCSR{0}) where {T}
154172
rowptr = _copy_and_increment(a.rowptr)
155173
colval = _copy_and_increment(a.colval)
156-
Transpose(lu!(translu.parent,SparseMatrixCSC(a.m,a.n,rowptr,colval,a.nzval)))
174+
transpose(lu!(translu.parent,SparseMatrixCSC(a.m,a.n,rowptr,colval,a.nzval)))
157175
end
158176

159177
end # Base.USE_GPL_LIBS
@@ -223,7 +241,7 @@ issparse(S::SparseMatrixCSR) = true
223241
224242
Returns the number of stored (filled) elements in a sparse array.
225243
"""
226-
nnz(S::SparseMatrixCSR) = length(nonzeros(S))
244+
nnz(S::SparseMatrixCSR{Bi}) where Bi = Int(S.rowptr[size(S, 1) + 1] - Bi)
227245

228246
"""
229247
nonzeros(S::SparseMatrixCSR)
@@ -235,6 +253,8 @@ and any modifications to the returned vector will mutate S as well.
235253
"""
236254
nonzeros(S::SparseMatrixCSR) = S.nzval
237255

256+
nzvalview(S::SparseMatrixCSR) = view(nonzeros(S), 1:nnz(S))
257+
238258
"""
239259
colvals(S::SparseMatrixCSR{Bi}) where {Bi}
240260
@@ -289,8 +309,8 @@ end
289309
Count the number of elements in `nonzeros(S)` for which predicate `pred` returns `true`.
290310
If `pred` not given, it counts the number of `true` values.
291311
"""
292-
count(pred, S::SparseMatrixCSR) = count(pred, nonzeros(S))
293-
count(S::SparseMatrixCSR) = count(i->true, nonzeros(S))
312+
count(pred, S::SparseMatrixCSR) = count(pred, nzvalview(S))
313+
count(S::SparseMatrixCSR) = count(i->true, nzvalview(S))
294314

295315
function mul!(y::AbstractVector,A::SparseMatrixCSR,v::AbstractVector, α::Number, β::Number)
296316
A.n == size(v, 1) || throw(DimensionMismatch())

test/SparseMatrixCSR.jl

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ function test_csr(Bi,Tv,Ti)
7979
@test getBi(CSR) == Bi
8080
@test getoffset(CSR) == 1-Bi
8181
@test nnz(CSR) == nnz(CSC)
82-
@test length(nonzeros(CSR)) == nnz(CSR)
82+
@test length(SparseArrays.nzvalview(CSR)) == nnz(CSR)
8383
@test nonzeros(CSR) === CSR.nzval
8484
@test colvals(CSR) === CSR.colval
8585
i,j,v = findnz(CSR)
@@ -106,11 +106,22 @@ function test_csr(Bi,Tv,Ti)
106106
mul!(z,CSC,x)
107107
@test y z
108108

109+
# test constructors
110+
@test CSR == SparseMatrixCSR(CSC)
111+
@test CSR == SparseMatrixCSR(Matrix(CSC))
112+
109113
_CSR = copy(CSR)
110114
out = LinearAlgebra.rmul!(CSR,-1)
111115
@test out === CSR
112116
@test _CSR -1*CSR
113117

118+
# Test overlong buffers
119+
let A = sparsecsr([1, 2, 3], [1, 2, 3], [4., 5, 6])
120+
push!(A.nzval, 4.0)
121+
push!(A.rowptr, -1)
122+
@test nnz(A) == length(SparseArrays.nzvalview(A)) == 3
123+
@test SparseArrays.nzvalview(A) == [4., 5, 6]
124+
end
114125
end
115126

116127
function test_lu(Bi,I,J,V)
@@ -135,13 +146,13 @@ for Bi in (0,1)
135146
end
136147

137148
if Base.USE_GPL_LIBS # `lu!` requires `SuiteSparse.UMFPACK`
138-
I = [1,1,2,2,2,3,3]
139-
J = [1,2,1,2,3,2,3]
140-
V = [4.0,1.0,-1.0,4.0,1.0,-1.0,4.0]
141-
test_lu(0,I,J,V)
142-
test_lu(1,I,J,V)
149+
I = [1,1,2,2,2,3,3]
150+
J = [1,2,1,2,3,2,3]
151+
V = [4.0,1.0,-1.0,4.0,1.0,-1.0,4.0]
152+
test_lu(0,I,J,V)
153+
test_lu(1,I,J,V)
143154
else
144-
@warn "Tests run without GPL libraries."
155+
@warn "Tests run without GPL libraries."
145156
end
146157

147158
end # module

0 commit comments

Comments
 (0)