Changeset 1036
- Timestamp:
- Feb 5, 2008, 6:25:52 PM (16 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/vector.cc
r1027 r1036 180 180 181 181 182 void vector::resize(size_t n, double init_value)183 {184 delete_allocated_memory();185 const_vec_ = vec_ = gsl_vector_alloc(n);186 if (!vec_)187 throw utility::GSL_error("vector::vector failed to allocate memory");188 all(init_value);189 190 }191 192 193 182 /* 194 183 //Peter use swap idiom … … 220 209 const vector& vector::assign(const VectorBase& other) 221 210 { 211 delete_allocated_memory(); 222 212 if (!other.size()) 223 213 vec_=NULL; 224 214 else { 225 215 if (size()!=other.size()) 226 resize(other.size(),0.0); 216 vec_ = gsl_vector_alloc(other.size()); 217 if (!vec_) 218 throw utility::GSL_error("vector failed to allocate memory"); 227 219 gsl_vector_memcpy(vec_,other.gsl_vector_p()); 228 220 } -
trunk/yat/utility/vector.h
r1027 r1036 149 149 150 150 /** 151 @brief Resize vector152 153 All elements are set to @a init_value.154 155 \note Underlying GSL vector is destroyed and a view into this156 vector becomes invalid.157 */158 void resize(size_t n, double init_value);159 160 // using VectorBase::operator=;161 162 /**163 151 \brief The assignment operator. 164 152
Note: See TracChangeset
for help on using the changeset viewer.