From c9712fb4a0af503e17b58b55ff2223915277e971 Mon Sep 17 00:00:00 2001 From: Jiaming Guo Date: Tue, 20 Dec 2016 11:21:23 -0600 Subject: [PATCH] fix minor error with querypoint set --- stim/biomodels/network.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/stim/biomodels/network.h b/stim/biomodels/network.h index 0f8c566..0e54719 100644 --- a/stim/biomodels/network.h +++ b/stim/biomodels/network.h @@ -456,7 +456,7 @@ public: } // convert vec3 to array in bunch - void edge2array(T* a, std::vector< typename stim::vec3 > b){ + void edge2array(T* a, edge b){ size_t n = b.size(); for(size_t i = 0; i < n; i++){ a[i * 3 + 0] = b[i][0]; @@ -490,7 +490,7 @@ public: T *c; // centerline (array of double pointers) - points on kdtree must be double size_t n_data = A.total_points(); // set the number of points - c = (T*) malloc(sizeof(T) * n_data * 3); //allocate an array to store all points in the data set + c = (T*) malloc(sizeof(T) * n_data * 3); // allocate an array to store all points in the data set unsigned t = 0; for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in the network @@ -517,7 +517,7 @@ public: size_t errormag_id = R.E[e].nmags() - 1; //get the id for the new magnitude size_t n = R.E[e].size(); // the number of points in current edge - T* queryPt = new T[n]; + T* queryPt = new T[3 * n]; T* m1 = new T[n]; T* dists = new T[n]; size_t* nnIdx = new size_t[n]; @@ -556,7 +556,7 @@ public: size_t errormag_id = R.E[e].nmags() - 1; size_t n = R.E[e].size(); // the number of points in current edge - T* query = new T[n]; + T* query = new T[3 * n]; T* m1 = new T[n]; T* dists = new T[n]; size* nnIdx = new size_t[n]; @@ -614,7 +614,7 @@ public: size_t n = A.E[e].size(); // the number of edges in A - T* queryPt = new T[n]; // set of all the points in current edge + T* queryPt = new T[3 * n]; // set of all the points in current edge T* m1 = new T[n]; // array of metrics for every point in current edge T* dists = new T[n]; // store the distances for every point in current edge size_t* nnIdx = new size_t[n]; // store the indices for every point in current edge @@ -677,14 +677,13 @@ public: for(unsigned ee = 0; ee < NB; ee++) edge_point_num[ee] = B.E[ee].size(); - T* queryPt = new T[3]; for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in A A.E[e].add_mag(0); //add a new magnitude for the metric size_t errormag_id = A.E[e].nmags() - 1; size_t n = A.E[e].size(); // the number of edges in A - T* queryPt = new T[n]; + T* queryPt = new T[3 * n]; T* m1 = new T[n]; T* dists = new T[n]; //store the distances size_t* nnIdx = new size_t[n]; //store the indices @@ -807,7 +806,7 @@ public: if(M > metric_fac) C[e] = (unsigned)-1; //set the nearest edge of impossibly mapping edges to maximum of unsigned else{ - T* queryPt = new T[1]; + T* queryPt = new T[3]; T* dists = new T[1]; size_t* nnIdx = new size_t[1]; -- libgit2 0.21.4