Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taking inplace Jacobian for AbstractArray #14

Merged
merged 1 commit into from
Aug 20, 2017

Conversation

YingboMa
Copy link
Member

@YingboMa YingboMa commented Aug 20, 2017

The following code will work after this fix.

julia> using BandedMatrices

julia> mutable struct BVPJacobianWrapper{LossType,CacheType} <: Function
         loss::LossType
         x1::CacheType
         fx1::CacheType
       end

julia> (p::BVPJacobianWrapper)(resid,u) = p.loss(u,resid)

julia> (p::BVPJacobianWrapper)(u) = (resid = similar(u); p.loss(u,resid); resid)

julia> loss!(x, resid) = @. resid = sin(tan(x)) * cos(x)
loss! (generic function with 1 method)

julia> f! = BVPJacobianWrapper(loss!, Vector{Float64}(5), Vector{Float64}(5)); J = bzeros(5,5,1,1); x = ones(5); resid = similar(x)
5-element Array{Float64,1}:
 0.0
 0.0
 0.0
 0.0
 0.0

julia> DiffEqDiffTools.finite_difference_jacobian!(J, f!, x, Val{:central}, resid, Val{:JacobianWrapper})
5×5 BandedMatrices.BandedMatrix{Float64}:
 -0.816616   0.0
  0.0       -0.816616   0.0
             0.0       -0.816616   0.0
                        0.0       -0.816616   0.0
                                   0.0       -0.816616

@coveralls
Copy link

coveralls commented Aug 20, 2017

Coverage Status

Coverage remained the same at 43.59% when pulling 63c18df on YingboMa:master into d21022e on JuliaDiffEq:master.

@ChrisRackauckas
Copy link
Member

Nice! That is really cool.

@ChrisRackauckas ChrisRackauckas merged commit 1156c83 into JuliaDiff:master Aug 20, 2017
@codecov
Copy link

codecov bot commented Aug 20, 2017

Codecov Report

Merging #14 into master will decrease coverage by 9.24%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #14      +/-   ##
==========================================
- Coverage   43.58%   34.34%   -9.25%     
==========================================
  Files           1        1              
  Lines         156      198      +42     
==========================================
  Hits           68       68              
- Misses         88      130      +42
Impacted Files Coverage Δ
src/finitediff.jl 34.34% <0%> (-9.25%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d21022e...63c18df. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants