marius311 / CMBLensing.jl

The automatically differentiable and GPU-compatible toolkit for CMB analysis.
https://cosmicmar.com/CMBLensing.jl
Other
52 stars 11 forks source link

Allow scalars and Arrays in FieldTuples #80

Open marius311 opened 2 years ago

marius311 commented 2 years ago

Eg:


using CMBLensing, LinearAlgebra

f = FlatMap(rand(10,10))
ft = FieldTuple(;f, AL=1., r=0, Aϕ=[1,2])

ft2 = ft .+ ft # broadcasting works
ft3 = Diagonal(ft2) * ft # diagonal operators
ft3'ft3 # inner prod
(;f, AL) = ft2 # unpacking components

gradient(ft -> norm(Diagonal(ft)*ft), ft)[1] # gradients work