You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a big codebase that uses FieldVectors from static arrays. It would be extremely powerful for us (and I'm sure many others in the future) to be able to do the following:
using StaticArrays
using ForwardDiff
struct Point{R<:Real} <:FieldVector{2,R}
x::R
y::Rend
StaticArrays.similar_type(p::Type{P}, ::Type{R}, size::Size{(2,)}) where {P<:Point, R<:Real} = Point{R}
f(p) = p.x
ForwardDiff.gradient(f, Point(2.0,3.0))
Currently this fails with ERROR: LoadError: type MArray has no field x because it's trying to evaluate f with an MArray of Duals.
This seems pretty easy to fix - maybe just writing a new version of dualize and adding a little more code where you have specialized things for SArray to also handle FieldVector. Do you think it is that simple? Should we take a crack at it, or do you foresee massive difficulties?
This seems pretty easy to fix - maybe just writing a new version of dualize and adding a little more code where you have specialized things for SArray to also handle FieldVector. Do you think it is that simple? Should we take a crack at it, or do you foresee massive difficulties?
Seems like a good idea!
If FieldVectors have similar indexing behavior to SVectors, you might even be able to just tweak the current SArray-specialized methods in order to achieve this (instead of adding new methods just for FieldVector).
Hi all,
We have a big codebase that uses
FieldVector
s from static arrays. It would be extremely powerful for us (and I'm sure many others in the future) to be able to do the following:Currently this fails with
ERROR: LoadError: type MArray has no field x
because it's trying to evaluatef
with an MArray of Duals.This seems pretty easy to fix - maybe just writing a new version of
dualize
and adding a little more code where you have specialized things forSArray
to also handleFieldVector
. Do you think it is that simple? Should we take a crack at it, or do you foresee massive difficulties?cc: @kylejbrown17 @MaximeBouton
The text was updated successfully, but these errors were encountered: