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

Macros for "directional derivatives" #20

Closed
ChrisRackauckas opened this issue Jul 6, 2017 · 2 comments
Closed

Macros for "directional derivatives" #20

ChrisRackauckas opened this issue Jul 6, 2017 · 2 comments

Comments

@ChrisRackauckas
Copy link
Member

In 2D doing directions is easy. A*u vs u*A. In 3D it's harder. What you instead need to do is, for example, slice u along z and apply A*u in a loop (if u is a 3D tensor). This technique handles all directions and scales to nD. It would be nice to make it easier on the user.

I proposed something like *(A,u,1) meaning "differentiate through axis 1 (x)", etc, which would do the following:

for i in 1:size(u,3)
  A*view(u,:,:,i)
end

and of course generalizing to ND (the library EllipsisNotation.jl could be helpful here). Taking it to the next level, maybe we can have a macro:

@dimensional Ax*u + Ay*u + Az*u + f(x,y,z)

which interprets the multiplications as being along axis 1,2,3. That's of course far down the line.

@shivin9
Copy link
Contributor

shivin9 commented Jul 6, 2017

Now we can do mixed derivatives also by applying the operator along different axes. That can be an alternate implementation of composed operators instead of having 2D stencils.

@ChrisRackauckas
Copy link
Member Author

Now we can do mixed derivatives also by applying the operator along different axes. That can be an alternate implementation of composed operators instead of having 2D stencils.

They are 1D stencils. It's just a funny and useful trick of linear algebra that u*A does the opposite direction stencil. By slicing along u you get matrices to then repeatedly apply the 1D stencil and do the derivative on an nD object.

xtalax added a commit to grahamas/DiffEqOperators.jl that referenced this issue May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants