Skip to content

Commit 8c84b8c

Browse files
authored
Merge pull request #572 from JuliaSparse/backports-release-1.10
Backports to v1.10.7
2 parents 5c37298 + ec38631 commit 8c84b8c

File tree

10 files changed

+56
-38
lines changed

10 files changed

+56
-38
lines changed

.github/workflows/ci.yml

+8-16
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,27 @@ jobs:
2222
fail-fast: false
2323
matrix:
2424
version:
25-
- '~1.10'
25+
- '1.10'
2626
os:
2727
- ubuntu-latest
2828
- windows-latest
2929
arch:
3030
- x64
31+
- x86
3132
include:
3233
- os: macOS-latest
3334
arch: aarch64
34-
version: '~1.10'
35-
- os: ubuntu-latest
36-
arch: x86
37-
version: '~1.10'
35+
version: '1.10'
36+
- os: macOS-13
37+
arch: x64
38+
version: '1.10'
3839
steps:
3940
- uses: actions/checkout@v4
4041
- uses: julia-actions/setup-julia@v2
4142
with:
4243
version: ${{ matrix.version }}
4344
arch: ${{ matrix.arch }}
44-
- uses: actions/cache@v4
45-
env:
46-
cache-name: cache-artifacts
47-
with:
48-
path: ~/.julia/artifacts
49-
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
50-
restore-keys: |
51-
${{ runner.os }}-test-${{ env.cache-name }}-
52-
${{ runner.os }}-test-${{ matrix.os }}
53-
${{ runner.os }}-
45+
- uses: julia-actions/cache@v2
5446
- run: julia --color=yes .ci/test_and_change_uuid.jl
5547
- uses: julia-actions/julia-buildpkg@v1
5648
- uses: julia-actions/julia-runtest@v1
@@ -65,7 +57,7 @@ jobs:
6557
docs:
6658
runs-on: ubuntu-latest
6759
steps:
68-
- uses: actions/checkout@v2
60+
- uses: actions/checkout@v4
6961
- uses: julia-actions/setup-julia@latest
7062
with:
7163
version: '1.10'

docs/src/index.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ DocTestSetup = :(using SparseArrays, LinearAlgebra)
77
Julia has support for sparse vectors and [sparse matrices](https://en.wikipedia.org/wiki/Sparse_matrix)
88
in the `SparseArrays` stdlib module. Sparse arrays are arrays that contain enough zeros that storing them in a special data structure leads to savings in space and execution time, compared to dense arrays.
99

10-
External packages which implement different sparse storage types, multidimensional sparse arrays, and more can be found in [Noteworthy external packages](@ref man-csc)
10+
External packages which implement different sparse storage types, multidimensional sparse arrays, and more can be found in [Noteworthy External Sparse Packages](@ref)
1111

1212
## [Compressed Sparse Column (CSC) Sparse Matrix Storage](@id man-csc)
1313

@@ -202,6 +202,11 @@ section of the standard library reference.
202202
| [`sprandn(m,n,d)`](@ref) | [`randn(m,n)`](@ref) | Creates a *m*-by-*n* random matrix (of density *d*) with iid non-zero elements distributed according to the standard normal (Gaussian) distribution. |
203203
| [`sprandn(rng,m,n,d)`](@ref) | [`randn(rng,m,n)`](@ref) | Creates a *m*-by-*n* random matrix (of density *d*) with iid non-zero elements generated with the `rng` random number generator |
204204

205+
206+
```@meta
207+
DocTestSetup = nothing
208+
```
209+
205210
# [SparseArrays API](@id stdlib-sparse-arrays)
206211

207212
```@docs
@@ -241,7 +246,7 @@ SparseArrays.ftranspose!
241246
```@meta
242247
DocTestSetup = nothing
243248
```
244-
# Noteworthy external packages
249+
# Noteworthy External Sparse Packages
245250

246251
Several other Julia packages provide sparse matrix implementations that should be mentioned:
247252

docs/src/solvers.md

+15-8
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,33 @@
44
DocTestSetup = :(using LinearAlgebra, SparseArrays)
55
```
66

7-
Sparse matrix solvers call functions from [SuiteSparse](http://suitesparse.com). The following factorizations are available:
7+
## [Sparse Linear Algebra](@id stdlib-sparse-linalg)
8+
9+
Sparse matrix solvers call functions from [SuiteSparse](http://suitesparse.com).
10+
11+
The following factorizations are available:
12+
13+
1. [`cholesky`](@ref SparseArrays.CHOLMOD.cholesky)
14+
2. [`ldlt`](@ref SparseArrays.CHOLMOD.ldlt)
15+
3. [`lu`](@ref SparseArrays.UMFPACK.lu)
16+
4. [`qr`](@ref SparseArrays.SPQR.qr)
817

918
| Type | Description |
1019
|:--------------------------------- |:--------------------------------------------- |
1120
| `CHOLMOD.Factor` | Cholesky factorization |
1221
| `UMFPACK.UmfpackLU` | LU factorization |
1322
| `SPQR.QRSparse` | QR factorization |
1423

15-
Other solvers such as [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl/) are available as external packages. [Arpack.jl](https://julialinearalgebra.github.io/Arpack.jl/stable/) provides `eigs` and `svds` for iterative solution of eigensystems and singular value decompositions.
24+
Other solvers such as [Pardiso.jl](https://github.com/JuliaSparse/Pardiso.jl/) are available
25+
as external packages. [Arpack.jl](https://julialinearalgebra.github.io/Arpack.jl/stable/)
26+
provides `eigs` and `svds` for iterative solution of eigensystems and singular value
27+
decompositions.
1628

1729
These factorizations are described in more detail in the
1830
[`Linear Algebra`](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/)
1931
section of the manual:
2032

21-
1. [`cholesky`](@ref SparseArrays.CHOLMOD.cholesky)
22-
2. [`ldlt`](@ref SparseArrays.CHOLMOD.ldlt)
23-
3. [`lu`](@ref SparseArrays.UMFPACK.lu)
24-
4. [`qr`](@ref SparseArrays.SPQR.qr)
25-
26-
```@docs
33+
```@docs; canonical=false
2734
SparseArrays.CHOLMOD.cholesky
2835
SparseArrays.CHOLMOD.cholesky!
2936
SparseArrays.CHOLMOD.ldlt

src/linalg.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ for op ∈ (:+, :-)
2828
end
2929
end
3030

31-
LinearAlgebra.generic_matmatmul!(C::StridedMatrix, tA, tB, A::SparseMatrixCSCUnion, B::DenseMatrixUnion, _add::MulAddMul) =
31+
@inline LinearAlgebra.generic_matmatmul!(C::StridedMatrix, tA, tB, A::SparseMatrixCSCUnion, B::DenseMatrixUnion, _add::MulAddMul) =
3232
spdensemul!(C, tA, tB, A, B, _add)
33-
LinearAlgebra.generic_matmatmul!(C::StridedMatrix, tA, tB, A::SparseMatrixCSCUnion, B::AbstractTriangular, _add::MulAddMul) =
33+
@inline LinearAlgebra.generic_matmatmul!(C::StridedMatrix, tA, tB, A::SparseMatrixCSCUnion, B::AbstractTriangular, _add::MulAddMul) =
3434
spdensemul!(C, tA, tB, A, B, _add)
35-
LinearAlgebra.generic_matvecmul!(C::StridedVecOrMat, tA, A::SparseMatrixCSCUnion, B::DenseInputVector, _add::MulAddMul) =
35+
@inline LinearAlgebra.generic_matvecmul!(C::StridedVecOrMat, tA, A::SparseMatrixCSCUnion, B::DenseInputVector, _add::MulAddMul) =
3636
spdensemul!(C, tA, 'N', A, B, _add)
3737

3838
Base.@constprop :aggressive function spdensemul!(C, tA, tB, A, B, _add)

src/solvers/spqr.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Matrix{T}(Q::QRSparseQ) where {T} = lmul!(Q, Matrix{T}(I, size(Q, 1), min(size(Q
146146

147147
# From SPQR manual p. 6
148148
_default_tol(A::AbstractSparseMatrixCSC) =
149-
20*sum(size(A))*eps(real(eltype(A)))*maximum(norm(view(A, :, i)) for i in 1:size(A, 2))
149+
20*sum(size(A))*eps()*maximum(norm(view(A, :, i)) for i in 1:size(A, 2))
150150

151151
"""
152152
qr(A::SparseMatrixCSC; tol=_default_tol(A), ordering=ORDERING_DEFAULT) -> QRSparse

src/sparsematrix.jl

+2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,12 @@ SparseMatrixCSC(m, n, colptr::ReadOnly, rowval::ReadOnly, nzval::Vector) =
4949

5050
"""
5151
SparseMatrixCSC{Tv,Ti}(::UndefInitializer, m::Integer, n::Integer)
52+
SparseMatrixCSC{Tv,Ti}(::UndefInitializer, (m,n)::NTuple{2,Integer})
5253
5354
Creates an empty sparse matrix with element type `Tv` and integer type `Ti` of size `m × n`.
5455
"""
5556
SparseMatrixCSC{Tv,Ti}(::UndefInitializer, m::Integer, n::Integer) where {Tv, Ti} = spzeros(Tv, Ti, m, n)
57+
SparseMatrixCSC{Tv,Ti}(::UndefInitializer, mn::NTuple{2,Integer}) where {Tv, Ti} = spzeros(Tv, Ti, mn...)
5658

5759
"""
5860
`FixedSparseCSC{Tv,Ti<:Integer} <: AbstractSparseMatrixCSC{Tv,Ti}`

src/sparsevector.jl

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ SparseVector(n::Integer, nzind::Vector{Ti}, nzval::Vector{Tv}) where {Tv,Ti} =
5050
SparseVector{Tv,Ti}(n, nzind, nzval)
5151

5252
SparseVector{Tv, Ti}(::UndefInitializer, n::Integer) where {Tv, Ti} = SparseVector{Tv, Ti}(n, Ti[], Tv[])
53+
SparseVector{Tv, Ti}(::UndefInitializer, (n,)::Tuple{Integer}) where {Tv, Ti} = SparseVector{Tv, Ti}(n, Ti[], Tv[])
5354

5455
"""
5556
`FixedSparseVector{Tv,Ti<:Integer} <: AbstractCompressedVector{Tv,Ti}`

test/ambiguous.jl

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
original_depot_path = copy(Base.DEPOT_PATH)
66
original_load_path = copy(Base.LOAD_PATH)
77
original_env = copy(ENV)
8+
original_project = Base.active_project()
89
###
910

1011
import Pkg
@@ -13,6 +14,7 @@ import Pkg
1314
if Base.find_package("Aqua") === nothing
1415
@debug "Installing Aqua.jl for SparseArrays.jl tests"
1516
iob = IOBuffer()
17+
Pkg.activate(; temp = true)
1618
try
1719
# TODO: make this version tie to compat in Project.toml
1820
# or do this another safer way
@@ -103,4 +105,6 @@ end
103105
for (k, v) in pairs(original_env)
104106
ENV[k] = v
105107
end
108+
109+
Base.set_active_project(original_project)
106110
###

test/sparsematrix_constructors_indexing.jl

+7-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,13 @@ end
5757
@test sparse([1, 1, 2, 2, 2], [1, 2, 1, 2, 2], -1.0, 2, 2, *) == sparse([1, 1, 2, 2], [1, 2, 1, 2], [-1.0, -1.0, -1.0, 1.0], 2, 2)
5858
@test sparse(sparse(Int32.(1:5), Int32.(1:5), trues(5))') isa SparseMatrixCSC{Bool,Int32}
5959
# undef initializer
60-
m = SparseMatrixCSC{Float32, Int16}(undef, 3, 4)
61-
@test size(m) == (3, 4)
62-
@test eltype(m) === Float32
63-
@test m == spzeros(3, 4)
60+
sz = (3, 4)
61+
for m in (SparseMatrixCSC{Float32, Int16}(undef, sz...), SparseMatrixCSC{Float32, Int16}(undef, sz),
62+
similar(SparseMatrixCSC{Float32, Int16}, sz))
63+
@test size(m) == sz
64+
@test eltype(m) === Float32
65+
@test m == spzeros(sz...)
66+
end
6467
end
6568

6669
@testset "spzeros for pattern creation (structural zeros)" begin

test/sparsevector.jl

+8-4
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,14 @@ end
219219
end
220220

221221
@testset "Undef initializer" begin
222-
v = SparseVector{Float32, Int16}(undef, 4)
223-
@test size(v) == (4, )
224-
@test eltype(v) === Float32
225-
@test v == spzeros(Float32, 4)
222+
sz = (4,)
223+
for v in (SparseVector{Float32, Int16}(undef, sz),
224+
SparseVector{Float32, Int16}(undef, sz...),
225+
similar(SparseVector{Float32, Int16}, sz))
226+
@test size(v) == sz
227+
@test eltype(v) === Float32
228+
@test v == spzeros(Float32, sz...)
229+
end
226230
end
227231
end
228232
### Element access

0 commit comments

Comments
 (0)