Changeset 63
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/vector.cc
r48 r63 5 5 #include <string> 6 6 #include <vector> 7 #include <utility> 7 8 8 9 #include "vector.h" … … 125 126 } 126 127 128 //Peter, add default checking all elements using GSL 129 std::pair<u_int,u_int> vector::minmax_index(const std::vector<u_int>& subset ) const 130 { 131 u_int min_index = subset[0]; 132 u_int max_index = subset[0]; 133 for (unsigned int i=1; i<subset.size(); i++) { 134 if (gsl_vector_get( v_, subset[i]) < gsl_vector_get( v_, min_index)) 135 min_index = subset[i]; 136 else if (gsl_vector_get( v_, subset[i]) > gsl_vector_get( v_, max_index)) 137 max_index = subset[i]; 138 } 139 return std::pair<u_int,u_int>(min_index, max_index); 140 } 141 127 142 128 143 -
trunk/src/vector.h
r62 r63 5 5 6 6 #include <iostream> 7 #include <vector> 8 #include <utility> 7 9 8 10 #include <gsl/gsl_vector.h> … … 86 88 /// @return A pointer to the internal GSL vector, 87 89 /// 88 inline gsl_vector* gsl_vector_pointer(void) { return v_; }; 90 inline gsl_vector* gsl_vector_pointer(void) { return v_; } 91 92 ///This function returns the indices of the minimum and maximum values in 93 ///the sub-vector (defined by subset), storing them in imin and imax. When 94 ///there are several equal minimum or maximum elements then the lowest 95 ///indices are returned. The returned index is the index from the complete vector (not the sub-vector) @return Index corresponding to the smallest 96 ///and largest value. 97 /// 98 std::pair<u_int,u_int> vector::minmax_index(const std::vector<u_int>& subset ) const; 89 99 90 100 ///
Note: See TracChangeset
for help on using the changeset viewer.