Changeset 791
- Timestamp:
- Mar 11, 2007, 1:12:34 AM (17 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 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 mis-match");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 mis-match"); 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 -
trunk/yat/utility/vector.h
r790 r791 512 512 513 513 /** 514 \brief Create a vector \a flag indicating NaN's in another vector 515 \a templat. 516 517 The \a flag vector is changed to contain 1's and 0's only. A 1 518 means that the corresponding element in the \a templat vector is 519 valid and a zero means that the corresponding element is a NaN. 520 521 \note Space for vector \a flag is reallocated to fit the size of 522 vector \a templat if sizes mismatch. 523 524 \return True if the \a templat vector contains at least one NaN. 525 */ 526 bool nan(const matrix& templat, matrix& flag); 527 528 /** 514 529 \brief Transforms a vector to a basis vector. 515 530
Note: See TracChangeset
for help on using the changeset viewer.