Ignore:
Timestamp:
Mar 19, 2007, 1:46:10 PM (16 years ago)
Author:
Peter
Message:

removed minmax functions and moved shuffle into vector.*

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/vector.cc

    r810 r825  
    2828#include "matrix.h"
    2929#include "utility.h"
     30#include "yat/random/random.h"
    3031
    3132#include <cassert>
     
    475476
    476477
    477   std::pair<double,double> minmax(const vector& v)
    478   {
    479     std::pair<double,double> minmax;
    480     gsl_vector_minmax(v.gsl_vector_p(), &minmax.first, &minmax.second);
    481     return minmax;
    482   }
    483 
    484 
    485   std::pair<size_t,size_t> minmax_index(const vector& v)
    486   {
    487     std::pair<size_t,size_t> minmax;
    488     gsl_vector_minmax_index(v.gsl_vector_p(), &minmax.first, &minmax.second);
    489     return minmax;
    490   }
    491 
    492 
    493478  bool nan(const vector& templat, vector& flag)
    494479  {
     
    515500
    516501
     502  void shuffle(vector& invec)
     503  {
     504    vector vec(invec);
     505    random::DiscreteUniform rnd;
     506    for (size_t i=0; i<vec.size(); i++){
     507      size_t index = rnd(vec.size()-i);
     508      invec[i]=vec(index);
     509      vec(index)=vec(vec.size()-i-1);
     510    }
     511  }
     512
     513
    517514  void sort(vector& v)
    518515  {
Note: See TracChangeset for help on using the changeset viewer.