Is the idea to reuse fast_copy in both the base and the derived classes?

On Jun 19, 2013, at 8:30 PM, Bob Carpenter <notifications@github.com> wrote:

> In src/stan/mcmc/hmc/hamiltonians/diag_e_point.hpp:
> 
> >        
> >        Eigen::VectorXd mInv;
> >        
> > +      diag_e_point(const diag_e_point& z): ps_point(z), mInv(z.mInv.size()) {
> > +        std::memcpy(&mInv(0), &(z.mInv(0)), z.mInv.size() * sizeof(double));
> 
> Could you encapsulate this memcpy as something like:
> 
> template <typename T>
> inline void fast_copy(const Matrix<T,Dynamic,1>& v_from, Matrix<T,Dynamic,1> v_to) {
>     v_to.resize(v_from.size());
>     std::memcopy(&v_from(0), &v_to(0), v_from.size() * sizeof(double));
> }
> 
> Then you could drop the mInv(z.mInv.size()) in the ctor. But there could also be an already sized version. I don't think we need error checking here as it's an internal function.
> 
> —
> Reply to this email directly or view it on GitHub.
>