Commit c9712fb4a0af503e17b58b55ff2223915277e971

Authored by Jiaming Guo
1 parent c72184d1

fix minor error with querypoint set

Showing 1 changed file with 7 additions and 8 deletions   Show diff stats
stim/biomodels/network.h
... ... @@ -456,7 +456,7 @@ public:
456 456 }
457 457  
458 458 // convert vec3 to array in bunch
459   - void edge2array(T* a, std::vector< typename stim::vec3<T> > b){
  459 + void edge2array(T* a, edge b){
460 460 size_t n = b.size();
461 461 for(size_t i = 0; i < n; i++){
462 462 a[i * 3 + 0] = b[i][0];
... ... @@ -490,7 +490,7 @@ public:
490 490  
491 491 T *c; // centerline (array of double pointers) - points on kdtree must be double
492 492 size_t n_data = A.total_points(); // set the number of points
493   - c = (T*) malloc(sizeof(T) * n_data * 3); //allocate an array to store all points in the data set
  493 + c = (T*) malloc(sizeof(T) * n_data * 3); // allocate an array to store all points in the data set
494 494  
495 495 unsigned t = 0;
496 496 for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in the network
... ... @@ -517,7 +517,7 @@ public:
517 517 size_t errormag_id = R.E[e].nmags() - 1; //get the id for the new magnitude
518 518  
519 519 size_t n = R.E[e].size(); // the number of points in current edge
520   - T* queryPt = new T[n];
  520 + T* queryPt = new T[3 * n];
521 521 T* m1 = new T[n];
522 522 T* dists = new T[n];
523 523 size_t* nnIdx = new size_t[n];
... ... @@ -556,7 +556,7 @@ public:
556 556 size_t errormag_id = R.E[e].nmags() - 1;
557 557  
558 558 size_t n = R.E[e].size(); // the number of points in current edge
559   - T* query = new T[n];
  559 + T* query = new T[3 * n];
560 560 T* m1 = new T[n];
561 561 T* dists = new T[n];
562 562 size* nnIdx = new size_t[n];
... ... @@ -614,7 +614,7 @@ public:
614 614  
615 615 size_t n = A.E[e].size(); // the number of edges in A
616 616  
617   - T* queryPt = new T[n]; // set of all the points in current edge
  617 + T* queryPt = new T[3 * n]; // set of all the points in current edge
618 618 T* m1 = new T[n]; // array of metrics for every point in current edge
619 619 T* dists = new T[n]; // store the distances for every point in current edge
620 620 size_t* nnIdx = new size_t[n]; // store the indices for every point in current edge
... ... @@ -677,14 +677,13 @@ public:
677 677 for(unsigned ee = 0; ee < NB; ee++)
678 678 edge_point_num[ee] = B.E[ee].size();
679 679  
680   - T* queryPt = new T[3];
681 680 for(unsigned e = 0; e < A.E.size(); e++){ //for each edge in A
682 681 A.E[e].add_mag(0); //add a new magnitude for the metric
683 682 size_t errormag_id = A.E[e].nmags() - 1;
684 683  
685 684 size_t n = A.E[e].size(); // the number of edges in A
686 685  
687   - T* queryPt = new T[n];
  686 + T* queryPt = new T[3 * n];
688 687 T* m1 = new T[n];
689 688 T* dists = new T[n]; //store the distances
690 689 size_t* nnIdx = new size_t[n]; //store the indices
... ... @@ -807,7 +806,7 @@ public:
807 806 if(M > metric_fac)
808 807 C[e] = (unsigned)-1; //set the nearest edge of impossibly mapping edges to maximum of unsigned
809 808 else{
810   - T* queryPt = new T[1];
  809 + T* queryPt = new T[3];
811 810 T* dists = new T[1];
812 811 size_t* nnIdx = new size_t[1];
813 812  
... ...