[ADMB Users] linear algebra (matrix algebra)

5 views
Skip to first unread message

Saang-Yoon

unread,
Jun 16, 2010, 9:23:06 PM6/16/10
to us...@admb-project.org
Dear ADMB folks.

I have a difficulty in coding matrix algebra with ADMB. Regarding
lineary algebra, the ADMB syntax does not seem to be consistent with
the traditional linear algebra. For example (as very simple example),
I have two matrices and one scalar as the follows:

matrix mA(1,2,1,1);
matrix mB(1,2,1,1);
number sC;

Traditionally, when the transpose of matrix mA is multiplied by matrix
mB, the resultant dimension becomes a scalar. That is,

!!sC=trans(mA)*mB;

But, ADMB compilation says this is in error. I wonder about how ADMB
users do when they do a linear algebra. A friend of mine suggests a
looping, and I laugh the idea. Yes, the looping for individual
products between mA and mB elements would work. However, I suspect
there is a more or less formal way. Please help.

Thank you,

Saang-Yoon
_______________________________________________
Users mailing list
Us...@admb-project.org
http://lists.admb-project.org/mailman/listinfo/users

dave fournier

unread,
Jun 17, 2010, 4:19:08 AM6/17/10
to us...@admb-project.org
a matrix times a matrix returns a matrix even if it is 1x1.
(I'm not checking for this case). If it is 1x1

!!sC=(trans(mA)*mB)(1,1);

should do the trick for you.

Saang-Yoon

unread,
Jun 17, 2010, 8:34:39 PM6/17/10
to us...@admb-project.org
Dear Dr. Fournier.
Your trick works!!! Thank you VERY MUCH.
Saang-Yoon
Reply all
Reply to author
Forward
0 new messages