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

Adjust to AdjointFactorization #2

Merged
merged 4 commits into from
Apr 21, 2024
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SuperLU"
uuid = "149cae9a-b337-42bd-ac98-00096b14e8a3"
authors = ["Kyungmin Lee <kyungmin.lee.42@gmail.com>"]
version = "0.1.0"
version = "0.1.1"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
7 changes: 7 additions & 0 deletions src/SuperLU.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ module SuperLU
using SparseArrays
using LinearAlgebra

const AdjointFact = isdefined(LinearAlgebra, :AdjointFactorization) ?
LinearAlgebra.AdjointFactorization :
Adjoint
const TransposeFact = isdefined(LinearAlgebra, :TransposeFactorization) ?
LinearAlgebra.TransposeFactorization :
Transpose

export splu

include("libsuperlu_api.jl")
Expand Down
6 changes: 3 additions & 3 deletions src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ function LinearAlgebra.ldiv!(a::LUDecomposition{Tv, SuperLUInt}, b::StridedVecOr
return b
end

function LinearAlgebra.ldiv!(a::Transpose{Tv, LUDecomposition{Tv, SuperLUInt}}, b::StridedVecOrMat{Tv}) where {Tv}
function LinearAlgebra.ldiv!(a::TransposeFact{Tv, LUDecomposition{Tv, SuperLUInt}}, b::StridedVecOrMat{Tv}) where {Tv}
solve!(a.parent, b, TRANS)
return b
end

function LinearAlgebra.ldiv!(a::Adjoint{Tv, LUDecomposition{Tv, SuperLUInt}}, b::StridedVecOrMat{Tv}) where {Tv}
function LinearAlgebra.ldiv!(a::AdjointFact{Tv, LUDecomposition{Tv, SuperLUInt}}, b::StridedVecOrMat{Tv}) where {Tv}
solve!(a.parent, b, CONJ)
return b
end

# not sure why Julia only implements \ for NoTrans and Adjoint.
function Base.:(\)(tF::Transpose{Tv,LUDecomposition{Tv, Ti}}, B::AbstractVecOrMat) where {Tv, Ti}
function Base.:(\)(tF::TransposeFact{Tv,LUDecomposition{Tv, Ti}}, B::AbstractVecOrMat) where {Tv, Ti}
Base.require_one_based_indexing(B)
F = tF.parent
TFB = typeof(oneunit(eltype(B)) / oneunit(eltype(F)))
Expand Down
6 changes: 4 additions & 2 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ end
Base.size(x::LUDecomposition) = (Int(x._L.nrow), Int(x._U.ncol))
Base.size(x::LUDecomposition, i::Integer) = size(x)[i]

Base.transpose(f::LUDecomposition) = Transpose(f)
Base.adjoint(f::LUDecomposition) = Adjoint(f)
Base.transpose(f::LUDecomposition) = TransposeFact(f)
if !isdefined(LinearAlgebra, :AdjointFactorization) # VERSION < v"1.10-"
Base.adjoint(f::LUDecomposition) = Adjoint(f)
end

@inline function Base.getproperty(lu::LUDecomposition{Tv, Ti}, d::Symbol) where {Tv, Ti}
if d == :L
Expand Down