Skip to content

Commit 610c3f8

Browse files
authored
Merge pull request #233 from tkonolige/fix_diag_indices
Fix DiagonalIndices when sparse matrix indices are not Int64.
2 parents ed66486 + 335900a commit 610c3f8

File tree

6 files changed

+7
-7
lines changed

6 files changed

+7
-7
lines changed

src/stationary_sparse.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ struct DiagonalIndices{Tv, Ti <: Integer}
1212
diag = Vector{Ti}(undef, A.n)
1313

1414
for col = 1 : A.n
15-
r1 = A.colptr[col]
16-
r2 = A.colptr[col + 1] - 1
15+
r1 = Int(A.colptr[col])
16+
r2 = Int(A.colptr[col + 1] - 1)
1717
r1 = searchsortedfirst(A.rowval, col, r1, r2, Base.Order.Forward)
1818
if r1 > r2 || A.rowval[r1] != col || iszero(A.nzval[r1])
1919
throw(LinearAlgebra.SingularException(col))

test/cg.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
rmul!(rhs, inv(norm(rhs)))
5959
tol = 1e-5
6060

61-
@testset "Matrix" begin
61+
@testset "SparseMatrixCSC{$T, $Ti}" for T in (Float64, Float32), Ti in (Int64, Int32)
6262
xCG = cg(A, rhs; tol=tol, maxiter=100)
6363
xJAC = cg(A, rhs; Pl=P, tol=tol, maxiter=100)
6464
@test norm(A * xCG - rhs) tol

test/gmres.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ n = 10
3333
@test norm(A * x - b) / norm(b) tol
3434
end
3535

36-
@testset "SparseMatrixCSC{$T}" for T in (Float64, ComplexF64)
36+
@testset "SparseMatrixCSC{$T, $Ti}" for T in (Float64, ComplexF64), Ti in (Int64, Int32)
3737
A = sprand(T, n, n, 0.5) + I
3838
b = rand(T, n)
3939
F = lu(A)

test/idrs.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Random.seed!(1234567)
2929
end
3030
end
3131

32-
@testset "SparseMatrixCSC{$T}" for T in (Float64, ComplexF64)
32+
@testset "SparseMatrixCSC{$T, $Ti}" for T in (Float64, ComplexF64), Ti in (Int64, Int32)
3333
A = sprand(T, n, n, 0.5) + n * I
3434
b = rand(T, n)
3535
tol = eps(real(T))

test/minres.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ end
5151
@test hist.isconverged
5252
end
5353

54-
@testset "SparseMatrixCSC{$T}" for T in (Float32, Float64, ComplexF32, ComplexF64)
54+
@testset "SparseMatrixCSC{$T, $Ti}" for T in (Float32, Float64, ComplexF32, ComplexF64), Ti in (Int64, Int32)
5555
A = let
5656
B = sprand(n, n, 2 / n)
5757
B + B' + I

test/stationary.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ m = 6
1616
ω = 1.2
1717
Random.seed!(1234322)
1818

19-
@testset "SparseMatrix{$T}" for T in (Float32, Float64, ComplexF32, ComplexF64)
19+
@testset "SparseMatrix{$T, $Ti}" for T in (Float32, Float64, ComplexF32, ComplexF64), Ti in (Int64, Int32)
2020
@testset "Sparse? $sparse" for sparse = (true, false)
2121
# Diagonally dominant
2222
if sparse

0 commit comments

Comments
 (0)