User Tools

Site Tools


gams:transpose_a_matrix

Ho do I transpose a matrix?

* transpose of a matrix

set i /i1*i2000/,
    j /j1*j2000/;

parameter w(i,j),
          transw1(j,i),
          transw2(j,i);
w(i,j)= uniformint(0,5);

* slow
transw1(j,i)=w(i,j);

* using projections is  more than 11 times faster on that example!
option transw2 < w;

Profile

...
----      9 Assignment w             1.482     1.482 SECS     84 Mb  3334217
----     12 Assignment transw1       1.623     3.105 SECS    223 Mb  3334217
----     14 Other                    0.140     3.245 SECS    244 Mb 
gams/transpose_a_matrix.txt · Last modified: 2009/07/09 13:52 by support