You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TMB Users
Hi
I have been trying to implement a fast Fourier transform in TMB. I tired to create an example below but I'm struggling. ChatGPT suggest that there's an issue that Eigen::FFT does not directly support the AD:
// Add your model code here PARAMETER(a); Type nll = pow(a, Type(2.0)); return nll; }
Is it possible to do this?
Cheers
Mike
Ben Bolker
unread,
May 25, 2023, 2:26:48 PM5/25/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to tmb-...@googlegroups.com
I'm skimming the surface here, but is this a case where you can
write a new atomic function that defines the FFT *and* its derivative
(since everything is linear the derivative should be easy?
https://kaskr.github.io/adcomp/AtomicFunctions.html
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to TMB Users
I agree with Ben that fft should be made as an atomic function. It is essentially a special case of atomic matrix multiply where the left operand is constant, so 'atomic::matmul' can be used as inspiration. I would expect the adjoint code requires the inverse fft, so one would actually need two new atomics 'fft' and 'ifft'. Also note that these atomics do not accept complex input/output. Manual splitting/unsplitting real- and imag parts would be needed. Given that this is not completely straight-forward, I'm thinking it might be a useful addition to TMB. For portability reasons it's probably worth considering R's fft C-side entry point (if available).
Ben Bolker
unread,
May 27, 2023, 8:02:42 PM5/27/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to tmb-...@googlegroups.com
For what it's worth, _Numerical Recipes_ (Press et al) give an
implementation of FFT (and inverse-FFT) for real, symmetric series (so
that all imaginary parts are zero going in either direction) that
packs/unpacks the input arrays so that the algorithm doesn't
unnecessarily carry the redundant half/zero imaginary values around.
The code should be available from the old editions of the books on
their web site; licensing doesn't allow you to directly cut and paste
the code, but if this is your actual use case it shouldn't be hard to
modify it enough to make it legal.
I don't know if that would be better/easier than using R's
implementation and dealing with the imaginary parts.
> <https://github.com/kaskr/adcomp/>>.
> > Please try to create a simple repeatable example to go with your
> > question (e.g issues 154, 134, 51). Use the issuetracker to
> report bugs.
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "TMB Users" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to tmb-users+...@googlegroups.com > > <mailto:tmb-users+...@googlegroups.com>.
> > To view this discussion on the web visit
> >
>
> --
> To post to this group, send email to us...@tmb-project.org. Before
> posting, please check the wiki and issuetracker at
> https://github.com/kaskr/adcomp/ <https://github.com/kaskr/adcomp/>.
> Please try to create a simple repeatable example to go with your
> question (e.g issues 154, 134, 51). Use the issuetracker to report bugs.
> ---
> You received this message because you are subscribed to the Google
> Groups "TMB Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to tmb-users+...@googlegroups.com > <mailto:tmb-users+...@googlegroups.com>.
> To view this discussion on the web visit