~ubuntu-branches/debian/sid/octave-tisean/sid

« back to all changes in this revision

Viewing changes to src/routines_c/find_multi_neighbors.cc

  • Committer: Package Import Robot
  • Author(s): Rafael Laboissiere
  • Date: 2017-08-14 12:53:47 UTC
  • Revision ID: package-import@ubuntu.com-20170814125347-ju5owr4dggr53a2n
Tags: upstream-0.2.3
ImportĀ upstreamĀ versionĀ 0.2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
21
 * Modified: Piotr Held <pjheld@gmail.com> (2015). 
 
22
 * This function is based on find_multi_neighbors of 
 
23
 * TISEAN 3.0.1 https://github.com/heggus/Tisean"
 
24
 */
 
25
/********************************************************************/
 
26
/********************************************************************/
 
27
 
 
28
#include <octave/oct.h>
 
29
#include <cmath>
 
30
 
 
31
octave_idx_type find_multi_neighbors(const Matrix &s,
 
32
                                     const MArray <octave_idx_type> &box,
 
33
                                     long *list,double **x,
 
34
                                     octave_idx_type bs,octave_idx_type dim,
 
35
                                     octave_idx_type emb,octave_idx_type del,
 
36
                                     double eps, unsigned long *flist)
 
37
{
 
38
  double dx=0.0;
 
39
 
 
40
  octave_idx_type nf=0;
 
41
  octave_idx_type ib=bs-1;
 
42
  octave_idx_type element;
 
43
  octave_idx_type k1,i2;
 
44
 
 
45
  octave_idx_type i=(octave_idx_type)(x[0][0]/eps)&ib;
 
46
  octave_idx_type j=(octave_idx_type)(x[dim-1][0]/eps)&ib;
 
47
  
 
48
  for (octave_idx_type i1=i-1;i1<=i+1;i1++) 
 
49
    {
 
50
      i2=i1&ib;
 
51
      for (octave_idx_type j1=j-1;j1<=j+1;j1++) 
 
52
        {
 
53
          element=box(j1&ib,i2);
 
54
          while (element != -1) 
 
55
            {
 
56
              for (octave_idx_type k=0;k<emb;k++) 
 
57
                {
 
58
                  k1= -k*del;
 
59
                  for (octave_idx_type li=0;li<dim;li++) 
 
60
                    {
 
61
                      dx=std::fabs(x[li][k1]-s(element+k1,li));
 
62
                      if (dx > eps)
 
63
                        break;
 
64
                    }
 
65
                  if (dx > eps)
 
66
                    break;
 
67
                }
 
68
              if (dx <= eps)
 
69
                flist[nf++]=element;
 
70
              element=list[element];
 
71
            }
 
72
        }
 
73
    }
 
74
  return nf;
 
75
}
 
76
 
 
77
octave_idx_type find_multi_neighbors(const double ** s,
 
78
                                     octave_idx_type **box,
 
79
                                     long *list,const double **x,
 
80
                                     octave_idx_type bs,octave_idx_type dim,
 
81
                                     octave_idx_type emb,octave_idx_type del,
 
82
                                     double eps, unsigned long *flist)
 
83
{
 
84
  double dx=0.0;
 
85
  octave_idx_type nf=0;
 
86
  octave_idx_type ib=bs-1;
 
87
  octave_idx_type element;
 
88
  octave_idx_type k1,i2;
 
89
 
 
90
  octave_idx_type i=(octave_idx_type)(x[0][0]/eps)&ib;
 
91
  octave_idx_type j=(octave_idx_type)(x[dim-1][0]/eps)&ib;
 
92
  
 
93
  for (octave_idx_type i1=i-1;i1<=i+1;i1++) 
 
94
    {
 
95
      i2=i1&ib;
 
96
      for (octave_idx_type j1=j-1;j1<=j+1;j1++) 
 
97
        {
 
98
          element=box[i2][j1&ib];
 
99
          while (element != -1) 
 
100
            {
 
101
              for (octave_idx_type k=0;k<emb;k++) 
 
102
                {
 
103
                  k1= -k*del;
 
104
                  for (octave_idx_type li=0;li<dim;li++) 
 
105
                    {
 
106
                      dx=std::fabs(x[li][k1]-s[li][element+k1]);
 
107
                      if (dx > eps)
 
108
                        break;
 
109
                    }
 
110
                  if (dx > eps)
 
111
                    break;
 
112
                }
 
113
              if (dx <= eps)
 
114
                flist[nf++]=element;
 
115
              element=list[element];
 
116
            }
 
117
        }
 
118
    }
 
119
  return nf;
 
120
}