From 2a89e1f478a489fb57eccba23c3d3d0712641451 Mon Sep 17 00:00:00 2001 From: Chris Rackauckas Date: Sun, 5 Apr 2020 16:38:36 -0400 Subject: [PATCH] add README example --- test/examples.jl | 16 ++++++++++++++++ test/runtests.jl | 1 + 2 files changed, 17 insertions(+) create mode 100644 test/examples.jl diff --git a/test/examples.jl b/test/examples.jl new file mode 100644 index 0000000..ad8185b --- /dev/null +++ b/test/examples.jl @@ -0,0 +1,16 @@ +fcalls = 0 +function f(dx,x) + global fcalls += 1 + for i in 2:length(x)-1 + dx[i] = x[i-1] - 2x[i] + x[i+1] + end + dx[1] = -2x[1] + x[2] + dx[end] = x[end-1] - 2x[end] + nothing +end + +using SparsityDetection, SparseArrays +input = rand(10) +output = similar(input) +sparsity_pattern = sparsity!(f,output,input) +jac = Float64.(sparse(sparsity_pattern)) diff --git a/test/runtests.jl b/test/runtests.jl index 6086591..b52cfc4 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,4 +5,5 @@ include("common.jl") @testset "Exploration" begin include("ifsandbuts.jl") end @testset "Hessian sparsity" begin include("hessian.jl") end @testset "Paraboloid example" begin include("paraboloid.jl") end +@safetestset "Simple examples" begin include("examples.jl") end @safetestset "Global PDE example" begin include("global_PDE.jl") end