Changeset 775


Ignore:
Timestamp:
Mar 2, 2007, 12:53:03 AM (17 years ago)
Author:
Jari Häkkinen
Message:

Fixes #200.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/averager_test.cc

    r680 r775  
    152152     
    153153  aw2->reset();
    154   w.scale(17);
     154  w*=17;
    155155  aw2->add_values(x,w);
    156156  if (!equal(aw,*aw2,tol,error)){
     
    208208     
    209209  apw2->reset();
    210   w.scale(17);
     210  w*=17;
    211211  apw2->add_values(x,y,w,w);
    212212  if (!equal(apw,*apw2,tol,error)){
  • trunk/test/regression_test.cc

    r759 r775  
    316316  double standard_error2 = wr.standard_error2(2000);
    317317
    318   w.scale(2);
     318  w*=2;
    319319  wr.fit(x,y,w);
    320320  if (fabs(wr.predict(2000)-predict)>10e-11){
     
    459459  double standard_error2 = mdw.standard_error2(z);
    460460
    461   w.scale(2);
     461  w*=2;
    462462  mdw.fit(data,y,w);
    463463  if (fabs(mdw.predict(z)-predict)>10e-10){
  • trunk/yat/utility/vector.cc

    r759 r775  
    198198
    199199
    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 
    214200  gsl_vector* vector::create_gsl_vector_copy(void) const
    215201  {
     
    309295
    310296
    311   void vector::scale(double factor)
    312   {
    313     gsl_vector_scale(v_,factor);
    314   }
    315 
    316 
    317297  void vector::set(const vector& vec)
    318298  {
     
    351331  {
    352332    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));
    361333  }
    362334
     
    457429  const vector& vector::operator+=(const vector& other)
    458430  {
    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));
    460434    return *this;
    461435  }
    462436
    463437
     438  const vector& vector::operator+=(double d)
     439  {
     440    gsl_vector_add_constant(v_, d);
     441    return *this;
     442  }
     443
     444
    464445  const vector& vector::operator-=(const vector& other)
    465446  {
    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));
    467450    return *this;
    468451  }
     
    471454  const vector& vector::operator*=(const double d)
    472455  {
    473     scale(d);
     456    gsl_vector_scale(v_, d);
    474457    return *this;
    475458  }
  • trunk/yat/utility/vector.h

    r767 r775  
    216216
    217217    /**
    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     /**
    232218       \brief This function performs element-wise division, \f$ this_i =
    233219       this_i/other_i \; \forall i \f$.
     
    311297
    312298    /**
    313        \brief Rescale vector, \f$ this_i = this_i * factor \; \forall i \f$.
    314     */
    315     void scale(double factor);
    316 
    317     /**
    318299       \brief Set element values to values in \a vec.
    319300
     
    354335    ///
    355336    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);
    364337
    365338    ///
     
    455428
    456429    /**
    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$.
    458432
    459433       \return A const reference to the resulting vector.
     
    464438
    465439    /**
    466        \brief Subtract and assign operator.
     440       \brief Add a constant to a vector, \f$ this_i = this_i + d \;
     441       \forall i \f$.
    467442
    468443       \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.
    469452
    470453       \throw GSL_error if dimensions mis-match.
     
    472455    const vector& operator-=(const vector&);
    473456
    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);
    480472
    481473
Note: See TracChangeset for help on using the changeset viewer.