Ignore:
Timestamp:
Feb 17, 2007, 1:25:36 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Addresses #2. Continued adding GSL_error exceptions.

File:
1 edited

Legend:

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

    r719 r751  
    2323
    2424#include "SVD.h"
     25#include <sstream>
    2526
    2627namespace theplu {
     
    4041
    4142
    42   int SVD::decompose(SVDalgorithm algo)
     43  void SVD::decompose(SVDalgorithm algo)
    4344  {
     45    int status=0;
    4446    switch (algo) {
    45         case GolubReinsch:
    46           return golub_reinsch();
    47         case ModifiedGolubReinsch:
    48           return modified_golub_reinsch();
    49         case Jacobi:
    50           return jacobi();
     47    case GolubReinsch:
     48      status=golub_reinsch();
     49      break;
     50    case ModifiedGolubReinsch:
     51      status=modified_golub_reinsch();
     52      break;
     53    case Jacobi:
     54      status=jacobi();
     55      break;
     56    default:
     57      std::stringstream ss("SVD::decompose ");
     58      ss << algo << " is not a valid SVDalgorithm";
     59      throw GSL_error(ss.str());
    5160    }
    52     // Jari, the program should never end up here, return values should be
    53     // something different from normal GSL return values, or maybe
    54     // throw an exception.
    55     return 0;
     61    if (status)
     62      throw utility::GSL_error(std::string("SVD::decompose",status));
    5663  }
    5764
     
    8895
    8996
    90   int SVD::solve(const utility::vector& b, utility::vector& x)
     97  void SVD::solve(const utility::vector& b, utility::vector& x)
    9198  {
    92     return gsl_linalg_SV_solve(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
    93                                s_.gsl_vector_p(), b.gsl_vector_p(),
    94                                x.gsl_vector_p());
     99    int status=gsl_linalg_SV_solve(U_.gsl_matrix_p(), V_.gsl_matrix_p(),
     100                                   s_.gsl_vector_p(), b.gsl_vector_p(),
     101                                   x.gsl_vector_p());
     102    if (status)
     103      throw utility::GSL_error(std::string("SVD::solve",status));
    95104  }
    96105
Note: See TracChangeset for help on using the changeset viewer.