User Tools

Site Tools


gams:transpose_a_matrix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
gams:transpose_a_matrix [2009/07/09 15:52]
support
gams:transpose_a_matrix [2020/05/20 07:55] (current)
Lutz Westermann
Line 2: Line 2:
  
 <​code>​ <​code>​
-* transpose of a matrix +Set i /i1*i2000/,
- +
-set i /i1*i2000/,+
     j /j1*j2000/;     j /j1*j2000/;
  
-parameter ​w(i,j),+Parameter ​w(i,j),
           transw1(j,​i),​           transw1(j,​i),​
           transw2(j,​i);​           transw2(j,​i);​
-w(i,j)= uniformint(0,​5);​ 
  
-slow+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);​ transw1(j,​i)=w(i,​j);​
  
-using projections is  more than 11 times faster on that example!+Version 2: Using the projection operator
 option transw2 < w; option transw2 < w;
- 
 </​code>​ </​code>​
  
-Profile ​+Looking at the performance profile, the [[https://​www.gams.com/​latest/​docs/​UG_OptionStatement.html#​UG_OptionStatement_ProjectionAndAggregation|projection]] is about 4 times quicker than the assignment:​ 
 <​code>​ <​code>​
-... +----     15 Assignment transw1 ​      0.797     ​1.219 SECS    ​298 MB  ​3334217 
-----      9 Assignment w             ​1.482 ​    1.482 SECS     84 Mb  3334217 +----     18 Other                    0.187     ​1.406 SECS    ​324 MB 
-----     12 Assignment transw1 ​      1.623     ​3.105 SECS    ​223 Mb  ​3334217 +
-----     14 Other                    0.140     ​3.245 SECS    ​244 Mb +
 </​code>​ </​code>​
  
IMPRESSUM / LEGAL NOTICEPRIVACY POLICY gams/transpose_a_matrix.1247147523.txt.gz · Last modified: 2009/07/09 15:52 by support