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

Sbuercklin/simple array rules #13

Merged
merged 2 commits into from
Aug 9, 2022
Merged

Conversation

SBuercklin
Copy link
Owner

Addresses #12 by implementing rrules for A * s, s * A, A / b where A is an AbstractArray, s is a scalar, and at least one eltype(A) or eltype(s) is a Unitful.Quantity.

This was a little tricky because we had to define two different rrules so as to not overwrite the default methods for CommutativeMulNumber in ChainRules.jl. The definitions here guarantee that:

  1. We have Quantity{T,D,U} where T <: Union{Real,Complex} for all Quantitys involved, basically enforcing the CommutativeMulNumber requirement on the backing value
  2. We have at least one Quantity involved, either in the AbstractArray or the scalar. This means we do not invalidate ChainRules.jl. This lets us e.g. multiply an array of Quantitys by a scalar

@SBuercklin SBuercklin merged commit dde0633 into main Aug 9, 2022
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.

1 participant