Re: Minimization
- To: mathgroup at smc.vnet.net
- Subject: [mg42275] Re: Minimization
- From: "Carl K. Woll" <carlw at u.washington.edu>
- Date: Thu, 26 Jun 2003 05:36:28 -0400 (EDT)
- Organization: University of Washington
- References: <bdbeu1$2dq$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
John, Here is a version which is a bit faster on my machine than Hartmut's, where I use pts instead of l1. pts[[Ordering[Plus@@((Transpose[pts]-p0)^2),5]]] The improvement in speed comes from using Plus@@((Transpose[pts]-p0)^2) instead of Hartmut's With[{r=#-p0},r.r]&/@pts Further improvements in speed may be achievable if you use Compile. Carl Woll Physics Dept U of Washington <Moranresearch at aol.com> wrote in message news:bdbeu1$2dq$1 at smc.vnet.net... > > I have a list of points l1= (xi,yi, zi) and a target point (x0,y0,z0) how > would I efficiently find the 5 points in l1 closest to, ie with the smallest > Euclidian disance to, the target point? Thank you. > John >