powers

47 views
Skip to first unread message

Andrew Gelman

unread,
May 15, 2014, 4:29:09 PM5/15/14
to stan...@googlegroups.com
Just wondering, would it be hard for us to implement a^b instead of pow(a,b)?

Bob Carpenter

unread,
May 15, 2014, 6:20:57 PM5/15/14
to stan...@googlegroups.com
Nope, not that hard at all for scalars. A bit harder
to vectorize, but still not that hard. Probably a day or
two if I need to vectorize. I created an issue:

https://github.com/stan-dev/stan/issues/648

It's fast-tracked to the back-burner, like other new function
requests.

This needs to get into the parser and code generator and I'd
be happy to help out on that end if someone else wanted to take it on.

- Bob

On May 15, 2014, at 10:29 PM, Andrew Gelman <gel...@stat.columbia.edu> wrote:

> Just wondering, would it be hard for us to implement a^b instead of pow(a,b)?
>
> --
> 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.
>

Mitzi Morris

unread,
Jun 3, 2014, 8:28:27 AM6/3/14
to stan...@googlegroups.com
On Friday, May 16, 2014 12:20:57 AM UTC+2, Bob Carpenter wrote:
> Nope, not that hard at all for scalars. A bit harder
> to vectorize, but still not that hard. Probably a day or
> two if I need to vectorize. I created an issue:
>
> https://github.com/stan-dev/stan/issues/648
>

I've played with the parser and it can handle the infix operator
for scalar exponentiation.

BUT the stan pow function always returns a real value,
therefore, cannot assign the result of raising an integer to
a positive int power to an int.

Mitzi Morris

unread,
Jun 3, 2014, 8:31:39 AM6/3/14
to stan...@googlegroups.com

Bob just leaned over my shoulder and pointed out that I've answered
my own question - we can't assign an int raised to an int to an int
because the exponent may be a negative int.

Reply all
Reply to author
Forward
0 new messages