Changeset 15841 for branches/2886_SymRegGrammarEnumeration
- Timestamp:
- 03/14/18 17:48:39 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/ExpressionClustering/Flann.cs
r15840 r15841 86 86 public int checks; /* how many leafs (features) to check in one search */ 87 87 public float cb_index; /* cluster boundary index. Used when searching the kmeans tree */ 88 public float eps; 88 89 89 90 /* kdtree index parameters */ 90 91 public int trees; /* number of randomized trees to use (for kdtree) */ 92 public int leaf_max_size; 91 93 92 94 /* kmeans index parameters */ … … 100 102 public float memory_weight; /* index memory weigthing factor */ 101 103 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_; 102 108 103 109 /* other parameters */ … … 137 143 138 144 [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); 140 149 141 150 [DllImport("flann-1.7.1.dll")] … … 152 161 var _dim = dataset.First().Length; 153 162 FLANNParameters p = DEFAULT_FLANN_PARAMETERS; 154 p.algorithm = flann_algorithm_t.FLANN_INDEX_ AUTOTUNED;163 p.algorithm = flann_algorithm_t.FLANN_INDEX_LINEAR; 155 164 p.centers_init = flann_centers_init_t.FLANN_CENTERS_RANDOM; 156 165 p.target_precision = 0.9f; … … 172 181 173 182 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 176 186 177 187 // copy testset 178 188 var _testset = new float[_tRows * _dim]; 179 189 i = 0; 180 for each (var e in queryset) {181 foreach (var ei in e) {182 _testset[i++] = (float)e i;190 for(int d = 0; d < _dim; d++) { 191 foreach(var e in queryset) { 192 _testset[i++] = (float)e[d]; 183 193 } 184 194 } 195 196 //var res = flann_find_nearest_neighbors_index(index, _testset, _tRows, _result, _dists, _nn, 10, ref p); 197 198 185 199 var res = 186 200 flann_find_nearest_neighbors( … … 194 208 return res; 195 209 } 196 197 198 210 } 199 211 }
Note: See TracChangeset
for help on using the changeset viewer.