Change Eclipse configuration
[jabaws.git] / website / archive / binaries / mac / src / disembl / Tisean_3.0.1 / source_c / routines / find_multi_neighbors.c
1 /*
2  *   This file is part of TISEAN
3  *
4  *   Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
5  *
6  *   TISEAN is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   TISEAN is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with TISEAN; if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 /*Author: Rainer Hegger Last modified: Jul 9, 1999 */
21 #include <math.h>
22
23 unsigned long find_multi_neighbors(double **s,long **box,long *list,double **x,
24                              unsigned long l,unsigned int bs,unsigned int dim,
25                              unsigned int emb,unsigned int del,double eps,
26                              unsigned long *flist)
27 {
28   unsigned long nf=0;
29   int i,i1,i2,j,j1,k,k1,li;
30   int ib=bs-1;
31   long element;
32   double dx=0.0;
33   
34   i=(int)(x[0][0]/eps)&ib;
35   j=(int)(x[dim-1][0]/eps)&ib;
36   
37   for (i1=i-1;i1<=i+1;i1++) {
38     i2=i1&ib;
39     for (j1=j-1;j1<=j+1;j1++) {
40       element=box[i2][j1&ib];
41       while (element != -1) {
42         for (k=0;k<emb;k++) {
43           k1= -k*(int)del;
44           for (li=0;li<dim;li++) {
45             dx=fabs(x[li][k1]-s[li][element+k1]);
46             if (dx > eps)
47               break;
48           }
49           if (dx > eps)
50             break;
51         }
52         if (dx <= eps)
53           flist[nf++]=element;
54         element=list[element];
55       }
56     }
57   }
58   return nf;
59 }