-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
elementwise (vectorized) functions #96
Comments
From @bgoodri on May 27, 2015 20:23 According to
That just leaves std::vector containers. |
From @bob-carpenter on May 27, 2015 23:36 The Eigen method The I was thinking of using a static class function specified
In this scheme, there's no functor passed around or constructed---instead
It saves on building constructors. It's less good if we need to put Eigen's might be a lot faster if they can somehow construct and return Then we need base cases like this:
and a recursive case like:
And then we'd need to create appropriate class wrappers, such as:
And then we define:
and we're done We have all the vectorized forms of cos And these all play nice and generally with our variants of cos.
|
This is duplicative of #202 |
From @bob-carpenter on May 27, 2015 19:3
All of our unary scalar functions should be vectorized to work elementwise with the same names on any container, including
For binary or larger operations, this should work so that either the dimensions match of the two arguments or one argument is a scalar that is broadcast. For example,
pow(matrix,matrix)
orpow(matrix,double)
orpow(double,matrix)
should all return a matrix.An even more ambitious goal is to do this kind of vectorization and broadcasting for arguments that aren't simple scalars. So we'd have
matrix[] inverse(matrix[])
apply inverse elementwise to the matrices in the array.The output will always be the same shape as the input and the operations applied elementwise.
Seth Flaxman pointed out we want to be careful not to conflict with matrix exponentials, matrix power, etc. So we'll need a separate
matrix matrix_pow(matrix,int)
operation.This issue can be approached in parts. Create a smaller issue and link into here if you just want to implement some of the functions, but leave this one standing until it's complete in the language.
Ideally, we'd have some template programs to do this vectorization given a functor (or perhaps a static class function). Please ping me for design help with this before taking it on.
Copied from original issue: stan-dev/stan#1464
The text was updated successfully, but these errors were encountered: