User Tools

Site Tools


gams:transpose_a_matrix

Ho do I transpose a matrix?

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

Parameter w(i,j),
          transw1(j,i),
          transw2(j,i);

* Generate some random data
w(i,j)= uniformInt(0,5);

* Activate performance profiling
Option profile=1;

* Version 1: Assignment
transw1(j,i)=w(i,j);

* Version 2: Using the projection operator
option transw2 < w;

Looking at the performance profile, the projection is about 4 times quicker than the assignment:

----     15 Assignment transw1       0.797     1.219 SECS    298 MB  3334217
----     18 Other                    0.187     1.406 SECS    324 MB 
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/transpose_a_matrix.txt · Last modified: 2020/05/20 07:55 by Lutz Westermann