It is a simple matter to write a function that uses a loop to do what
you want and then you just call
that function. prototypes could be
void fill(const dvar_matrix& dest,const dvar_vector& src);
void fill(const dmatrix& dest,const dvector& src);
then you just use
fill(M,v);
why wouldn't that do the job?