You mention that you need all the neighbors. If you really need the nearest neighbors, this answer might be interesting.

Finding nearest neighbors is a classic problem in the field of computational geometry. There are algorithms to create a data structure that enables the nearest neighbors to be found very quickly.

A simple example is to find the closest pair of points in a plane. The slow way is to measure the distance between each of the points and find which is smallest. This requires (N*N-N)/2 distance comparisons, where N is the number of points. The fast way is to compute a particular type of triangular mesh to join the points. The closest pair will be linked by one of the edges of the triangles. While there is some extra computing for creating the mesh, this algorithm is still a big win.

If you need this type of fast algorithm, look at the home page for Qhull. In particular, you need the Voronoi object. The Qhull page says that it has been used for at least eight dimensional analysis.

It should work perfectly the first time! - toma
msg me if this is not clear or if you would like more information on this topic.


In reply to Re: getting my neighbours in an N-dimensional space by toma
in thread getting my neighbours in an N-dimensional space by dash2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.