Skip to content

Commit

Permalink
convert Integer in Cholesky constructors to BlasInt (JuliaLang#29732)
Browse files Browse the repository at this point in the history
  • Loading branch information
kleinschmidt authored and JeffBezanson committed Oct 21, 2018
1 parent cbbdaaa commit 53563cd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/src/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ struct Cholesky{T,S<:AbstractMatrix} <: Factorization{T}
new(factors, uplo, info)
end
end
Cholesky(A::AbstractMatrix{T}, uplo::Symbol, info::BlasInt) where {T} =
Cholesky(A::AbstractMatrix{T}, uplo::Symbol, info::Integer) where {T} =
Cholesky{T,typeof(A)}(A, char_uplo(uplo), info)
Cholesky(A::AbstractMatrix{T}, uplo::AbstractChar, info::BlasInt) where {T} =
Cholesky(A::AbstractMatrix{T}, uplo::AbstractChar, info::Integer) where {T} =
Cholesky{T,typeof(A)}(A, uplo, info)

struct CholeskyPivoted{T,S<:AbstractMatrix} <: Factorization{T}
Expand All @@ -56,8 +56,8 @@ struct CholeskyPivoted{T,S<:AbstractMatrix} <: Factorization{T}
new(factors, uplo, piv, rank, tol, info)
end
end
function CholeskyPivoted(A::AbstractMatrix{T}, uplo::AbstractChar, piv::Vector{BlasInt},
rank::BlasInt, tol::Real, info::BlasInt) where T
function CholeskyPivoted(A::AbstractMatrix{T}, uplo::AbstractChar, piv::Vector{<:Integer},
rank::Integer, tol::Real, info::Integer) where T
CholeskyPivoted{T,typeof(A)}(A, uplo, piv, rank, tol, info)
end

Expand Down
26 changes: 26 additions & 0 deletions stdlib/LinearAlgebra/test/cholesky.jl
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,30 @@ end
@test_throws InexactError cholesky!(Diagonal([2, 1]))
end

@testset "constructor with non-BlasInt arguments" begin

x = rand(5,5)
chol = cholesky(x'x)

factors, uplo, info = chol.factors, chol.uplo, chol.info

@test Cholesky(factors, uplo, Int32(info)) == chol
@test Cholesky(factors, uplo, Int64(info)) == chol

cholp = cholesky(x'x, Val(true))

factors, uplo, piv, rank, tol, info =
cholp.factors, cholp.uplo, cholp.piv, cholp.rank, cholp.tol, cholp.info

@test CholeskyPivoted(factors, uplo, Vector{Int32}(piv), rank, tol, info) == cholp
@test CholeskyPivoted(factors, uplo, Vector{Int64}(piv), rank, tol, info) == cholp

@test CholeskyPivoted(factors, uplo, piv, Int32(rank), tol, info) == cholp
@test CholeskyPivoted(factors, uplo, piv, Int64(rank), tol, info) == cholp

@test CholeskyPivoted(factors, uplo, piv, rank, tol, Int32(info)) == cholp
@test CholeskyPivoted(factors, uplo, piv, rank, tol, Int64(info)) == cholp

end

end # module TestCholesky

0 comments on commit 53563cd

Please sign in to comment.