Page 1 of 1

Matrix multiplication in GAMS

Posted: Mon Feb 11, 2019 3:56 pm
by Luca
Dear all,

what is the best way to multiply two matrix in GAMS?

Thanks for all your answer,
Luca

Re: Matrix multiplication in GAMS

Posted: Tue Feb 12, 2019 5:35 pm
by Manassaldi
hi, the matrix dimensions must be compatible to carry out the multiplication.
Here are some examples:

Code: Select all

eq(i,j).. C(i,j) =e= sum(k,A(i,k)*B(k,j));
or

Code: Select all

eq(i,j).. C(i,j) =e=  sum((k,m)$(ord(m) eq ord(k)), A(i,k)*B(m,j) );
Bye!