Changeset 750


Ignore:
Timestamp:
Feb 17, 2007, 11:56:29 AM (17 years ago)
Author:
Jari Häkkinen
Message:

Addresses #2. Continued adding GSL_error exceptions.

Location:
trunk/yat
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/random/random.cc

    r738 r750  
    3939      // support rng/seed changes through environment vars
    4040    if (!gsl_rng_env_setup())
    41       throw utility::GSL_error("RNG: unknown generator");
     41      throw utility::GSL_error("RNG::RNG unknown generator");
    4242    if (!(rng_=gsl_rng_alloc(gsl_rng_default)))
    43       throw utility::GSL_error("RNG: failed to allocate memory");
     43      throw utility::GSL_error("RNG::RNG failed to allocate memory");
    4444  }
    4545
     
    110110  {
    111111    if (!(rng_ = gsl_rng_clone(rng->rng())))
    112       throw utility::GSL_error("RNG_state: failed to allocate memory");
     112      throw utility::GSL_error("RNG_state::RNG_state failed to allocate memory");
    113113  }
    114114 
     
    152152    delete p;
    153153    if (!gen_)
    154       throw utility::GSL_error("DiscreteGeneral: failed to setup generator.");
     154      throw utility::GSL_error("DiscreteGeneral::DiscreteGeneral failed to setup generator.");
    155155  }
    156156
     
    174174  {
    175175    if (range_>rng_->max()) {
    176       std::stringstream ss("DiscreteUniform: ");
     176      std::stringstream ss("DiscreteUniform::DiscreteUniform: ");
    177177      ss << n << " is too large for RNG " << rng_->name();
    178178      throw utility::GSL_error(ss.str());
     
    193193    // underlying RNG
    194194    if (n>rng_->max()) {
    195       std::stringstream ss("DiscreteUniform::op(): ");
     195      std::stringstream ss("DiscreteUniform::operator(u_long): ");
    196196      ss << n << " is too large for RNG " << rng_->name();
    197197      throw utility::GSL_error(ss.str());
  • trunk/yat/regression/MultiDimensional.cc

    r739 r750  
    2323
    2424#include "MultiDimensional.h"
     25#include "yat/utility/Exception.h"
    2526#include "yat/utility/matrix.h"
    2627#include "yat/utility/vector.h"
     
    5960    if (work_)
    6061      gsl_multifit_linear_free(work_);
    61     work_=gsl_multifit_linear_alloc(x.rows(),fit_parameters_.size());
    62     gsl_multifit_linear(x.gsl_matrix_p(),y.gsl_vector_p(),
    63                         fit_parameters_.gsl_vector_p(),
    64                         covariance_.gsl_matrix_p(),&chisquare_,work_);
     62    if (!(work_=gsl_multifit_linear_alloc(x.rows(),fit_parameters_.size())))
     63      throw utility::GSL_error("MultiDimensional::fit failed to allocate memory");
     64
     65    int status = gsl_multifit_linear(x.gsl_matrix_p(), y.gsl_vector_p(),
     66                                     fit_parameters_.gsl_vector_p(),
     67                                     covariance_.gsl_matrix_p(), &chisquare_,
     68                                     work_);
     69    if (status)
     70      throw utility::GSL_error(std::string("MultiDimensional::fit",status));
     71
    6572    s2_ = chisquare_/(x.rows()-x.columns());
    6673  }
  • trunk/yat/regression/MultiDimensionalWeighted.cc

    r741 r750  
    6262    if (work_)
    6363      gsl_multifit_linear_free(work_);
    64     work_=gsl_multifit_linear_alloc(x.rows(),fit_parameters_.size());
    65     gsl_multifit_wlinear(x.gsl_matrix_p(),w.gsl_vector_p(),y.gsl_vector_p(),
    66                          fit_parameters_.gsl_vector_p(),
    67                          covariance_.gsl_matrix_p(),&chisquare_,work_);
     64    if (!(work_=gsl_multifit_linear_alloc(x.rows(),fit_parameters_.size())))
     65      throw utility::GSL_error("MultiDimensionalWeighted::fit failed to allocate memory");
     66    int status = gsl_multifit_wlinear(x.gsl_matrix_p(), w.gsl_vector_p(),
     67                                      y.gsl_vector_p(),
     68                                      fit_parameters_.gsl_vector_p(),
     69                                      covariance_.gsl_matrix_p(), &chisquare_,
     70                                      work_);
     71    if (status)
     72      throw utility::GSL_error(std::string("MultiDimensionalWeighted::fit",
     73                                           status));
    6874
    6975    statistics::AveragerWeighted aw;
  • trunk/yat/utility/Exception.h

    r738 r750  
    2929#include <string>
    3030
     31#include <gsl/gsl_errno.h>
     32
    3133namespace theplu {
    3234namespace yat {
     
    4850    */
    4951    inline GSL_error(std::string message) throw()
    50       : std::runtime_error("IO_error: " + message) {}
     52      : std::runtime_error("GSL_error: " + message) {}
     53
     54    inline GSL_error(std::string message, int gsl_status) throw()
     55      : std::runtime_error("GSL_error: " + message + gsl_strerror(gsl_status)) {}
    5156  };
    5257
Note: See TracChangeset for help on using the changeset viewer.