Changeset 791 for trunk/yat/utility/vector.cc
 Timestamp:
 Mar 11, 2007, 1:12:34 AM (16 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/vector.cc
r790 r791 199 199 200 200 201 gsl_vector* vector::create_gsl_vector_copy(void) const202 {203 gsl_vector* vec = gsl_vector_alloc(size());204 if (!vec)205 throw utility::GSL_error("vector::create_gsl_vector_copy failed to allocate memory");206 if (gsl_vector_memcpy(vec, proxy_v_))207 throw utility::GSL_error("vector::create_gsl_matrix_copy dimension mismatch");208 return vec;209 }210 211 212 201 const vector& vector::clone(const vector& other) 213 202 { … … 236 225 return *this; 237 226 } 227 228 229 gsl_vector* vector::create_gsl_vector_copy(void) const 230 { 231 gsl_vector* vec = gsl_vector_alloc(size()); 232 if (!vec) 233 throw utility::GSL_error("vector::create_gsl_vector_copy failed to allocate memory"); 234 if (gsl_vector_memcpy(vec, proxy_v_)) 235 throw utility::GSL_error("vector::create_gsl_matrix_copy dimension mismatch"); 236 return vec; 237 } 238 238 239 239 … … 417 417 418 418 419 const vector& vector::operator=(const double d) 420 { 421 assert(v_); 422 gsl_vector_add_constant(v_, d); 423 return *this; 424 } 425 426 419 427 const vector& vector::operator*=(const double d) 420 428 { … … 468 476 gsl_vector_minmax_index(v.gsl_vector_p(), &minmax.first, &minmax.second); 469 477 return minmax; 478 } 479 480 481 bool nan(const vector& templat, vector& flag) 482 { 483 size_t rows=templat.size(); 484 if (rows!=flag.size()) 485 flag.clone(vector(rows,1.0)); 486 else 487 flag.set_all(1.0); 488 bool nan=false; 489 for (size_t i=0; i<rows; i++) 490 if (std::isnan(templat(i))) { 491 flag(i)=0; 492 nan=true; 493 } 494 return nan; 470 495 } 471 496
Note: See TracChangeset
for help on using the changeset viewer.