Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit b8fac52

Browse files
author
Avik Pal
committed
Conditional dep on Zygote
1 parent 4bd65ab commit b8fac52

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

Project.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DiffEqOperators"
22
uuid = "9fdde737-9c7f-55bf-ade8-46b3f136cc48"
33
authors = ["Chris Rackauckas <[email protected]>"]
4-
version = "4.32.0"
4+
version = "4.33.0"
55

66
[deps]
77
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
@@ -16,14 +16,14 @@ LoopVectorization = "bdcacae8-1622-11e9-2a5c-532679323890"
1616
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1717
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
1818
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
19+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1920
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
2021
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2122
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2223
SparseDiffTools = "47a9eef4-7e08-11e9-0b38-333d64bd3804"
2324
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
2425
SuiteSparse = "4607b0f0-06f3-5cda-b6b1-a6196a1729e9"
2526
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
26-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
2727

2828
[compat]
2929
BandedMatrices = "0.15.11, 0.16"
@@ -39,6 +39,7 @@ NNlib = "0.6, 0.7"
3939
NonlinearSolve = "0.3.7"
4040
RuntimeGeneratedFunctions = "0.4, 0.5"
4141
SciMLBase = "1.11"
42+
SparseDiffTools = "1.17"
4243
StaticArrays = "0.10, 0.11, 0.12, 1.0"
4344
SymbolicUtils = "0.11, 0.12, 0.13, 0.14, 0.15, 0.16"
4445
julia = "1"
@@ -51,6 +52,7 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5152
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
5253
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
5354
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
55+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
5456

5557
[targets]
56-
test = ["FillArrays", "OrdinaryDiffEq", "Parameters", "Random", "SafeTestsets", "SpecialFunctions", "Test"]
58+
test = ["FillArrays", "OrdinaryDiffEq", "Parameters", "Random", "SafeTestsets", "SpecialFunctions", "Test", "Zygote"]

docs/src/operators/vector_jacobian_product.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,6 @@ VecJacOperator{T}(f,u::AbstractArray,p=nothing,t::Union{Nothing,Number}=nothing;
77
The `VecJacOperator` is a linear operator `J'*v` where `J` acts like `df/du`
88
for some function `f(u,p,t)`. For in-place operations `mul!(w,J,v)`, `f`
99
is an in-place function `f(du,u,p,t)`.
10+
11+
!!! note
12+
This operator is available when `Zygote` is imported.

src/DiffEqOperators.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import LinearAlgebra: mul!, ldiv!, lmul!, rmul!, axpy!, opnorm, factorize, I
77
import DiffEqBase: update_coefficients!, isconstant
88
using SciMLBase: AbstractDiffEqLinearOperator, AbstractDiffEqCompositeOperator, DiffEqScaledOperator
99
import SciMLBase: getops
10-
using Zygote # SparseDiffTools has conditional dep on Zygote
1110
using SparseDiffTools
1211
using SparseArrays, ForwardDiff, BandedMatrices, NNlib, LazyArrays, BlockBandedMatrices, LoopVectorization
1312
using LazyBandedMatrices, ModelingToolkit
1413
using RuntimeGeneratedFunctions
14+
using Requires
1515
RuntimeGeneratedFunctions.init(@__MODULE__)
1616

1717
abstract type AbstractDiffEqAffineOperator{T} end
@@ -21,7 +21,6 @@ abstract type AbstractMatrixFreeOperator{T} <: AbstractDiffEqLinearOperator{T} e
2121
### Matrix-free Operators
2222
include("matrixfree_operators.jl")
2323
include("jacvec_operators.jl")
24-
include("vecjac_operators.jl")
2524

2625
### Utilities
2726
include("utils.jl")
@@ -66,9 +65,16 @@ for T in [DiffEqScaledOperator, DiffEqOperatorCombination, DiffEqOperatorComposi
6665
(L::T)(du,u,p,t) = (update_coefficients!(L,u,p,t); mul!(du,L,u))
6766
end
6867

68+
function __init__()
69+
@require Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" begin
70+
export VecJacOperator
71+
72+
include("vecjac_operators.jl")
73+
end
74+
end
75+
6976
export MatrixFreeOperator
7077
export AnalyticalJacVecOperator, JacVecOperator, getops
71-
export VecJacOperator
7278
export AbstractDerivativeOperator, DerivativeOperator,
7379
CenteredDifference, UpwindDifference, nonlinear_diffusion, nonlinear_diffusion!,
7480
GradientOperator, Gradient, CurlOperator, Curl, DivergenceOperator, Divergence

0 commit comments

Comments
 (0)