Ignore:
Timestamp:
Feb 18, 2007, 1:01:39 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Addresses #2 and #65. Continued adding GSL_error exceptions, and added doxygen briefs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/vector.cc

    r754 r755  
    219219
    220220
    221   int vector::div(const vector& other)
    222   {
    223     return gsl_vector_div(v_,other.v_);
     221  void vector::div(const vector& other)
     222  {
     223    int status=gsl_vector_div(v_,other.v_);
     224    if (status)
     225      throw utility::GSL_error(std::string("vector::div",status));
    224226  }
    225227
     
    289291
    290292
    291   int vector::mul(const vector& other)
    292   {
    293     return gsl_vector_mul(v_,other.v_);
    294   }
    295 
    296 
    297   int vector::reverse(void)
    298   {
    299     return gsl_vector_reverse(v_);
     293  void vector::mul(const vector& other)
     294  {
     295    int status=gsl_vector_mul(v_,other.v_);
     296    if (status)
     297      throw utility::GSL_error(std::string("vector::mul",status));
     298  }
     299
     300
     301  void vector::reverse(void)
     302  {
     303    gsl_vector_reverse(v_);
    300304  }
    301305
     
    363367
    364368
    365   int vector::swap(vector& other)
    366   {
    367     return gsl_vector_swap(v_,other.v_);
    368   }
    369 
    370 
    371   int vector::swap_elements(size_t i, size_t j)
    372   {
    373     return gsl_vector_swap_elements(v_,i,j);
     369  void vector::swap(vector& other)
     370  {
     371    int status=gsl_vector_swap(v_,other.v_);
     372    if (status)
     373      throw utility::GSL_error(std::string("vector::swap",status));
     374  }
     375
     376
     377  void vector::swap_elements(size_t i, size_t j)
     378  {
     379    int status=gsl_vector_swap_elements(v_, i, j);
     380    if (status)
     381      throw utility::GSL_error(std::string("vector::swap_elements",status));
    374382  }
    375383
     
    377385  double& vector::operator()(size_t i)
    378386  {
    379     return *gsl_vector_ptr(v_,i);
     387    double* d=gsl_vector_ptr(v_, i);
     388    if (!d)
     389      throw utility::GSL_error("vector::operator()",GSL_EINVAL);
     390    return *d;
    380391  }
    381392
     
    383394  const double& vector::operator()(size_t i) const
    384395  {
    385     return *gsl_vector_const_ptr(proxy_v_,i);
     396    const double* d=gsl_vector_const_ptr(proxy_v_, i);
     397    if (!d)
     398      throw utility::GSL_error("vector::operator()",GSL_EINVAL);
     399    return *d;
    386400  }
    387401
Note: See TracChangeset for help on using the changeset viewer.