Changeset 775
- Timestamp:
- Mar 2, 2007, 12:53:03 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/averager_test.cc
r680 r775 152 152 153 153 aw2->reset(); 154 w .scale(17);154 w*=17; 155 155 aw2->add_values(x,w); 156 156 if (!equal(aw,*aw2,tol,error)){ … … 208 208 209 209 apw2->reset(); 210 w .scale(17);210 w*=17; 211 211 apw2->add_values(x,y,w,w); 212 212 if (!equal(apw,*apw2,tol,error)){ -
trunk/test/regression_test.cc
r759 r775 316 316 double standard_error2 = wr.standard_error2(2000); 317 317 318 w .scale(2);318 w*=2; 319 319 wr.fit(x,y,w); 320 320 if (fabs(wr.predict(2000)-predict)>10e-11){ … … 459 459 double standard_error2 = mdw.standard_error2(z); 460 460 461 w .scale(2);461 w*=2; 462 462 mdw.fit(data,y,w); 463 463 if (fabs(mdw.predict(z)-predict)>10e-10){ -
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 mis-match.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 element-wise 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 mis-match.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 mis-match. … … 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.