# Strange behavior of Transpose in Mathematica 12.3 for Windows

Posted 3 months ago
727 Views
|
4 Replies
|
1 Total Likes
|
 Transpose is used in tree different ways. It spents much time, except when it is added AbsoluteTiming. Why? Thanks. GuillermoVery slow Transpose[{Range[10^5], Range[10^5]}] slow Evaluate[Transpose[{Range[10^5], Range[10^5]}]] Fast Evaluate[Transpose[{Range[10^5], Range[10^5]}]] // AbsoluteTiming Answer
4 Replies
Sort By:
Posted 3 months ago
 The time is spent rendering the large output in the notebook. Add ; to suppress the output (tr = Transpose[{Range[10^5], Range[10^5]}];) // AbsoluteTiming (* {0.000537, Null} *) (tr = Evaluate[Transpose[{Range[10^5], Range[10^5]}]];) // AbsoluteTiming (* {0.000352, Null} *) Answer
Posted 3 months ago
 @Rohit:Any idea why Evaluate runs in about 60% of the time as the non-evaluate version?THANKS Answer
Posted 3 months ago
 Hi Mike,The times are small and AbsoluteTiming is elapsed time which depends on what else is running on the machine. Replace AbsoluteTiming with RepeatedTiming to get a more accurate measurement. There is very little difference. Or use BenchmarkPlot. tr = Transpose[{#, #}] &; trEval = Evaluate[Transpose[{#, #}] &]; r = Range[10^7]; Needs["GeneralUtilities"] BenchmarkPlot[{tr, trEval}, r[[;; #]] &, 10^Range] `  Answer
Posted 3 months ago
 Rohit:Thanks. I can trust the space-time continuum again. :) Answer