Changeset 877


Ignore:
Timestamp:
Sep 20, 2007, 9:01:57 PM (13 years ago)
Author:
Markus Ringnér
Message:

This revision breaks the vector_test. I know this is against the rules but it is intented for getting help from Jari to identify linking problem. A new function sort_index is added to vector, and tested in vector_test. Everything compiles but vector_test fails to link and I cannot see why

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/vector_test.cc

    r865 r877  
    267267  ok &= this_ok;
    268268
     269  std::string data3("data/vector3.data");
     270  std::ifstream data_stream3(data3.c_str());
     271  utility::vector vec3(data_stream3);
     272  std::vector<size_t> dummy;
     273  utility::sort_index(dummy,vec3);
     274  for(size_t i=0;i<dummy.size();i++) {
     275    *message << "dummy: " << dummy[i] << std::endl;
     276  }
     277
    269278  if (!ok)
    270279    *message << "vector test failed" << std::endl;
  • trunk/yat/utility/vector.cc

    r865 r877  
    513513
    514514
     515  void sort_index(std::vector<size_t>& sort_index, const vector& invec)
     516  {
     517    assert(invec.gsl_vector_p());
     518    gsl_permutation* p = gsl_permutation_alloc(invec.size());
     519    int status=gsl_sort_vector_index(p,invec.gsl_vector_p());
     520    if (status) {
     521      gsl_permutation_free(p);
     522      throw utility::GSL_error(std::string("sort_index(vector&,const vector&)",status));     
     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    }
     528    gsl_permutation_free(p);
     529  }
     530
     531
     532
    515533  double sum(const vector& v)
    516534  {
  • trunk/yat/utility/vector.h

    r865 r877  
    536536
    537537  /**
     538     Create a vector \a sort_index containing the indeces of
     539     elements in a another vector \a invec.  The elements of \a
     540     sort_index give the index of the vector element which would
     541     have been stored in that position if the vector had been sorted
     542     in place. The first element of \a sort_index gives the index of the least
     543     element in \a invec, and the last element of \a sort_index gives the index of the
     544     greatest element in \a invec . The vector \a invec is not changed.
     545
     546  */
     547  void sort_index(std::vector<size_t>& sort_index, vector& invec);
     548
     549
     550  /**
    538551     \brief Calculate the sum of all vector elements.
    539552
Note: See TracChangeset for help on using the changeset viewer.