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

Add ArrayDifferentialOperators for Vector calculus #942

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

xtalax
Copy link
Contributor

@xtalax xtalax commented Aug 1, 2023

Adds Vector calculus operators which are composable by the dot and cross product.

A request for comment on a good design so that equations with these display intelligibly

@codecov-commenter
Copy link

codecov-commenter commented Aug 4, 2023

Codecov Report

Merging #942 (068ad64) into master (60d26bb) will increase coverage by 0.44%.
The diff coverage is 1.72%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the GitHub App Integration for your organization. Read more.

@@            Coverage Diff            @@
##           master    #942      +/-   ##
=========================================
+ Coverage    8.35%   8.80%   +0.44%     
=========================================
  Files          26      26              
  Lines        3267    3318      +51     
=========================================
+ Hits          273     292      +19     
- Misses       2994    3026      +32     
Files Changed Coverage Δ
src/diff.jl 0.29% <0.00%> (-0.06%) ⬇️
src/arrays.jl 12.18% <100.00%> (+0.55%) ⬆️

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@xtalax
Copy link
Contributor Author

xtalax commented Aug 21, 2023

Core fails look unrelated

@xtalax xtalax changed the title WIP Add ArrayDifferentialOperators for Vector calculus [Awaiting Review] Add ArrayDifferentialOperators for Vector calculus Aug 21, 2023
src/diff.jl Outdated
@@ -1,4 +1,5 @@
abstract type Operator <: Function end
abstract type AbstractOperator <: Function end
abstract type Operator <: AbstractOperator end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need 2 of these?

src/diff.jl Outdated
abstract type ArrayOperator end

struct ArrayDifferentialOperator <: ArrayOperator
"""The variables to differentiate with resp≈ect to."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@shashi
Copy link
Member

shashi commented Aug 25, 2023

2 things:

  1. There are extra Abstract types, I don't like creating type hierarchy until it leads to code reuse with dispatch. Until then, just use concrete types.
  2. Ideally I'd want to give Differential itself dimensions. So Differential(x) behaves like d/dx for scalar, but Differential(x) behaves like Nabla for x::Vector. Can achieve nabla by just parameterizing Differential with the type of x. It seems like all the other operators you added can still be expressed in these terms.

Base.:*(D1::Differential, D2::Differential) = D1 ∘ D2
Base.:^(D::Differential, n::Integer) = _repeat_apply(D, n)
Base.:*(D1, D2::Operator) = D1 ∘ D2
Base.:*(D1::Operator, D2) = D1 ∘ D2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we have these methods @ChrisRackauckas ? this does not make sense in general, only maybe for 2 operators

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's a case where they don't make sense?

@xtalax
Copy link
Contributor Author

xtalax commented Aug 25, 2023

Ideally I'd want to give Differential itself dimensions. So Differential(x) behaves like d/dx for scalar, but Differential(x) behaves like Nabla for x::Vector. Can achieve nabla by just parameterizing Differential with the type of x. It seems like all the other operators you added can still be expressed in these terms.

The reason I have done this is that operators are often combined together, so the elements of differentials are not necessarily differentials, but can in general be other functions too.

src/diff.jl Outdated Show resolved Hide resolved
@xtalax xtalax changed the title [Awaiting Review] Add ArrayDifferentialOperators for Vector calculus Add ArrayDifferentialOperators for Vector calculus Sep 4, 2023
@ChrisRackauckas
Copy link
Member

What's left here?

@raphaelchinchilla
Copy link
Contributor

What is the status of this PR?

@ChrisRackauckas
Copy link
Member

Stale, someone would need to revive it.

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.

5 participants