Changeset 1506
- Timestamp:
- Sep 17, 2008, 12:53:55 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/vector_test.cc
r1487 r1506 341 341 } 342 342 343 // test for zero size constructor 344 { 345 theplu::yat::utility::Vector vec(0, 1.2); 346 theplu::yat::utility::Vector vec2(vec); 347 } 343 348 return suite.return_value(); 344 349 } -
trunk/yat/utility/Vector.cc
r1487 r1506 46 46 47 47 Vector::Vector(size_t n, double init_value) 48 : VectorMutable( gsl_vector_alloc(n))49 { 50 if ( !vec_)51 throw utility::GSL_error("Vector::Vector failed to allocate memory");52 assert( const_vec_);53 a ll(init_value);48 : VectorMutable(create_gsl_vector(n)) 49 { 50 if (n) 51 all(init_value); 52 assert(n==0 || vec_); 53 assert(n==0 || const_vec_); 54 54 } 55 55 … … 204 204 205 205 206 gsl_vector* Vector::create_gsl_vector(size_t n) const 207 { 208 if (!n) 209 return NULL; 210 gsl_vector* vec = gsl_vector_alloc(n); 211 if (!vec) 212 throw utility::GSL_error("Vector::create_gsl_vector failed to allocate memory"); 213 return vec; 214 } 215 216 206 217 void Vector::delete_allocated_memory(void) 207 218 { -
trunk/yat/utility/Vector.h
r1487 r1506 164 164 gsl_vector* create_gsl_vector_copy(const VectorBase&) const; 165 165 166 /** 167 \brief Create a new gsl vector 168 169 Necessary memory for the new GSL vector is allocated and the 170 caller is responsible for freeing the allocated memory. 171 172 \return A pointer to created GSL vector. 173 174 \throw GSL_error if memory cannot be allocated for the new 175 GSL vector. 176 */ 177 gsl_vector* create_gsl_vector(size_t n) const; 178 166 179 void delete_allocated_memory(void); 167 180 };
Note: See TracChangeset
for help on using the changeset viewer.