Changeset 879 for trunk/yat/utility
 Timestamp:
 Sep 21, 2007, 4:10:07 PM (15 years ago)
 Location:
 trunk/yat/utility
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/vector.cc
r877 r879 522 522 throw utility::GSL_error(std::string("sort_index(vector&,const vector&)",status)); 523 523 } 524 for(size_t i=0;i<p>size;i++) { 525 sort_index.resize(0); 526 sort_index.push_back(gsl_permutation_get(p,i)); 527 } 524 sort_index=std::vector<size_t>(p>data,p>data+p>size); 528 525 gsl_permutation_free(p); 529 526 } 530 527 528 529 void sort_smallest_index(std::vector<size_t>& sort_index, size_t k, 530 const vector& invec) 531 { 532 assert(invec.gsl_vector_p()); 533 assert(k<=invec.size()); 534 sort_index.resize(k); 535 gsl_sort_vector_smallest_index(&sort_index[0],k,invec.gsl_vector_p()); 536 } 537 538 void sort_largest_index(std::vector<size_t>& sort_index, size_t k, 539 const vector& invec) 540 { 541 assert(invec.gsl_vector_p()); 542 assert(k<=invec.size()); 543 sort_index.resize(k); 544 gsl_sort_vector_largest_index(&sort_index[0],k,invec.gsl_vector_p()); 545 } 531 546 532 547 
trunk/yat/utility/vector.h
r878 r879 547 547 void sort_index(std::vector<size_t>& sort_index, const vector& invec); 548 548 549 /** Similar to sort_index but creates a vector with indices to the \a k 550 smallest elements in \a invec. 551 */ 552 void sort_smallest_index(std::vector<size_t>& sort_index, size_t k, const 553 vector& invec); 554 555 /** Similar to sort_index but creates a vector with indices to the \a k 556 largest elements in \a invec. 557 */ 558 void sort_largest_index(std::vector<size_t>& sort_index, size_t k, const 559 vector& invec); 560 561 549 562 550 563 /**
Note: See TracChangeset
for help on using the changeset viewer.