I defined the following struture
struct AB{T}
A::T
B::T
end
with two components of the same numerical type. Sometimes I need to swap the two such that A=-B and B=A. Is there a way to avoid actual swapping the value and just “mark” the swapping such that subsequent computations will treat A as B and -B as A? I’m interested in storing an array of AB type as a StructArray{AB}, which makes sense to not actually swap the arrays.
How can this be done? I’m looking for something like the adjoint(::Matrix...) markup of numerical arrays. Thank you for any suggestions.