 Timestamp:
 Mar 2, 2007, 12:53:03 AM (15 years ago)
 Location:
 trunk/yat/utility
 Files:

 2 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/utility/vector.cc
r759 r775 198 198 199 199 200 void vector::add(const vector& other)201 {202 int status=gsl_vector_add(v_,other.v_);203 if (status)204 throw utility::GSL_error(std::string("vector::add",status));205 }206 207 208 void vector::add(double term)209 {210 gsl_vector_add_constant(v_,term);211 }212 213 214 200 gsl_vector* vector::create_gsl_vector_copy(void) const 215 201 { … … 309 295 310 296 311 void vector::scale(double factor)312 {313 gsl_vector_scale(v_,factor);314 }315 316 317 297 void vector::set(const vector& vec) 318 298 { … … 351 331 { 352 332 gsl_sort_vector(v_); 353 }354 355 356 void vector::sub(const vector& other)357 {358 int status=gsl_vector_sub(v_,other.v_);359 if (status)360 throw utility::GSL_error(std::string("vector::sub",status));361 333 } 362 334 … … 457 429 const vector& vector::operator+=(const vector& other) 458 430 { 459 add(other); 431 int status=gsl_vector_add(v_,other. v_); 432 if (status) 433 throw utility::GSL_error(std::string("vector::add", status)); 460 434 return *this; 461 435 } 462 436 463 437 438 const vector& vector::operator+=(double d) 439 { 440 gsl_vector_add_constant(v_, d); 441 return *this; 442 } 443 444 464 445 const vector& vector::operator=(const vector& other) 465 446 { 466 sub(other); 447 int status=gsl_vector_sub(v_, other.v_); 448 if (status) 449 throw utility::GSL_error(std::string("vector::sub", status)); 467 450 return *this; 468 451 } … … 471 454 const vector& vector::operator*=(const double d) 472 455 { 473 scale(d);456 gsl_vector_scale(v_, d); 474 457 return *this; 475 458 } 
trunk/yat/utility/vector.h
r767 r775 216 216 217 217 /** 218 \brief Vector addition, \f$ this_i = this_i + other_i \;219 \forall i \f$.220 221 \throw GSL_error if dimensions mismatch.222 */223 void add(const vector& other);224 225 /**226 \brief Add a constant to a vector, \f$ this_i = this_i + term \;227 \forall i \f$.228 */229 void add(double term);230 231 /**232 218 \brief This function performs elementwise division, \f$ this_i = 233 219 this_i/other_i \; \forall i \f$. … … 311 297 312 298 /** 313 \brief Rescale vector, \f$ this_i = this_i * factor \; \forall i \f$.314 */315 void scale(double factor);316 317 /**318 299 \brief Set element values to values in \a vec. 319 300 … … 354 335 /// 355 336 void sort(void); 356 357 /**358 \brief Vector subtraction, \f$ this_i = this_i  other_i \;359 \forall i \f$.360 361 \throw GSL_error if dimensions mismatch.362 */363 void sub(const vector& other);364 337 365 338 /// … … 455 428 456 429 /** 457 \brief Addition and assign operator. 430 \brief Addition and assign operator. Vector addition, \f$ 431 this_i = this_i + other_i \; \forall i \f$. 458 432 459 433 \return A const reference to the resulting vector. … … 464 438 465 439 /** 466 \brief Subtract and assign operator. 440 \brief Add a constant to a vector, \f$ this_i = this_i + d \; 441 \forall i \f$. 467 442 468 443 \return A const reference to the resulting vector. 444 */ 445 const vector& operator+=(double d); 446 447 /** 448 \brief Subtract and assign operator. Vector subtraction, \f$ 449 this_i = this_i  other_i \; \forall i \f$. 450 451 \return A const reference to the resulting vector. 469 452 470 453 \throw GSL_error if dimensions mismatch. … … 472 455 const vector& operator=(const vector&); 473 456 474 /// 475 /// Multiply with scalar and assign operator. 476 /// 477 /// @return A const reference to the resulting vector. 478 /// 479 const vector& operator*=(const double); 457 /** 458 \brief Subtract a constant to a vector, \f$ this_i = this_i  d 459 \; \forall i \f$. 460 461 \return A const reference to the resulting vector. 462 */ 463 const vector& operator=(double d); 464 465 /** 466 \brief Multiply with scalar and assign operator, \f$ this_i = 467 this_i * d \; \forall i \f$. 468 469 \return A const reference to the resulting vector. 470 */ 471 const vector& operator*=(double d); 480 472 481 473
Note: See TracChangeset
for help on using the changeset viewer.