On 12/6/13, 9:16 PM, Ben Goodrich wrote:
> On Friday, December 6, 2013 7:09:04 PM UTC-5, Michael Betancourt wrote:
>
> There are two ways to proceed:
>
> Change the samplers and autodiff to use Eigen::Vector but leave the internal model storage as std::vector
>
> or
>
> Convert everything to Eigen::Vector
>
> Given how the model is abstracted through the autodiff functors both should be equally feasible. Does anyone have
> any preferences?
>
>
> Um, what is the problem that these two proposals are a solution to? Maybe using an Eigen::Map is a third possibility?
The underlying use is now as an Eigen vector and we wind up
either wrapping or copying the std::vector coming in.
I don't think we want Eigen::Map as the input type --- it's just
one of many expression template-like types that Eigen uses.
Ben's pointed us before to Eigen's advice on how to do these
arguments more generally so as to accept references to expression
templates:
http://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html
We could start following this advice, but it may be more trouble
than it's worth in this case. And it will, of course, introduce
more deeply nested template parameter fiddling at compile time.
> I'm pretty sure I would be in favor of converting everything to Eigen types regardless. It is one thing to say that we
> should limit the number of libraries that we depend on (although I am not totally convinced of that). But given that
> Stan fundamentally depends on a library such as Eigen (and it would be non-trivial to even swap in another matrix
> library like Armadillo), then we should use Eigen as much as possible because it is awesome.'
Stan's samplers did not in the past fundamentally depend on Eigen.
Michael's refactor of the samplers in 2.0 introduced the dependency.
Adding the dependency makes sense when you start manipulating the
parameter vector as a mathematical vector, as Michael's doing.
Stan's model base class still (v2.0.1) does not depend on Eigen,
so this proposed change would be introducing a dependency.
Of course, all of our generated models depend on everything. This
is not good, but it'd be a big programming project to trim everything
and would require the code generator to keep track of dependencies on
every function it generates, which means a dependency of the code generator
on every specific function we introduce to ensure its dependencies are included.
Not having this dependency makes it easier to introduce new functions.
- Bob