Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/14/18 17:48:39 (6 years ago)
Author:
gkronber
Message:

#2886 fixed FLANNParameters structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2886_SymRegGrammarEnumeration/ExpressionClustering/Flann.cs

    r15840 r15841  
    8686      public int checks;                /* how many leafs (features) to check in one search */
    8787      public float cb_index;            /* cluster boundary index. Used when searching the kmeans tree */
     88      public float eps;
    8889
    8990      /*  kdtree index parameters */
    9091      public int trees;                 /* number of randomized trees to use (for kdtree) */
     92      public int leaf_max_size;
    9193
    9294      /* kmeans index parameters */
     
    100102      public float memory_weight;       /* index memory weigthing factor */
    101103      public float sample_fraction;     /* what fraction of the dataset to use for autotuning */
     104
     105      public uint table_number_;
     106      public uint key_size_;
     107      public uint multi_probe_level_;
    102108
    103109      /* other parameters */
     
    137143
    138144    [DllImport("flann-1.7.1.dll")]
    139     public static extern int flann_build_index(float[] dataset, int rows, int cols, ref float speedup, ref FLANNParameters flann_params);
     145    public static extern IntPtr flann_build_index(float[] dataset, int rows, int cols, ref float speedup, ref FLANNParameters flann_params);
     146
     147    [DllImport("flann-1.7.1.dll")]
     148    public static extern int flann_find_nearest_neighbors_index(IntPtr index_id, float[] testset, int trows, int[] indices, float[] dists, int nn, int checks, ref FLANNParameters flann_params);
    140149
    141150    [DllImport("flann-1.7.1.dll")]
     
    152161      var _dim = dataset.First().Length;
    153162      FLANNParameters p = DEFAULT_FLANN_PARAMETERS;
    154       p.algorithm = flann_algorithm_t.FLANN_INDEX_AUTOTUNED;
     163      p.algorithm = flann_algorithm_t.FLANN_INDEX_LINEAR;
    155164      p.centers_init = flann_centers_init_t.FLANN_CENTERS_RANDOM;
    156165      p.target_precision = 0.9f;
     
    172181
    173182      float speedup = -1.0f;
    174       // _ds must be a rows × cols matrix stored in row-major order (one feature on each row)
    175       var index = flann_build_index(_ds, rows: dataset.Count, cols: _dim, speedup: ref speedup, flann_params: ref p);
     183      // _ds must be a rows × cols matrix stored in row-major order (one feature on each row)                         
     184      //var index = flann_build_index(_ds, rows: dataset.Count, cols: _dim, speedup: ref speedup, flann_params: ref p);
     185     
    176186
    177187      // copy testset
    178188      var _testset = new float[_tRows * _dim];
    179189      i = 0;
    180       foreach (var e in queryset) {
    181         foreach (var ei in e) {
    182           _testset[i++] = (float)ei;
     190      for(int d = 0; d < _dim; d++) {
     191        foreach(var e in queryset) {
     192          _testset[i++] = (float)e[d];
    183193        }
    184194      }
     195
     196      //var res = flann_find_nearest_neighbors_index(index, _testset, _tRows, _result, _dists, _nn, 10, ref p);
     197
     198
    185199      var res =
    186200        flann_find_nearest_neighbors(
     
    194208      return res;
    195209    }
    196 
    197 
    198210  }
    199211}
Note: See TracChangeset for help on using the changeset viewer.