complex numbers?

30 views
Skip to first unread message

Bob Carpenter

unread,
Mar 5, 2016, 2:38:03 PM3/5/16
to stan...@googlegroups.com
[moved to stan-dev for general discussion]

Expose to what? Do you mean having something in
the language like:

complex a;

with some support for something like

real real_part(complex a);
real complex_part(complex a);

And then support through all the containers (matrices/vectors
and arrays) and user-defined functions.

And what about basic arithmetic operators? Other functions?

I think we could cobble together some I/O format---I don't know
if there's a usual way to do this in any of the interface
languages already.

- Bob

> On Mar 5, 2016, at 12:21 PM, Michael Betancourt <notifi...@github.com> wrote:
>
> Exposing a complex type which is just a pair would be
> handy as we could then expose FFTs.
>
> On Mar 4, 2016, at 10:38 PM, bgoodri <notifi...@github.com> wrote:
>
> > I think we should put off the idea of auto-diffing complex vars but fix the original issue that Stan Math can be compiled a std::complex<stan::math::var>.
> >
> > —
> > Reply to this email directly or view it on GitHub.
> >
>
> —
> Reply to this email directly or view it on GitHub.
>

Ben Goodrich

unread,
Mar 5, 2016, 3:50:15 PM3/5/16
to stan development mailing list
On Saturday, March 5, 2016 at 2:38:03 PM UTC-5, Bob Carpenter wrote:
[moved to stan-dev for general discussion]

Expose to what?  Do you mean having something in
the language like:

  complex a;

I am thinking that

complex a;

in the Stan language would parse to

pair(double, double)

in C++ for the real and imaginary parts respectively. But any function taking a pair scalar type would have to deal with its parts separately.

I think we need to specialize the constructor so that

std::complex<stan::math::var> x;


is a compile-time error.

Ben

Bob Carpenter

unread,
Mar 7, 2016, 12:57:04 AM3/7/16
to stan...@googlegroups.com
It seems odd to create a specialized constructor for
a class we don't support, though if we were going to
do it anywhere, it'd be in the std lib.

- Bob
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Ben Goodrich

unread,
Mar 7, 2016, 1:16:49 AM3/7/16
to stan development mailing list
On Monday, March 7, 2016 at 12:57:04 AM UTC-5, Bob Carpenter wrote:
It seems odd to create a specialized constructor for
a class we don't support, though if we were going to
do it anywhere, it'd be in the std lib.

That's what I mean. If we are not going to support genuine complex numbers, we shouldn't permit


std::complex<stan::math:var> x;

to compile.

Ben

Reply all
Reply to author
Forward
0 new messages