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/matrix.cc

    r754 r755  
    191191
    192192
    193   int matrix::div_elements(const matrix& b)
    194   {
    195     return gsl_matrix_div_elements(m_, b.m_);
     193  void matrix::div_elements(const matrix& b)
     194  {
     195    int status=gsl_matrix_div_elements(m_, b.m_);
     196    if (status)
     197      throw utility::GSL_error(std::string("matrix::div_elements",status));
    196198  }
    197199
     
    269271
    270272
    271   int matrix::mul_elements(const matrix& b)
    272   {
    273     return gsl_matrix_mul_elements(m_, b.m_);
     273  void matrix::mul_elements(const matrix& b)
     274  {
     275    int status=gsl_matrix_mul_elements(m_, b.m_);
     276    if (status)
     277      throw utility::GSL_error(std::string("matrix::mul_elements",status));
     278   
    274279  }
    275280
     
    326331
    327332
    328   int matrix::swap(matrix& other)
    329   {
    330     return gsl_matrix_swap(m_, other.m_);
    331   }
    332 
    333 
    334   int matrix::swap_columns(const size_t i, const size_t j)
    335   {
    336     return gsl_matrix_swap_columns(m_, i, j);
    337   }
    338 
    339 
    340   int matrix::swap_rowcol(const size_t i, const size_t j)
    341   {
    342     return gsl_matrix_swap_rowcol(m_, i, j);
    343   }
    344 
    345 
    346   int matrix::swap_rows(const size_t i, const size_t j)
    347   {
    348     return gsl_matrix_swap_rows(m_, i, j);
     333  void matrix::swap(matrix& other)
     334  {
     335    int status=gsl_matrix_swap(m_, other.m_);
     336    if (status)
     337      throw utility::GSL_error(std::string("matrix::swap",status));
     338  }
     339
     340
     341  void matrix::swap_columns(const size_t i, const size_t j)
     342  {
     343    int status=gsl_matrix_swap_columns(m_, i, j);
     344    if (status)
     345      throw utility::GSL_error(std::string("matrix::swap_columns",status));
     346  }
     347
     348
     349  void matrix::swap_rowcol(const size_t i, const size_t j)
     350  {
     351    int status=gsl_matrix_swap_rowcol(m_, i, j);
     352    if (status)
     353      throw utility::GSL_error(std::string("matrix::swap_rowcol",status));
     354  }
     355
     356
     357  void matrix::swap_rows(const size_t i, const size_t j)
     358  {
     359    int status=gsl_matrix_swap_rows(m_, i, j);
     360    if (status)
     361      throw utility::GSL_error(std::string("matrix::swap_rows",status));
    349362  }
    350363
     
    368381  double& matrix::operator()(size_t row, size_t column)
    369382  {
    370     return (*gsl_matrix_ptr(m_, row, column));
     383    double* d=gsl_matrix_ptr(m_, row, column);
     384    if (!d)
     385      throw utility::GSL_error("matrix::operator()",GSL_EINVAL);
     386    return *d;
    371387  }
    372388
     
    374390  const double& matrix::operator()(size_t row, size_t column) const
    375391  {
    376     return (*gsl_matrix_const_ptr(m_, row, column));
     392    const double* d=gsl_matrix_const_ptr(m_, row, column);
     393    if (!d)
     394      throw utility::GSL_error("matrix::operator()",GSL_EINVAL);
     395    return *d;
    377396  }
    378397
Note: See TracChangeset for help on using the changeset viewer.