Changeset 1135
- Timestamp:
- Feb 24, 2008, 12:40:27 AM (16 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/vector_test.cc
r1132 r1135 314 314 } 315 315 316 /*317 316 { 318 317 utility::Vector vec(10, 2.3); … … 338 337 } 339 338 } 340 */341 339 342 340 // test for ticket:285 -
trunk/yat/utility/Vector.cc
r1130 r1135 156 156 const Vector& Vector::assign(const VectorBase& other) 157 157 { 158 // avoid self assignment 159 if (this == &other) 160 return *this; 161 if (!other.size()){ 162 delete_allocated_memory(); 163 return *this; 164 } 165 // indirect self assignment if begin <= other.begin() < end 166 if (begin() <= other.begin() && other.begin()<end()) { 167 if (size() != other.size()) { 168 gsl_vector* tmp = create_gsl_vector_copy(other); 169 delete_allocated_memory(); 170 const_vec_ = vec_ = tmp; 171 } 172 return *this; 173 } 158 174 delete_allocated_memory(); 159 if (other.size()) { 160 if (size()!=other.size()) 161 vec_ = gsl_vector_alloc(other.size()); 162 if (!vec_) 163 throw utility::GSL_error("Vector failed to allocate memory"); 164 if (gsl_vector_memcpy(vec_, other.gsl_vector_p())) 165 throw utility::GSL_error("Vector::assign memcpy failed."); 166 const_vec_ = vec_; 167 } 175 vec_ = create_gsl_vector_copy(other); 176 const_vec_ = vec_; 168 177 return *this; 169 178 }
Note: See TracChangeset
for help on using the changeset viewer.