diff --git a/Project.toml b/Project.toml index e873ffe1..1254eefc 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "LinearSolve" uuid = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" authors = ["SciML"] -version = "2.36.1" +version = "2.37.0" [deps] ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9" @@ -105,7 +105,7 @@ RecursiveArrayTools = "3.8" RecursiveFactorization = "0.2.14" Reexport = "1" SafeTestsets = "0.1" -SciMLBase = "2.26.3" +SciMLBase = "2.58.0" SciMLOperators = "0.3.7" Setfield = "1" SparseArrays = "1.10" diff --git a/src/common.jl b/src/common.jl index 3f145fc6..e486046c 100644 --- a/src/common.jl +++ b/src/common.jl @@ -139,8 +139,6 @@ __init_u0_from_Ab(::SMatrix{S1, S2}, b) where {S1, S2} = zeros(SVector{S2, eltyp function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm, args...; - alias_A = default_alias_A(alg, prob.A, prob.b), - alias_b = default_alias_b(alg, prob.A, prob.b), abstol = default_tol(real(eltype(prob.b))), reltol = default_tol(real(eltype(prob.b))), maxiters::Int = length(prob.b), @@ -149,10 +147,50 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm, Pr = nothing, assumptions = OperatorAssumptions(issquare(prob.A)), sensealg = LinearSolveAdjoint(), + alias = LinearAliasSpecifier(), kwargs...) (;A, b, u0, p) = prob - A = if alias_A || A isa SMatrix + has_A = haskey(kwargs,:alias_A) + has_b = haskey(kwargs,:alias_b) + + if has_A || has_b + aliases = LinearAliasSpecifier() + if has_A + Base.depwarn("alias_A keyword argument is deprecated, to set `alias_A`, + please use a LinearAliasSpecifier, e.g. `solve(prob, alias = LinearAliasSpecifier(alias_A = true))", :alias_A) + SciMLBase.@reset aliases.alias_A = values(kwargs).alias_A + else + SciMLBase.@reset aliases.alias_A = default_alias_A(alg, prob.A, prob.b) + end + + if has_b + Base.depwarn("alias_b keyword argument is deprecated, to set `alias_b`, + please use an LinearAliasSpecifier, e.g. `solve(prob, alias = LinearAliasSpecifier(alias_b = true))", :alias_b) + SciMLBase.@reset aliases.alias_b = values(kwargs).alias_b + else + SciMLBase.@reset aliases.alias_b = default_alias_b(alg, prob.A, prob.b) + end + + aliases + else + # If alias isa Bool, all fields of ODEAliases set to alias + if alias isa Bool + aliases = LinearAliasSpecifier(alias = alias) + elseif alias isa LinearAliasSpecifier || isnothing(alias) + aliases = alias + end + + if isnothing(aliases.alias_A) + SciMLBase.@reset aliases.alias_A = default_alias_A(alg,prob.A,prob.b) + end + if isnothing(aliases.alias_b) + SciMLBase.@reset aliases.alias_b = default_alias_b(alg,prob.A,prob.b) + end + aliases + end + + A = if aliases.alias_A || A isa SMatrix A elseif A isa Array copy(A) @@ -164,7 +202,7 @@ function SciMLBase.init(prob::LinearProblem, alg::SciMLLinearSolveAlgorithm, b = if b isa SparseArrays.AbstractSparseArray && !(A isa Diagonal) Array(b) # the solution to a linear solve will always be dense! - elseif alias_b || b isa SVector + elseif aliases.alias_b || b isa SVector b elseif b isa Array copy(b)