MathGroup Archive 2002

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

Search the Archive

RE: How to speed up this calculation?

  • To: mathgroup at
  • Subject: [mg37223] RE: How to speed up this calculation?
  • From: "DrBob" <drbob at>
  • Date: Thu, 17 Oct 2002 00:08:54 -0400 (EDT)
  • Reply-to: <drbob at>
  • Sender: owner-wri-mathgroup at

It's not clear what you mean by pairs that repeat themselves, but does
this do what you want?

pairs = Flatten[Outer[List, points, points, 1], 1];
Map[Union, Map[Sort, pairs, 2], 1]


-----Original Message-----
From: Cheng Liu [mailto:cliu at] 
To: mathgroup at
Subject: [mg37223]  How to speed up this calculation?

Dear group,

         I have the following question regarding a lengthy calculation 
using Mathematica:

For given w points in x direction and h points in y direction, I can 
construct all the points using

         h=10; w=8;

Next, I need to find all the possible pairs of point including points 
themselves, i.e., pair AA.  I can use


Then, I have to clear those pairs that repeat themselves, i.e., pair AB
pair BA.  Also, when w and h are of the order of 1000s, the computation 
takes a very long time.  Is there a better way of doing the second part
the computation?  Thanks in advance.



Cheng Liu, Ph.D.
MST-8, Structure/Property Relations
Materials Science and Technology Division
Los Alamos National Laboratory
Los Alamos, New Mexico 87545

Phone: 505-665-6892 (office), 505-667-9950 (lab)
Fax:   505-667-8021
email: cliu at

  • Prev by Date: Re: List processing
  • Next by Date: Re: How to speed up this calculation?
  • Previous by thread: How to speed up this calculation?
  • Next by thread: Re: How to speed up this calculation?