Skip to content

Commit 90a4a3c

Browse files
committed
Prepare for AdjointFactorization
1 parent 1ca8a3d commit 90a4a3c

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SciMLBase"
22
uuid = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
33
authors = ["Chris Rackauckas <[email protected]> and contributors"]
4-
version = "1.81.0"
4+
version = "1.81.1"
55

66
[deps]
77
ArrayInterfaceCore = "30b0a656-2188-435a-8636-2ec0e6a096e2"

src/operators/basic_operators.jl

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ function Base.copy(L::DiffEqArrayOperator)
127127
DiffEqArrayOperator(copy(L.A); update_func = L.update_func)
128128
end
129129

130+
const AdjointFact = isdefined(LinearAlgebra, :AdjointFactorization) ? LinearAlgebra.AdjointFactorization : Adjoint
131+
const TransposeFact = isdefined(LinearAlgebra, :TransposeFactorization) ? LinearAlgebra.TransposeFactorization : Transpose
132+
130133
"""
131134
FactorizedDiffEqArrayOperator(F)
132135
@@ -137,26 +140,26 @@ Supports left division and `ldiv!` when applied to an array.
137140
struct FactorizedDiffEqArrayOperator{T <: Number,
138141
FType <: Union{
139142
Factorization{T}, Diagonal{T}, Bidiagonal{T},
140-
Adjoint{T, <:Factorization{T}}
143+
AdjointFact{T, <:Factorization{T}},
144+
TransposeFact{T, <:Factorization{T}}
141145
}
142146
} <: AbstractDiffEqLinearOperator{T}
143147
F::FType
144148
end
145149

146-
function Base.convert(::Type{AbstractMatrix}, L::FactorizedDiffEqArrayOperator)
147-
if L.F isa Adjoint
148-
convert(AbstractMatrix, L.F')'
149-
else
150-
convert(AbstractMatrix, L.F)
151-
end
152-
end
153-
function Base.Matrix(L::FactorizedDiffEqArrayOperator)
154-
if L.F isa Adjoint
155-
Matrix(L.F')'
156-
else
157-
Matrix(L.F)
158-
end
159-
end
150+
Base.convert(::Type{AbstractMatrix}, L::FactorizedDiffEqArrayOperator{<:Any,<:Union{Factorization,AbstractMatrix}}) =
151+
convert(AbstractMatrix, L.F)
152+
Base.convert(::Type{AbstractMatrix}, L::FactorizedDiffEqArrayOperator{<:Any,<:Union{Adjoint,AdjointFact}}) =
153+
adjoint(convert(AbstractMatrix, adjoint(L.F)))
154+
Base.convert(::Type{AbstractMatrix}, L::FactorizedDiffEqArrayOperator{<:Any,<:Union{Transpose,TransposeFact}}) =
155+
transpose(convert(AbstractMatrix, transpose(L.F)))
156+
157+
Base.Matrix(L::FactorizedDiffEqArrayOperator{<:Any,<:Union{Factorization,AbstractMatrix}}) =
158+
Matrix(L.F)
159+
Base.Matrix(L::FactorizedDiffEqArrayOperator{<:Any,<:AdjointFact}) = Matrix(L.F')'
160+
Base.Matrix(L::FactorizedDiffEqArrayOperator{<:Any,<:TransposeFact}) =
161+
transpose(Matrix(transpose(L.F)))
162+
160163
Base.adjoint(L::FactorizedDiffEqArrayOperator) = FactorizedDiffEqArrayOperator(L.F')
161164
Base.size(L::FactorizedDiffEqArrayOperator, args...) = size(L.F, args...)
162165
function LinearAlgebra.ldiv!(Y::AbstractVecOrMat, L::FactorizedDiffEqArrayOperator,

0 commit comments

Comments
 (0)