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

convert Integer in Cholesky constructors to BlasInt #29732

Merged
merged 5 commits into from
Oct 21, 2018
Merged
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
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