Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1992
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1992

[Date Index] [Thread Index] [Author Index]

Search the Archive

using Transpose vs. Thread

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: using Transpose vs. Thread
  • From: gaylord at ux1.cso.uiuc.edu
  • Date: Fri, 4 Sep 1992 08:44:01 -0500

i was messing around and came across this

Timing[Map[(#[[1]] -> #[[2]])&, Transpose[{Range[1000],Range[1000]}]];]
{2.23333 Second, Null}

Timing[Map[Apply[Rule,#]&, Transpose[{Range[1000],Range[1000]}]];] 
{2.15 Second, Null}

Timing[Thread[Rule[Range[1000],Range[1000]]];]
{0.85 Second, Null}

------------------------------

more generally on the Transpose function itself

Transpose[{Range[5],Range[5]}]
{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}

Thread[List[Range[5],Range[5]]]
{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}}


Timing[Thread[List[Range[10000],Range[10000]]];]
{3.71667 Second, Null}

Timing[Transpose[{Range[10000],Range[10000]}];]
{4.51667 Second, Null}

so it looks like we can define a user-defined function, maybe call it
transposeFast (i'm too modest to have it named after myself) which is
faster than the built-in Transpose function.

interesting

richard j. gaylord, university of illinois, gaylord at ux1.cso.uiuc.edu

"if you're not programming functionally, then you must be programming
dysfunctionally"








  • Prev by Date: Crystal Structure
  • Next by Date: Mathematica Stochastica
  • Previous by thread: Crystal Structure
  • Next by thread: Mathematica Stochastica