Changeset 65


Ignore:
Timestamp:
Apr 22, 2004, 2:46:15 PM (19 years ago)
Author:
Jari Häkkinen
Message:

Fixed some u_int size_t confusion.
Added functionality.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/vector.cc

    r64 r65  
    129129
    130130
    131   std::pair<u_int,u_int> vector::minmax_index() const
     131  std::pair<size_t,size_t> vector::minmax_index(void) const
    132132  {
    133133    size_t min_index=0;
    134134    size_t max_index=0;
    135135    void gsl_vector_minmax_index (const gsl_vector * v_, size_t * min_index, size_t * max_index);
    136     return std::pair<u_int,u_int>(min_index, max_index);
     136    return std::pair<size_t,size_t>(min_index, max_index);
    137137  }
    138138
     
    140140
    141141//Peter, add default checking all elements using GSL
    142   std::pair<u_int,u_int> vector::minmax_index(const std::vector<u_int>& subset ) const
    143   {
    144     u_int min_index = subset[0];
    145     u_int max_index = subset[0];
     142  std::pair<size_t,size_t> vector::minmax_index(const std::vector<size_t>& subset ) const
     143  {
     144    size_t min_index = subset[0];
     145    size_t max_index = subset[0];
    146146    for (unsigned int i=1; i<subset.size(); i++) {
    147147      if (gsl_vector_get( v_, subset[i]) < gsl_vector_get( v_, min_index))
     
    150150        max_index = subset[i];
    151151    }
    152     return std::pair<u_int,u_int>(min_index, max_index);
     152    return std::pair<size_t,size_t>(min_index, max_index);
    153153  }
    154154
  • trunk/src/vector.h

    r64 r65  
    9696    ///and largest value.
    9797    ///
    98     std::pair<u_int,u_int> vector::minmax_index() const;
     98    std::pair<size_t,size_t> vector::minmax_index(void) const;
    9999
    100100    ///This function returns the indices of the minimum and maximum values in
     
    118118    /// Set all elements to \a value.
    119119    ///
    120     inline void set_all(const double& value) { gsl_vector_set_all(v_,value); }
     120    inline void set_all(const double& value) { gsl_vector_set_all(v_,value); }
     121
     122    ///
     123    /// Makes a basis vector byy settin all elements to
     124    /// zero except the \a i-th element which is set to
     125    /// one..
     126    ///
     127    inline void set_basis(const size_t i) { gsl_vector_set_basis(v_,i); }
     128    ///
     129    /// Set all elements to zero.
     130    ///
     131    inline void set_zero(void) { gsl_vector_set_zero(v_); }
    121132
    122133    ///
     
    145156    ///
    146157    inline const double& operator()(size_t i) const
    147       { return *gsl_vector_ptr(v_,i); }
     158      { return *gsl_vector_const_ptr(v_,i); }
    148159   
    149160    ///
     
    152163    /// @return Reference to element \a i.
    153164    ///
    154     inline double& operator[](size_t i) { return (*this)(i); }
     165    inline double& operator[](size_t i) { return *gsl_vector_ptr(v_,i); }
    155166
    156167    ///
     
    159170    /// @return The value of element \a i.
    160171    ///
    161     inline const double& operator[](size_t i) const { return (*this)(i); }
     172    inline const double& operator[](size_t i) const
     173      { return *gsl_vector_const_ptr(v_,i); }
    162174   
    163175    ///
Note: See TracChangeset for help on using the changeset viewer.