From 080cc1098508690d3444e9822446c8b1532a4eb6 Mon Sep 17 00:00:00 2001 From: ErikQQY <2283984853@qq.com> Date: Wed, 18 Sep 2024 23:46:47 +0800 Subject: [PATCH 1/3] Drop UnPack Signed-off-by: ErikQQY <2283984853@qq.com> --- Project.toml | 4 ---- src/FractionalDiffEq.jl | 1 - src/delay/abm.jl | 6 +++--- src/delay/matrix_form.jl | 2 +- src/delay/pece.jl | 12 ++++++------ src/delay/product_integral.jl | 4 ++-- src/discrete/GL.jl | 2 +- src/discrete/PECE.jl | 2 +- src/dode/matrix.jl | 2 +- src/ffode/atangana_seda.jl | 6 +++--- src/fode/atangana_seda.jl | 4 ++-- src/fode/bdf.jl | 15 ++++++++------- src/fode/explicit_pi.jl | 12 ++++++------ src/fode/grunwald_letnikov.jl | 4 ++-- src/fode/implicit_pi_rectangle.jl | 12 ++++++------ src/fode/implicit_pi_trapzoid.jl | 12 ++++++------ src/fode/newton_gregory.jl | 14 +++++++------- src/fode/newton_polynomials.jl | 2 +- src/fode/nonlinearalg.jl | 4 ++-- src/fode/pi_pece.jl | 12 ++++++------ src/fode/trapezoid.jl | 16 +++++++--------- src/multitermsfode/closed_form.jl | 2 +- src/multitermsfode/explicit_pi.jl | 10 +++++----- src/multitermsfode/hankelmatrix.jl | 2 +- src/multitermsfode/implicit_pi_pece.jl | 10 +++++----- src/multitermsfode/implicit_pi_rectangle.jl | 10 +++++----- src/multitermsfode/implicit_pi_trapezoid.jl | 10 +++++----- src/multitermsfode/matrix.jl | 4 ++-- src/types/problems.jl | 4 ---- 29 files changed, 95 insertions(+), 105 deletions(-) diff --git a/Project.toml b/Project.toml index 2159646a..30ac70df 100644 --- a/Project.toml +++ b/Project.toml @@ -19,8 +19,6 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b" SpecialMatrices = "928aab9d-ef52-54ac-8ca1-acd7ca42c160" ToeplitzMatrices = "c751599d-da0a-543b-9d20-d0a503d91d24" -TruncatedStacktraces = "781d530d-4396-4725-bb49-402e4bee1e77" -UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [compat] ConcreteStructs = "0.2.2" @@ -37,8 +35,6 @@ SparseArrays = "1.10" SpecialFunctions = "2.3.1" SpecialMatrices = "3.0.0" ToeplitzMatrices = "0.8.3" -TruncatedStacktraces = "1.4.0" -UnPack = "1.0.2" julia = "1.10" [extras] diff --git a/src/FractionalDiffEq.jl b/src/FractionalDiffEq.jl index 27918d6f..3f027ec8 100644 --- a/src/FractionalDiffEq.jl +++ b/src/FractionalDiffEq.jl @@ -9,7 +9,6 @@ import DiffEqBase: solve import InvertedIndices: Not import SpecialMatrices: Vandermonde import FFTW: fft, ifft -import UnPack: @unpack import Polynomials: Polynomial import TruncatedStacktraces: @truncate_stacktrace diff --git a/src/delay/abm.jl b/src/delay/abm.jl index d4b152f8..10c3fc27 100644 --- a/src/delay/abm.jl +++ b/src/delay/abm.jl @@ -39,7 +39,7 @@ struct DelayABM <: FDDEAlgorithm end #FIXME: Fix DelayABM method for FDDESystem : https://www.researchgate.net/publication/245538900_A_Predictor-Corrector_Scheme_For_Solving_Nonlinear_Delay_Differential_Equations_Of_Fractional_Order #TODO: Need more works function SciMLBase.__init(prob::FDDEProblem, alg::DelayABM; dt = 0.0, kwargs...) - @unpack f, order, u0, h, tspan, p, constant_lags = prob + (; f, order, u0, h, tspan, p, constant_lags) = prob τ = constant_lags[1] T = eltype(u0) l = length(u0) @@ -89,7 +89,7 @@ function SciMLBase.__init(prob::FDDEProblem, alg::DelayABM; dt = 0.0, kwargs...) end function SciMLBase.solve!(cache::ABMCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, constant_algs, p, x, x0, x1, N, Ndelay, dt, kwargs = cache + (; prob, alg, mesh, u0, order, p, x, x0, x1, N, Ndelay, dt) = cache l = length(u0) if iip @fastmath @inbounds @simd for n in 1:N @@ -150,7 +150,7 @@ DelayABM method for system of fractional delay differential equations. =# function solve(FDDESys::FDDESystem, dt, ::DelayABM) - @unpack f, ϕ, α, τ, T = FDDESys + (; f, ϕ, α, τ, T) = FDDESys len = length(ϕ) N::Int = round(Int, T / dt) Ndelay = round(Int, τ / dt) diff --git a/src/delay/matrix_form.jl b/src/delay/matrix_form.jl index 39fba34a..0b36610e 100644 --- a/src/delay/matrix_form.jl +++ b/src/delay/matrix_form.jl @@ -10,7 +10,7 @@ https://github.com/mandresik/system-of-linear-fractional-differential-delayed-eq struct MatrixForm <: FDDEAlgorithm end function solve(prob::FDDEMatrixProblem, h, ::MatrixForm) - @unpack α, τ, A, B, f, x0, tspan = prob + (; α, τ, A, B, f, x0, tspan) = prob t0 = tspan[1] T = tspan[2] limit = 100 diff --git a/src/delay/pece.jl b/src/delay/pece.jl index 398def91..6aaca0fe 100644 --- a/src/delay/pece.jl +++ b/src/delay/pece.jl @@ -46,7 +46,7 @@ end function SciMLBase.__init(prob::FDDEProblem, alg::DelayPECE; dt = 0.0, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, h, order, u0, constant_lags, p, tspan = prob + (; f, h, order, u0, constant_lags, p, tspan) = prob τ = constant_lags[1] iip = SciMLBase.isinplace(prob) t0 = tspan[1] @@ -84,7 +84,7 @@ end end function SciMLBase.solve!(cache::DelayPECECache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, p, dt = cache + (; prob, alg, mesh, u0, order, p, dt) = cache maxn = length(mesh) l = length(u0) initial = _generate_similar_array(u0, 1, prob.h(p, 0)) @@ -157,7 +157,7 @@ function generalized_binomials(j, n, order, dt) end function v(cache::DelayPECECache{iip, T}, n) where {iip, T} - @unpack prob, mesh, dt, constant_lags, p = cache + (; prob, mesh, dt, constant_lags, p) = cache τ = constant_lags if typeof(τ) <: Function m = floor.(Int, τ.(mesh) / dt) @@ -191,7 +191,7 @@ function v(cache::DelayPECECache{iip, T}, n) where {iip, T} end function solve_fdde_with_multiple_lags(FDDE::FDDEProblem, dt) - @unpack f, h, order, constant_lags, p, tspan = FDDE + (; f, h, order, constant_lags, p, tspan) = FDDE τ = constant_lags[1] mesh = collect(0:dt:tspan[2]) maxn = length(mesh) @@ -274,7 +274,7 @@ end #########################For variable order FDDE########################### function solve_fdde_with_single_lag_and_variable_order(FDDE::FDDEProblem, dt) - @unpack f, order, h, constant_lags, p, tspan = FDDE + (; f, order, h, constant_lags, p, tspan) = FDDE iip = SciMLBase.isinplace(FDDE) order = order[1] τ = constant_lags[1] @@ -339,7 +339,7 @@ function solve_fdde_with_single_lag_and_variable_order(FDDE::FDDEProblem, dt) end function solve_fdde_with_multiple_lags_and_variable_order(FDDE::FDDEProblem, dt) - @unpack f, h, order, constant_lags, p, tspan = FDDE + (; f, h, order, constant_lags, p, tspan) = FDDE τ = constant_lags[1] mesh = collect(0:dt:tspan[2]) maxn = length(mesh) diff --git a/src/delay/product_integral.jl b/src/delay/product_integral.jl index 70b51c59..d34f0de8 100644 --- a/src/delay/product_integral.jl +++ b/src/delay/product_integral.jl @@ -21,7 +21,7 @@ Base.eltype(::DelayPIEXCache{iip, T}) where {iip, T} = T function SciMLBase.__init(prob::FDDEProblem, alg::DelayPIEX; dt = 0.0, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, order, u0, h, tspan, p, constant_lags = prob + (; f, order, u0, h, tspan, p, constant_lags) = prob τ = constant_lags[1] iip = SciMLBase.isinplace(prob) T = eltype(u0) @@ -47,7 +47,7 @@ function SciMLBase.__init(prob::FDDEProblem, alg::DelayPIEX; dt = 0.0, kwargs... end function SciMLBase.solve!(cache::DelayPIEXCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, constant_lags, p, N, y0, y, g, b, dt, kwargs = cache + (; prob, alg, mesh, u0, order, constant_lags, p, N, y0, y, g, b, dt, kwargs) = cache h_al = dt^order[1] τ = constant_lags l = length(u0) diff --git a/src/discrete/GL.jl b/src/discrete/GL.jl index 0ee8381c..8b533542 100644 --- a/src/discrete/GL.jl +++ b/src/discrete/GL.jl @@ -12,7 +12,7 @@ """ function solve(prob::FractionalDiscreteSystem, N, ::GL) - @unpack fun, α, u0, p = prob + (; fun, α, u0, p) = prob result = zeros(Float64, length(u0), N)# Initialization result[:, 1] = u0 diff --git a/src/discrete/PECE.jl b/src/discrete/PECE.jl index 2ed28a66..14f61b83 100644 --- a/src/discrete/PECE.jl +++ b/src/discrete/PECE.jl @@ -21,7 +21,7 @@ Use the PECE algorithm to solve fractional difference equations =# function solve(FDProb::FractionalDiscreteProblem, h, ::PECE) - @unpack fun, α, u0, tspan = FDProb + (; fun, α, u0, tspan) = FDProb if tspan isa Tuple T = tspan[end] elseif tspan isa Real diff --git a/src/dode/matrix.jl b/src/dode/matrix.jl index f2142ae2..16629cff 100644 --- a/src/dode/matrix.jl +++ b/src/dode/matrix.jl @@ -21,7 +21,7 @@ struct DOMatrixDiscrete <: DODEAlgorithm end isFunction(x) = isa(x, Function) ? true : false function solve(prob::DODEProblem, h, ::DOMatrixDiscrete) - @unpack parameters, orders, interval, rightfun, u0, tspan = prob + (; parameters, orders, interval, rightfun, u0, tspan) = prob N = length(tspan) # find the index of the distributed order DOid = findall(isFunction, orders) diff --git a/src/ffode/atangana_seda.jl b/src/ffode/atangana_seda.jl index e1db5251..45e0eebd 100644 --- a/src/ffode/atangana_seda.jl +++ b/src/ffode/atangana_seda.jl @@ -15,7 +15,7 @@ function solve(prob::Union{FFMODEProblem, FFMODESystem}, h::Float64, ::AtanganaS end end function solve_singletermffode(prob::Union{FFMODEProblem, FFMODESystem}, h) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob α = order[1] # Fractional order β = order[2] # Fractal dimension t0 = tspan[1] @@ -63,7 +63,7 @@ function solve_singletermffode(prob::Union{FFMODEProblem, FFMODESystem}, h) end function solve_ffodesystem(prob::FFMODESystem, h) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob α = order[1] β = order[2] t0 = tspan[1] @@ -120,7 +120,7 @@ function solve_ffodesystem(prob::FFMODESystem, h) end function solve_cf_variable_ffodesystem(prob::FFMODESystem, h) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob α = order[1] β = order[2] t0 = tspan[1] diff --git a/src/fode/atangana_seda.jl b/src/fode/atangana_seda.jl index 93ff3ff3..75d6b5e6 100644 --- a/src/fode/atangana_seda.jl +++ b/src/fode/atangana_seda.jl @@ -1,6 +1,6 @@ function solve(prob::FODEProblem, alg::AtanganaSedaAB; dt = 0.0) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob order = order[1] t0 = tspan[1] tfinal = tspan[2] @@ -78,7 +78,7 @@ struct AtanganaSedaCF <: FODEAlgorithm end #FIXME: Tests function solve(prob::FODEProblem, ::AtanganaSedaCF; dt = 0.0) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] t = collect(Float64, t0:dt:tfinal) diff --git a/src/fode/bdf.jl b/src/fode/bdf.jl index 02a98db4..ef56e282 100644 --- a/src/fode/bdf.jl +++ b/src/fode/bdf.jl @@ -41,7 +41,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::BDF; dt = 0.0, reltol = 1e-6, abstol = 1e-6, maxiters = 1000, kwargs...) prob = _is_need_convert!(prob) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -89,7 +89,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::BDF; dt = 0.0, reltol = 1e-6, end function SciMLBase.solve!(cache::BDFCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, halpha, y, fy, zn, Jfdefun, p, problem_size, m_alpha, m_alpha_factorial, r, N, Nr, Q, NNr, omega, w, s, dt, reltol, abstol, maxiters, kwargs = cache + (; prob, alg, mesh, y, r, N, Q, s, dt) = cache tfinal = mesh[end] BDF_first_approximations(cache) @@ -120,7 +120,7 @@ end function BDF_disegna_blocchi( cache::BDFCache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, y, fy, zn, abstol, maxiters, r, Nr, N, Jfdefun, s, w, omega, halpha, u0 = cache + (; r, Nr, N) = cache nxi::Int = copy(nx0) nxf::Int = copy(nx0 + L * r - 1) @@ -171,7 +171,7 @@ function BDF_disegna_blocchi( end function BDF_quadrato(cache::BDFCache, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer} - @unpack problem_size, omega = cache + (; problem_size, omega) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 @@ -186,7 +186,7 @@ end function BDF_triangolo( cache::BDFCache{iip, T}, nxi::P, nxf::P, j0) where {P <: Integer, iip, T} - @unpack prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, u0, m_alpha, m_alpha_factorial, p = cache + (; prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, p) = cache for n in nxi:min(N, nxf) n1 = n + 1 St = ABM_starting_term(cache, mesh[n1]) @@ -235,7 +235,8 @@ function BDF_triangolo( end function BDF_first_approximations(cache::BDFCache{iip, T}) where {iip, T} - @unpack prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, u0, m_alpha, m_alpha_factorial, p = cache + (; prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, p) = cache + Im = zeros(problem_size, problem_size) + I Ims = zeros(problem_size * s, problem_size * s) + I Y0 = zeros(T, s * problem_size, 1) @@ -365,7 +366,7 @@ end Jf_vectorfield(t, y, Jfdefun) = Jfdefun(t, y) function ABM_starting_term(cache::BDFCache{iip, T}, t) where {iip, T} - @unpack u0, m_alpha, mesh, m_alpha_factorial, high_order_prob = cache + (; u0, m_alpha, mesh, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/explicit_pi.jl b/src/fode/explicit_pi.jl index db6c1944..55feb8c0 100644 --- a/src/fode/explicit_pi.jl +++ b/src/fode/explicit_pi.jl @@ -35,7 +35,7 @@ Base.eltype(::PIEXCache{iip, T}) where {iip, T} = T function SciMLBase.__init(prob::FODEProblem, alg::PIEX; dt = 0.0, abstol = 1e-6, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -140,7 +140,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::PIEX; dt = 0.0, abstol = 1e-6, mu, abstol, index_fft, bn_fft, high_order_prob, kwargs) end function SciMLBase.solve!(cache::PIEXCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, y, fy, r, N, Nr, Qr, NNr, bn, halpha1, mu, abstol, index_fft, bn_fft, kwargs = cache + (; prob, alg, mesh, u0, y, r, N, Qr) = cache tfinal = mesh[end] PIEX_triangolo(cache, 1, r - 1) @@ -174,7 +174,7 @@ end function PIEX_disegna_blocchi( cache::PIEXCache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, N, r, Nr = cache + (; N, r, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 @@ -228,7 +228,7 @@ end function PIEX_quadrato(cache::PIEXCache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, r, N, Nr, Qr, NNr, problem_size, bn, halpha1, mu, abstol, index_fft, bn_fft = cache + (; prob, r, N, problem_size, index_fft, bn_fft) = cache coef_end = nxf - nyi + 1 alpha_length = length(prob.order) i_fft::Int = log2(coef_end / r) @@ -255,7 +255,7 @@ end function PIEX_triangolo( cache::PIEXCache{iip, T}, nxi::P, nxf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, u0, order, m_alpha, m_alpha_factorial, p, problem_size, zn, N, bn, halpha1, mu, abstol, index_fft, bn_fft, high_order_prob = cache + (; prob, mesh, order, p, problem_size, N, bn, halpha1) = cache alpha_length = length(order) for n in nxi:min(N, nxf) @@ -283,7 +283,7 @@ function PIEX_triangolo( end function PIEX_system_starting_term(cache::PIEXCache{iip, T}, t) where {iip, T} - @unpack mesh, u0, m_alpha, m_alpha_factorial, high_order_prob = cache + (; mesh, u0, m_alpha, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/grunwald_letnikov.jl b/src/fode/grunwald_letnikov.jl index 8d3b8a82..546a5a9f 100644 --- a/src/fode/grunwald_letnikov.jl +++ b/src/fode/grunwald_letnikov.jl @@ -15,7 +15,7 @@ Base.eltype(::GLCache{iip, T}) where {iip, T} = T function SciMLBase.__init(prob::FODEProblem, alg::GL; dt = 0.0, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing # GL method is only for commensurate order FODE - @unpack f, order, u0, tspan, p = prob + (; order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] order = order[1] @@ -33,7 +33,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::GL; dt = 0.0, kwargs...) end function SciMLBase.solve!(cache::GLCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, horder, y, p, kwargs = cache + (; prob, alg, mesh, u0, order, horder, y, p) = cache prob = _is_need_convert!(prob) n = length(mesh) l = length(u0) diff --git a/src/fode/implicit_pi_rectangle.jl b/src/fode/implicit_pi_rectangle.jl index 6bb72260..7b422255 100644 --- a/src/fode/implicit_pi_rectangle.jl +++ b/src/fode/implicit_pi_rectangle.jl @@ -37,7 +37,7 @@ function SciMLBase.__init( prob::FODEProblem, alg::PIRect; dt = 0.0, abstol = 1e-6, maxiters = 1000, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -145,7 +145,7 @@ function SciMLBase.__init( abstol, maxiters, index_fft, bn_fft, high_order_prob, kwargs) end function SciMLBase.solve!(cache::PIRectCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, y, fy, r, N, Nr, Qr, NNr, bn, halpha1, abstol, index_fft, bn_fft, kwargs = cache + (; prob, alg, mesh, u0, y, r, N, Qr) = cache tfinal = mesh[end] PIRect_triangolo(cache, 1, r - 1) @@ -179,7 +179,7 @@ end function PIRect_disegna_blocchi( cache::PIRectCache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, N, r, Nr = cache + (; N, r, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 @@ -233,7 +233,7 @@ end function PIRect_quadrato(cache::PIRectCache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, r, N, Nr, Qr, NNr, problem_size, bn, halpha1, abstol, index_fft, bn_fft = cache + (; prob, r, N, problem_size, index_fft, bn_fft) = cache coef_end = nxf - nyi + 1 alpha_length = length(prob.order) i_fft::Int = log2(coef_end / r) @@ -263,7 +263,7 @@ end function PIRect_triangolo( cache::PIRectCache{iip, T}, nxi::P, nxf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, u0, order, m_alpha, m_alpha_factorial, p, problem_size, zn, Jfdefun, N, bn, halpha1, abstol, maxiters, index_fft, bn_fft, high_order_prob = cache + (; prob, mesh, order, p, problem_size, Jfdefun, N, bn, halpha1, abstol, maxiters, high_order_prob) = cache alpha_length = length(order) for n in nxi:min(N, nxf) @@ -315,7 +315,7 @@ function PIRect_triangolo( end function PIRect_system_starting_term(cache::PIRectCache{iip, T}, t) where {iip, T} - @unpack mesh, u0, m_alpha, m_alpha_factorial, high_order_prob = cache + (; mesh, u0, m_alpha, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/implicit_pi_trapzoid.jl b/src/fode/implicit_pi_trapzoid.jl index 8b631c4e..07d4aeef 100644 --- a/src/fode/implicit_pi_trapzoid.jl +++ b/src/fode/implicit_pi_trapzoid.jl @@ -38,7 +38,7 @@ function SciMLBase.__init( prob::FODEProblem, alg::PITrap; dt = 0.0, abstol = 1e-6, maxiters = 1000, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -154,7 +154,7 @@ function SciMLBase.__init( end function SciMLBase.solve!(cache::PITrapCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, y, fy, r, N, Nr, Qr, NNr, an, a0, halpha2, abstol, index_fft, an_fft, kwargs = cache + (; prob, alg, mesh, u0, y, r, N, Qr) = cache tfinal = mesh[end] PITrap_triangolo(cache, 1, r - 1) @@ -188,7 +188,7 @@ end function PITrap_disegna_blocchi( cache::PITrapCache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, N, r, Nr = cache + (; N, r, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 @@ -242,7 +242,7 @@ end function PITrap_quadrato(cache::PITrapCache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, r, N, Nr, Qr, NNr, problem_size, an, a0, halpha2, abstol, index_fft, an_fft = cache + (; prob, r, N, problem_size, index_fft, an_fft) = cache coef_end = nxf - nyi + 1 alpha_length = length(prob.order) i_fft::Int = log2(coef_end / r) @@ -272,7 +272,7 @@ end function PITrap_triangolo( cache::PITrapCache{iip, T}, nxi::P, nxf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, u0, order, m_alpha, m_alpha_factorial, p, problem_size, zn, Jfdefun, N, an, a0, halpha2, abstol, maxiters, index_fft, an_fft, high_order_prob = cache + (; prob, mesh, order, p, problem_size, Jfdefun, N, an, a0, halpha2, abstol, maxiters, high_order_prob) = cache alpha_length = length(order) for n in nxi:min(N, nxf) @@ -325,7 +325,7 @@ function PITrap_triangolo( end function PITrap_system_starting_term(cache::PITrapCache{iip, T}, t) where {iip, T} - @unpack mesh, u0, m_alpha, m_alpha_factorial, high_order_prob = cache + (; mesh, u0, m_alpha, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/newton_gregory.jl b/src/fode/newton_gregory.jl index f89b82d1..6d737d6f 100644 --- a/src/fode/newton_gregory.jl +++ b/src/fode/newton_gregory.jl @@ -41,7 +41,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::NewtonGregory; dt = 0.0, reltol = 1e-6, abstol = 1e-6, maxiters = 1000, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -88,7 +88,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::NewtonGregory; dt = 0.0, w, s, dt, reltol, abstol, maxiters, high_order_prob, kwargs) end function SciMLBase.solve!(cache::NewtonGregoryCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, halpha, y, fy, zn, Jfdefun, p, problem_size, m_alpha, m_alpha_factorial, r, N, Nr, Q, NNr, omega, w, s, dt, reltol, abstol, maxiters, kwargs = cache + (; prob, alg, mesh, u0, y, r, N, Q, s, dt) = cache tfinal = mesh[end] NG_first_approximations(cache) @@ -119,7 +119,7 @@ end function NG_disegna_blocchi!(cache::NewtonGregoryCache{iip, T}, L::P, ff, nx0::P, ny0) where {P <: Integer, iip, T} - @unpack mesh, y, fy, zn, abstol, maxiters, r, Nr, N, Jfdefun, s, w, omega, halpha, u0 = cache + (; r, Nr, N) = cache nxi::Int = copy(nx0) nxf::Int = copy(nx0 + L * r - 1) nyi::Int = copy(ny0) @@ -170,7 +170,7 @@ end function NG_quadrato(cache::NewtonGregoryCache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack problem_size, omega = cache + (; problem_size, omega) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 @@ -185,7 +185,7 @@ end function NG_triangolo( cache::NewtonGregoryCache{iip, T}, nxi::P, nxf::P, j0) where {P <: Integer, iip, T} - @unpack prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, u0, m_alpha, m_alpha_factorial, p = cache + (; prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, p) = cache for n in nxi:min(N, nxf) n1 = Int64(n + 1) St = NG_starting_term(cache, mesh[n1]) @@ -234,7 +234,7 @@ function NG_triangolo( end function NG_first_approximations(cache::NewtonGregoryCache{iip, T}) where {iip, T} - @unpack prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, u0, m_alpha, m_alpha_factorial, p = cache + (; prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, p) = cache Im = zeros(problem_size, problem_size) + I Ims = zeros(problem_size * s, problem_size * s) + I Y0 = zeros(s * problem_size, 1) @@ -360,7 +360,7 @@ function NG_weights(alpha, N) end function NG_starting_term(cache::NewtonGregoryCache{iip, T}, t) where {iip, T} - @unpack u0, m_alpha, mesh, m_alpha_factorial, high_order_prob = cache + (; u0, m_alpha, mesh, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/newton_polynomials.jl b/src/fode/newton_polynomials.jl index 6f0a0fae..5e6c8614 100644 --- a/src/fode/newton_polynomials.jl +++ b/src/fode/newton_polynomials.jl @@ -1,6 +1,6 @@ function solve(prob::FODEProblem, alg::NewtonPolynomial; dt = 0.0) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] order = order[1] diff --git a/src/fode/nonlinearalg.jl b/src/fode/nonlinearalg.jl index 3b442839..31c63041 100644 --- a/src/fode/nonlinearalg.jl +++ b/src/fode/nonlinearalg.jl @@ -24,7 +24,7 @@ function SciMLBase.__init( prob::FODEProblem, alg::NonLinearAlg; dt = 0.0, L0 = 1e10, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -46,7 +46,7 @@ function SciMLBase.__init( end function SciMLBase.solve!(cache::NonlinearAlgCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, halpha, p, N, problem_size, gen, W, z, y, L0, memory_effect, kwargs = cache + (; prob, alg, mesh, u0, order, halpha, p, N, problem_size, gen, W, z, y, L0, memory_effect, kwargs) = cache @fastmath @inbounds @simd for i in 1:problem_size W[i, :] = getvec(order[i], memory_effect, gen) diff --git a/src/fode/pi_pece.jl b/src/fode/pi_pece.jl index 9ff062d7..b172487e 100644 --- a/src/fode/pi_pece.jl +++ b/src/fode/pi_pece.jl @@ -40,7 +40,7 @@ Base.eltype(::PECECache{iip, T}) where {iip, T} = T function SciMLBase.__init(prob::FODEProblem, alg::PECE; dt = 0.0, abstol = 1e-6, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -166,7 +166,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::PECE; dt = 0.0, abstol = 1e-6, end function SciMLBase.solve!(cache::PECECache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, y, fy, zn_pred, zn_corr, r, N, Nr, Qr, NNr, an, bn, a0, halpha1, halpha2, mu, abstol, index_fft, an_fft, bn_fft, kwargs = cache + (; prob, alg, mesh, u0, r, N, Qr) = cache tfinal = mesh[N + 1] ABM_triangolo(cache, 1, r - 1) @@ -200,7 +200,7 @@ end function DisegnaBlocchi( cache::PECECache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, N, r, Nr = cache + (; N, r, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 nyi::Int = ny0 @@ -254,7 +254,7 @@ end function ABM_quadrato(cache::PECECache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, r, N, Nr, Qr, NNr, an, bn, a0, halpha1, halpha2, mu, abstol, index_fft, an_fft, bn_fft = cache + (; prob, r, N, mu, index_fft, an_fft, bn_fft) = cache problem_size = length(prob.order) alpha_length = length(prob.order) coef_end = nxf - nyi + 1 @@ -299,7 +299,7 @@ end function ABM_triangolo( cache::PECECache{iip, T}, nxi::P, nxf::P) where {P <: Integer, iip, T} - @unpack prob, mesh, u0, order, m_alpha, m_alpha_factorial, p, zn_pred, zn_corr, N, an, bn, a0, halpha1, halpha2, mu, abstol, index_fft, an_fft, bn_fft = cache + (; prob, mesh, order, p, zn_pred, zn_corr, N, an, bn, a0, halpha1, halpha2, mu, abstol) = cache alpha_length = length(order) problem_size = length(order) @@ -362,7 +362,7 @@ function ABM_triangolo( end function starting_term(cache::PECECache{iip, T}, t) where {iip, T} - @unpack mesh, m_alpha, u0, m_alpha_factorial, high_order_prob = cache + (; mesh, m_alpha, u0, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/fode/trapezoid.jl b/src/fode/trapezoid.jl index aea6fb14..9a2d5830 100644 --- a/src/fode/trapezoid.jl +++ b/src/fode/trapezoid.jl @@ -41,7 +41,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::Trapezoid; dt = 0.0, reltol = 1e-6, abstol = 1e-6, maxiters = 1000, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing prob = _is_need_convert!(prob) - @unpack f, order, u0, tspan, p = prob + (; f, order, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -89,8 +89,7 @@ function SciMLBase.__init(prob::FODEProblem, alg::Trapezoid; dt = 0.0, end function SciMLBase.solve!(cache::TrapezoidCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, u0, order, halpha, y, fy, zn, p, problem_size, m_alpha, m_alpha_factorial, r, N, Nr, Q, NNr, omega, w, s, dt, reltol, abstol, maxiters, kwargs = cache - t0 = mesh[1] + (; prob, alg, mesh, u0, order, halpha, y, fy, zn, p, problem_size, m_alpha, m_alpha_factorial, r, N, Nr, Q, NNr, omega, w, s, dt, reltol, abstol, maxiters, kwargs) = cache tfinal = mesh[end] TrapFirstApproximations(cache) @@ -121,7 +120,7 @@ end function TrapDisegnaBlocchi(cache::TrapezoidCache{iip, T}, L::P, ff, nx0::P, ny0::P) where {P <: Integer, iip, T} - @unpack mesh, y, fy, zn, abstol, maxiters, r, Nr, N, Jfdefun, s, w, omega, halpha, u0 = cache + (; r, Nr, N) = cache nxi::Int = copy(nx0) nxf::Int = copy(nx0 + L * r - 1) @@ -173,7 +172,7 @@ end function TrapQuadrato(cache::TrapezoidCache{iip, T}, nxi::P, nxf::P, nyi::P, nyf::P) where {P <: Integer, iip, T} - @unpack problem_size, omega = cache + (; problem_size, omega) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 @@ -188,8 +187,7 @@ end function TrapTriangolo( cache::TrapezoidCache{iip, T}, nxi::P, nxf::P, j0) where {P <: Integer, iip, T} - @unpack prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, u0, m_alpha, m_alpha_factorial, p = cache - t0 = mesh[1] + (; prob, mesh, problem_size, zn, Jfdefun, N, abstol, maxiters, s, w, omega, halpha, p) = cache for n in nxi:min(N, nxf) n1::Int = n + 1 St = TrapStartingTerm(cache, mesh[n1]) @@ -238,7 +236,7 @@ function TrapTriangolo( end function TrapFirstApproximations(cache::TrapezoidCache{iip, T}) where {iip, T} - @unpack prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, u0, m_alpha, m_alpha_factorial, p = cache + (; prob, mesh, abstol, problem_size, maxiters, s, halpha, omega, w, Jfdefun, p) = cache Im = zeros(problem_size, problem_size) + I Ims = zeros(problem_size * s, problem_size * s) + I Y0 = zeros(s * problem_size, 1) @@ -369,7 +367,7 @@ function TrapWeights(alpha, N) end function TrapStartingTerm(cache::TrapezoidCache{iip, T}, t) where {iip, T} - @unpack u0, m_alpha, mesh, m_alpha_factorial, high_order_prob = cache + (; u0, m_alpha, mesh, m_alpha_factorial, high_order_prob) = cache t0 = mesh[1] u0 = high_order_prob ? reshape(u0, 1, length(u0)) : u0 ys = zeros(size(u0, 1), 1) diff --git a/src/multitermsfode/closed_form.jl b/src/multitermsfode/closed_form.jl index 5b0852da..243538fb 100644 --- a/src/multitermsfode/closed_form.jl +++ b/src/multitermsfode/closed_form.jl @@ -15,7 +15,7 @@ ISBN:9787030543981 struct ClosedForm <: MultiTermsFODEAlgorithm end function solve(prob::MultiTermsFODEProblem, h, ::ClosedForm) - @unpack parameters, orders, rightfun, rparameters, rorders, u0, tspan = prob + (; parameters, orders, rightfun, rparameters, rorders, tspan) = prob t0 = tspan[1] T = tspan[2] D = sum(parameters ./ (h .^ orders)) diff --git a/src/multitermsfode/explicit_pi.jl b/src/multitermsfode/explicit_pi.jl index 49ccd2e8..f578584e 100644 --- a/src/multitermsfode/explicit_pi.jl +++ b/src/multitermsfode/explicit_pi.jl @@ -32,7 +32,7 @@ Base.eltype(::MTPIEXCache{T}) where {T} = T function SciMLBase.__init( prob::MultiTermsFODEProblem, alg::MTPIEX; dt = 0.0, abstol = 1e-6, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack parameters, orders, f, u0, tspan, p = prob + (; parameters, orders, f, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -90,7 +90,7 @@ function SciMLBase.__init( end function SciMLBase.solve!(cache::MTPIEXCache{T}) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, y, fy, p, zn, r, N, Nr, Qr, NNr, bn, kwargs = cache + (; prob, alg, mesh, y, r, N, Qr) = cache t0 = mesh[1] tfinal = mesh[end] MTPX_multiterms_triangolo(cache, 1, r - 1, t0) @@ -122,7 +122,7 @@ end function MTPX_multiterms_disegna_blocchi( cache::MTPIEXCache{T}, L, ff, nx0, nu0, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, r, N, Nr, Qr, NNr, bn, kwargs = cache + (; r, N, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 nyi::Int = nu0 @@ -175,7 +175,7 @@ function MTPX_multiterms_disegna_blocchi( end function MTPX_multiterms_quadrato(cache::MTPIEXCache{T}, nxi, nxf, nyi, nyf) where {T} - @unpack prob, alg, mesh, r, N, Nr, Qr, NNr, bn, kwargs = cache + (; prob, bn) = cache orders_length = length(prob.orders) problem_size = size(prob.u0, 2) coef_beg = nxi - nyf @@ -199,7 +199,7 @@ function MTPX_multiterms_quadrato(cache::MTPIEXCache{T}, nxi, nxf, nyi, nyf) whe end function MTPX_multiterms_triangolo(cache::MTPIEXCache{T}, nxi, nxf, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, r, N, Nr, Qr, NNr, bn, kwargs = cache + (; prob, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, N, bn) = cache problem_size = size(prob.u0, 2) orders_length = length(prob.orders) for n in nxi:min(N, nxf) diff --git a/src/multitermsfode/hankelmatrix.jl b/src/multitermsfode/hankelmatrix.jl index b3a435e9..ff315876 100644 --- a/src/multitermsfode/hankelmatrix.jl +++ b/src/multitermsfode/hankelmatrix.jl @@ -8,7 +8,7 @@ Use Closed-Form Hankel matrix algorithm to obtain numerical solution at zero ini struct ClosedFormHankelM <: MultiTermsFODEAlgorithm end function solve(prob::MultiTermsFODEProblem, h, ::ClosedFormHankelM) - @unpack parameters, orders, rightfun, rparameters, rorders, u0, tspan = prob + (; parameters, orders, rightfun, rparameters, rorders, tspan) = prob t0 = tspan[1] T = tspan[2] t = collect(t0:h:T) diff --git a/src/multitermsfode/implicit_pi_pece.jl b/src/multitermsfode/implicit_pi_pece.jl index 766f76ac..a0a4d0b4 100644 --- a/src/multitermsfode/implicit_pi_pece.jl +++ b/src/multitermsfode/implicit_pi_pece.jl @@ -39,7 +39,7 @@ Base.eltype(::MTPECECache{T}) where {T} = T function SciMLBase.__init( prob::MultiTermsFODEProblem, alg::MTPECE; dt = 0.0, abstol = 1e-6, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack parameters, orders, f, u0, tspan, p = prob + (; parameters, orders, f, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -112,7 +112,7 @@ function SciMLBase.__init( zn_corr, r, N, Nr, Qr, NNr, C, an, bn, a0, mu, abstol, kwargs) end function SciMLBase.solve!(cache::MTPECECache{T}) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, r, N, Nr, Qr, NNr, C, a0, an, bn, mu, abstol, kwargs = cache + (; prob, alg, mesh, u0, r, N, Qr) = cache t0 = mesh[1] tfinal = mesh[end] @@ -146,7 +146,7 @@ function SciMLBase.solve!(cache::MTPECECache{T}) where {T} end function MTPECE_disegna_blocchi(cache::MTPECECache{T}, L, ff, nx0, nu0, t0) where {T} - @unpack r, N = cache + (; r, N) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 @@ -200,7 +200,7 @@ function MTPECE_disegna_blocchi(cache::MTPECECache{T}, L, ff, nx0, nu0, t0) wher end function MTPECE_quadrato(cache::MTPECECache{T}, nxi, nxf, nyi, nyf) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, r, N, Nr, Qr, NNr, C, a0, an, bn, mu, abstol, kwargs = cache + (; prob, u0, an, bn, mu) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 @@ -254,7 +254,7 @@ function MTPECE_quadrato(cache::MTPECECache{T}, nxi, nxf, nyi, nyf) where {T} end function MTPECE_triangolo(cache::MTPECECache{T}, nxi, nxf, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn_pred, zn_corr, r, N, Nr, Qr, NNr, C, a0, an, bn, mu, abstol, kwargs = cache + (; prob, mesh, u0, bet, lam_rat_i, gamma_val, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn_pred, zn_corr, N, C, a0, an, bn, mu, abstol) = cache problem_size = size(u0, 1) orders_length = length(prob.orders) diff --git a/src/multitermsfode/implicit_pi_rectangle.jl b/src/multitermsfode/implicit_pi_rectangle.jl index 2cd049b9..ddb37ee8 100644 --- a/src/multitermsfode/implicit_pi_rectangle.jl +++ b/src/multitermsfode/implicit_pi_rectangle.jl @@ -37,7 +37,7 @@ Base.eltype(::MTPIRectCache{T}) where {T} = T function SciMLBase.__init(prob::MultiTermsFODEProblem, alg::MTPIRect; dt = 0.0, abstol = 1e-6, maxiters = 100, kwargs...) - @unpack parameters, orders, f, u0, tspan, p = prob + (; parameters, orders, f, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] u0 = u0[:]' @@ -100,7 +100,7 @@ function SciMLBase.__init(prob::MultiTermsFODEProblem, alg::MTPIRect; end function SciMLBase.solve!(cache::MTPIRectCache{T}) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, y, fy, p, zn, r, N, Nr, Qr, NNr, C, bn, abstol, maxiters, kwargs = cache + (; prob, alg, mesh, u0, y, r, N, Qr) = cache t0 = mesh[1] tfinal = mesh[end] MTPIRect_triangolo(cache, 1, r - 1, t0) @@ -132,7 +132,7 @@ function SciMLBase.solve!(cache::MTPIRectCache{T}) where {T} end function MTPIRect_disegna_blocchi(cache::MTPIRectCache{T}, L, ff, nx0, nu0, t0) where {T} - @unpack r, N, Nr = cache + (; r, N, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 nyi::Int = nu0 @@ -185,7 +185,7 @@ function MTPIRect_disegna_blocchi(cache::MTPIRectCache{T}, L, ff, nx0, nu0, t0) end function MTPIRect_quadrato(cache::MTPIRectCache{T}, nxi, nxf, nyi, nyf) where {T} - @unpack prob, u0 = cache + (; prob, u0) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 funz_beg = nyi + 1 @@ -220,7 +220,7 @@ function MTPIRect_quadrato(cache::MTPIRectCache{T}, nxi, nxf, nyi, nyf) where {T end function MTPIRect_triangolo(cache::MTPIRectCache{T}, nxi, nxf, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, r, N, Nr, Qr, NNr, C, bn, abstol, maxiters, kwargs = cache + (; prob, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, N, C, bn, abstol, maxiters) = cache problem_size = size(u0, 1) orders_length = length(prob.orders) diff --git a/src/multitermsfode/implicit_pi_trapezoid.jl b/src/multitermsfode/implicit_pi_trapezoid.jl index 4b9bbf03..a156c12e 100644 --- a/src/multitermsfode/implicit_pi_trapezoid.jl +++ b/src/multitermsfode/implicit_pi_trapezoid.jl @@ -39,7 +39,7 @@ Base.eltype(::MTPITrapCache{T}) where {T} = T function SciMLBase.__init(prob::MultiTermsFODEProblem, alg::MTPITrap; dt = 0.0, abstol = 1e-6, maxiters = 100, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack parameters, orders, f, u0, tspan, p = prob + (; parameters, orders, f, u0, tspan, p) = prob t0 = tspan[1] tfinal = tspan[2] T = eltype(u0) @@ -108,7 +108,7 @@ function SciMLBase.__init(prob::MultiTermsFODEProblem, alg::MTPITrap; end function SciMLBase.solve!(cache::MTPITrapCache{T}) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, y, fy, p, zn, r, N, Nr, Qr, NNr, C, an, a0, abstol, maxiters, kwargs = cache + (; prob, alg, mesh, u0, r, N, Qr) = cache t0 = mesh[1] tfinal = mesh[end] @@ -141,7 +141,7 @@ function SciMLBase.solve!(cache::MTPITrapCache{T}) where {T} end function MTPITrap_disegna_blocchi(cache::MTPITrapCache{T}, L, ff, nx0, nu0, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, r, N, Nr, Qr, NNr, C, an, a0, abstol, maxiters, kwargs = cache + (; r, N, Nr) = cache nxi::Int = nx0 nxf::Int = nx0 + L * r - 1 @@ -195,7 +195,7 @@ function MTPITrap_disegna_blocchi(cache::MTPITrapCache{T}, L, ff, nx0, nu0, t0) end function MTPITrap_quadrato(cache::MTPITrapCache{T}, nxi, nxf, nyi, nyf) where {T} - @unpack prob, u0, an = cache + (; prob, u0, an) = cache coef_beg = nxi - nyf coef_end = nxf - nyi + 1 @@ -231,7 +231,7 @@ function MTPITrap_quadrato(cache::MTPITrapCache{T}, nxi, nxf, nyi, nyf) where {T end function MTPITrap_triangolo(cache::MTPITrapCache{T}, nxi, nxf, t0) where {T} - @unpack prob, alg, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, r, N, Nr, Qr, NNr, C, an, a0, abstol, maxiters, kwargs = cache + (; prob, mesh, u0, bet, lam_rat_i, gamma_val, J, highest_order_parameter, highest_order_ceiling, other_orders_ceiling, p, zn, N, C, an, a0, abstol, maxiters) = cache orders_length = length(prob.orders) problem_size = size(u0, 1) diff --git a/src/multitermsfode/matrix.jl b/src/multitermsfode/matrix.jl index 570cd252..178fd51e 100644 --- a/src/multitermsfode/matrix.jl +++ b/src/multitermsfode/matrix.jl @@ -16,7 +16,7 @@ Base.eltype(::MatrixDiscreteCache{T}) where {T} = T function SciMLBase.__init( prob::MultiTermsFODEProblem, alg::MatrixDiscrete; dt = 0.0, kwargs...) dt ≤ 0 ? throw(ArgumentError("dt must be positive")) : nothing - @unpack parameters, orders, f, u0, tspan, p = prob + (; parameters, orders, f, u0, tspan, p) = prob T = eltype(u0) t0 = tspan[1] tfinal = tspan[2] @@ -45,7 +45,7 @@ function SciMLBase.__init( end function SciMLBase.solve!(cache::MatrixDiscreteCache{iip, T}) where {iip, T} - @unpack prob, alg, mesh, highest_order, equation, rightside, kwargs = cache + (; prob, alg, mesh, highest_order, equation, rightside) = cache result = equation \ rightside result = vcat(zeros(highest_order), result) y = collect(Vector{eltype(result)}, eachrow(result)) diff --git a/src/types/problems.jl b/src/types/problems.jl index 62626d58..bb37fa1e 100644 --- a/src/types/problems.jl +++ b/src/types/problems.jl @@ -197,8 +197,6 @@ struct FODEProblem{uType, tType, oType, isinplace, P, F, bF, PT, K} <: end end -TruncatedStacktraces.@truncate_stacktrace FODEProblem 3 1 2 - function FODEProblem(f::SciMLBase.AbstractODEFunction, order, u0, tspan, args...; kwargs...) FODEProblem{SciMLBase.isinplace(f, 4)}(f, order, u0, tspan, args...; kwargs...) end @@ -332,8 +330,6 @@ struct FDDEProblem{uType, tType, oType, lType, isinplace, P, F, H, K, PT} <: end end -TruncatedStacktraces.@truncate_stacktrace FDDEProblem 5 1 2 - FDDEProblem(f, args...; kwargs...) = FDDEProblem(DDEFunction(f), args...; kwargs...) function FDDEProblem(f::SciMLBase.AbstractDDEFunction, args...; kwargs...) From 5f21d44ce73ab27337294b7daaf641bf0bf0ab35 Mon Sep 17 00:00:00 2001 From: ErikQQY <2283984853@qq.com> Date: Wed, 18 Sep 2024 23:52:30 +0800 Subject: [PATCH 2/3] Fix wrong using error Signed-off-by: ErikQQY <2283984853@qq.com> --- src/FractionalDiffEq.jl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/FractionalDiffEq.jl b/src/FractionalDiffEq.jl index 3f027ec8..dd22020e 100644 --- a/src/FractionalDiffEq.jl +++ b/src/FractionalDiffEq.jl @@ -1,8 +1,7 @@ module FractionalDiffEq using LinearAlgebra, Reexport, SciMLBase, SpecialFunctions, SparseArrays, ToeplitzMatrices, - FFTW, RecipesBase, ForwardDiff, Polynomials, TruncatedStacktraces, - HypergeometricFunctions, DiffEqBase, ConcreteStructs + FFTW, RecipesBase, ForwardDiff, Polynomials, HypergeometricFunctions, DiffEqBase, ConcreteStructs import SciMLBase: __solve import DiffEqBase: solve @@ -10,7 +9,6 @@ import InvertedIndices: Not import SpecialMatrices: Vandermonde import FFTW: fft, ifft import Polynomials: Polynomial -import TruncatedStacktraces: @truncate_stacktrace @reexport using DiffEqBase, SciMLBase From a24d03c065380741772b32011d3c75bbccb5f8ed Mon Sep 17 00:00:00 2001 From: ErikQQY <2283984853@qq.com> Date: Wed, 18 Sep 2024 23:58:13 +0800 Subject: [PATCH 3/3] update Project.toml Signed-off-by: ErikQQY <2283984853@qq.com> --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 30ac70df..cbdf180d 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "FractionalDiffEq" uuid = "c7492dd8-6170-483b-af64-cefb6c377d9a" authors = ["Qingyu Qu "] -version = "0.3.5" +version = "0.3.6" [deps] ConcreteStructs = "2569d6c7-a4a2-43d3-a901-331e8e4be471"