Bob Carpenter
unread,Dec 1, 2013, 10:07:52 PM12/1/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to stan...@googlegroups.com
[back on stan-dev]
On 12/1/13, 5:35 PM, Ben Goodrich wrote:
>> The only thing I was thinking about doing was using
>> template instantiations as we do for the grammars
>> so these become one-time speed costs at the expense of
>> using much more memory. This is just the template lib
>> version of breaking a lib into .cpp and .hpp file.
>
> Is it not possible to do the same thing with the rest of Stan the library? Like instantiate one dynamically resizeable
> Cholesky object with our scalar types?
It's pretty straightforward. Especially for Cholesky,
which only has two instantiations until we add RHMC,
namely Matrix<double> and Matrix<var>.
The problem is that we have a lot of functions and many of
them are far more polymorphic than the Cholesky decomposition.
The worst case is for now is the Student-t density function,
which has four arguments, each of which can be instantiated by
double, var,
vector<double>, vector<var>,
row-vector<double>, row-vector<var>,
vector<var>, vector<double>, for a total of 8^4 (4096) instantiations.
I don't think that will be feasible in terms of compilation time
or object code size.
With the header-based approach we take now, only the instances that
are used in a particular model get instantiated and compiled, though
it has to be done on a model-per-model basis.
- Bob