Skip to content

backwards diffs for JopGradient on edges - #32

Open
jkwashbourne-oss wants to merge 1 commit into
masterfrom
wask/gradient-backwards-diffs
Open

backwards diffs for JopGradient on edges#32
jkwashbourne-oss wants to merge 1 commit into
masterfrom
wask/gradient-backwards-diffs

Conversation

@jkwashbourne-oss

@jkwashbourne-oss jkwashbourne-oss commented Jun 22, 2024

Copy link
Copy Markdown
Member

adds backwards one sided diffs on the edges where previously no derivatives were computed.

thinking more about it, perhaps this results in unexpected behavior, since the last two points in the dimension we are taking the derivatives will have the same value.

julia> nz,nx = 5,5
(5, 5)

julia> dz,dx = 25.0,25.0
(25.0, 25.0)

julia> G = JopGradient(JetSpace(Float32,nz,nx), (Float32(dz), Float32(dx)))
"Jet linear operator, (5, 5) → (5, 5, 2)"

julia> x = rand(Float32,nz,nx)
5×5 Matrix{Float32}:
 0.957345   0.534336   0.144943  0.424699  0.727155
 0.449017   0.886986   0.303386  0.235856  0.764744
 0.980932   0.391082   0.116915  0.202955  0.598075
 0.0956441  0.0800584  0.623844  0.639636  0.365211
 0.532148   0.491575   0.325524  0.058127  0.24094

julia> G*x
5×5×2 Array{Float32, 3}:
[:, :, 1] =
 -0.0203331   0.014106    0.00633772  -0.00755372   0.00150356
  0.0212766  -0.0198362  -0.00745887  -0.00131601  -0.00666677
 -0.0354115  -0.0124409   0.0202772    0.0174672   -0.00931453
  0.0174601   0.0164607  -0.0119328   -0.0232604   -0.00497085
  0.0174601   0.0164607  -0.0119328   -0.0232604   -0.00497085

[:, :, 2] =
 -0.0169204    -0.0155757    0.0111902     0.0120983    0.0120983
  0.0175188    -0.023344    -0.00270122    0.0211555    0.0211555
 -0.023594     -0.0109667    0.00344164    0.0158048    0.0158048
 -0.000623429   0.0217514    0.000631707  -0.010977    -0.010977
 -0.00162291   -0.00664205  -0.0106959     0.00731252   0.00731252

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