From d4563e071c203bb3bcbaf7e502de6d606d188e3c Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 18 Oct 2024 11:38:02 -0400 Subject: [PATCH 1/3] SplitFunction W_prototype fixes A few minor improvements to https://github.com/SciML/SciMLBase.jl/pull/816 --- src/scimlfunctions.jl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index e783c5277..b331684d6 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -455,6 +455,7 @@ SplitFunction{iip,specialize}(f1,f2; jvp = __has_jvp(f1) ? f1.jvp : nothing, vjp = __has_vjp(f1) ? f1.vjp : nothing, jac_prototype = __has_jac_prototype(f1) ? f1.jac_prototype : nothing, + W_prototype = __has_W_prototype(f1) ? f1.W_prototype : nothing, sparsity = __has_sparsity(f1) ? f1.sparsity : jac_prototype, paramjac = __has_paramjac(f1) ? f1.paramjac : nothing, colorvec = __has_colorvec(f1) ? f1.colorvec : nothing, @@ -484,6 +485,11 @@ the usage of the `SplitFunction`. These include: as the prototype and integrators will specialize on this structure where possible. Non-structured sparsity patterns should use a `SparseMatrixCSC` with a correct sparsity pattern for the Jacobian. The default is `nothing`, which means a dense Jacobian. +- `jac_prototype`: a prototype matrix matching the type that matches the W matrix. For example, + if the Jacobian is tridiagonal, and the mass_matrix is diagonal, then an appropriately sized `Tridiagonal` + matrix can be used as the prototype and integrators will specialize on this structure where possible. Non-structured + sparsity patterns should use a `SparseMatrixCSC` with a correct sparsity pattern for the W matrix. + The default is `nothing`, which means a W of appropriate type for the jacobian and linear solver - `paramjac(pJ,u,p,t)`: returns the parameter Jacobian ``\frac{df_1}{dp}``. - `colorvec`: a color vector according to the SparseDiffTools.jl definition for the sparsity pattern of the `jac_prototype`. This specializes the Jacobian construction when using @@ -3080,7 +3086,7 @@ SDEFunction(f::SDEFunction; kwargs...) = f @add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, - jac_prototype, Wfact, Wfact_t, paramjac, observed, + jac_prototype, W_prototype Wfact, Wfact_t, paramjac, observed, colorvec, sys) f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1) f2 = SDEFunction(f2) @@ -3091,7 +3097,7 @@ SDEFunction(f::SDEFunction; kwargs...) = f typeof(Wfact), typeof(Wfact_t), typeof(paramjac), typeof(observed), typeof(colorvec), typeof(sys)}(f1, f2, mass_matrix, cache, analytic, tgrad, jac, - jac_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys) + jac_prototype, W_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys) end function SplitSDEFunction{iip, specialize}(f1, f2, g; From 3d99bb935e54649a81a42a2163c22d77a65c5982 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Fri, 18 Oct 2024 12:07:49 -0400 Subject: [PATCH 2/3] typo --- src/scimlfunctions.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index b331684d6..04c9ad5fb 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -3086,7 +3086,7 @@ SDEFunction(f::SDEFunction; kwargs...) = f @add_kwonly function SplitSDEFunction(f1, f2, g, mass_matrix, cache, analytic, tgrad, jac, jvp, vjp, - jac_prototype, W_prototype Wfact, Wfact_t, paramjac, observed, + jac_prototype, W_prototype, Wfact, Wfact_t, paramjac, observed, colorvec, sys) f1 = f1 isa AbstractSciMLOperator ? f1 : SDEFunction(f1) f2 = SDEFunction(f2) From 480c1d8d41680769e32220d37d3149c0a900fb2f Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Fri, 18 Oct 2024 22:37:05 -0400 Subject: [PATCH 3/3] Update src/scimlfunctions.jl --- src/scimlfunctions.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scimlfunctions.jl b/src/scimlfunctions.jl index 04c9ad5fb..c62e8d838 100644 --- a/src/scimlfunctions.jl +++ b/src/scimlfunctions.jl @@ -485,7 +485,7 @@ the usage of the `SplitFunction`. These include: as the prototype and integrators will specialize on this structure where possible. Non-structured sparsity patterns should use a `SparseMatrixCSC` with a correct sparsity pattern for the Jacobian. The default is `nothing`, which means a dense Jacobian. -- `jac_prototype`: a prototype matrix matching the type that matches the W matrix. For example, +- `W_prototype`: a prototype matrix matching the type that matches the W matrix. For example, if the Jacobian is tridiagonal, and the mass_matrix is diagonal, then an appropriately sized `Tridiagonal` matrix can be used as the prototype and integrators will specialize on this structure where possible. Non-structured sparsity patterns should use a `SparseMatrixCSC` with a correct sparsity pattern for the W matrix.