[ADMB Users] how to assign a matrix column (vector) after extracting it

Saang-Yoon shyunuw at gmail.com
Sat Oct 16 18:40:00 PDT 2010


Hello.
This inquiry should be easy to many of you.  I would appreciate your
help and time.

I am extracting columns of a matrix say, MM, and then am trying to
assign those individual columns to another matrix M.  MM and M have
different dimensions: e.g., dimension of MM = (r x c), while dimension
of M = (r x (c-1) ).  Of course, I can do so by looping across rows
and columns, but I am trying to reduce the two loops into one loop.

Following is my idea.

for(int j=1;j<=c-1;j++)
    M::colfill(j, extract_column(MM,j));

In the above example, I am using

   matrix::colfill(j, vector)

which is from the ADMB manual, but the compile-link is in error.

If I were in R, I would do like the following:
for(j in 1:(c-1))
    M[,j]=MM[,j];

I would greatly appreciate your hint.  Also if you can show the usage
of the command, "matrix::colfill(int& j, vector&), it will be more
than great.    Thank you,

Saang-Yoon



More information about the Users mailing list