The idea's just to not duplicate complicated code.
I only marked the first instance, but the same
memcpy form was used later.

- Bob

On 6/19/13 4:57 PM, Michael Betancourt 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));
>
> 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.
>
> —
> Reply to this email directly or view it on GitHub <https://github.com/stan-dev/stan/pull/125/files#r4783837>.
>