Changeset 109
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/vector.cc
r68 r109 30 30 31 31 32 vector::vector(const vector& other) 33 { 34 v_ = other.gsl_vector_copy(); 32 vector::vector(const vector& other, const std::vector<size_t>& index) 33 { 34 if (index.size()){ 35 v_ = gsl_vector_alloc(index.size()); 36 for (size_t i=0; i<index.size(); i++) 37 gsl_vector_set(v_, i, other(index[i])); 38 } 39 else 40 v_ = other.gsl_vector_copy(); 35 41 } 36 42 -
trunk/src/vector.h
r65 r109 47 47 48 48 /// 49 /// The copy constructor. 50 /// 51 vector(const vector&); 49 /// The copy constructor, creating a new sub-vector defined by \a 50 /// index (default is to copy the whole vector). 51 /// 52 vector(const vector&, 53 const std::vector<size_t>& index = std::vector<size_t>()); 52 54 53 55 /// … … 98 100 std::pair<size_t,size_t> vector::minmax_index(void) const; 99 101 100 ///This function returns the indices of the minimum and maximum values in 101 ///the sub-vector (defined by subset), storing them in imin and imax. When 102 ///there are several equal minimum or maximum elements then the lowest 103 ///indices are returned. The returned index is the index from the complete vector (not the sub-vector) @return Index corresponding to the smallest 104 ///and largest value. 105 /// 106 std::pair<size_t,size_t> vector::minmax_index(const std::vector<size_t>& subset ) const; 102 ///This function returns the indices of the minimum and maximum 103 ///values in the sub-vector (defined by subset), storing them in 104 ///imin and imax. When there are several equal minimum or maximum 105 ///elements then the lowest indices are returned. The returned 106 ///index is the index from the complete vector (not the 107 ///sub-vector) 108 ///@return Index corresponding to the smallest and largest value. 109 /// 110 std::pair<size_t,size_t> 111 vector::minmax_index(const std::vector<size_t>& subset ) const; 107 112 108 113 /// … … 121 126 122 127 /// 123 /// Makes a basis vector by y settinall elements to128 /// Makes a basis vector by setting all elements to 124 129 /// zero except the \a i-th element which is set to 125 /// one. .130 /// one. 126 131 /// 127 132 inline void set_basis(const size_t i) { gsl_vector_set_basis(v_,i); } 133 128 134 /// 129 135 /// Set all elements to zero.
Note: See TracChangeset
for help on using the changeset viewer.