Changeset 3169


Ignore:
Timestamp:
Jan 22, 2014, 8:41:42 AM (10 years ago)
Author:
Peter
Message:

use private function create_gsl_vector rather than calling gsl function and repeating code for error detection

File:
1 edited

Legend:

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

    r2881 r3169  
    112112
    113113    // convert the data to a gsl vector
    114     vec_ = gsl_vector_alloc(nof_rows*nof_columns);
    115     if (!vec_)
    116       throw utility::GSL_error("Vector::Vector failed to allocate memory");
     114    vec_ = create_gsl_vector(nof_rows*nof_columns);
    117115    size_t n=0;
    118116    // if gsl error handler disabled, out of bounds index will not
     
    166164    if (!other.size())
    167165      return NULL;
    168     gsl_vector* vec = gsl_vector_alloc(other.size());
    169     if (!vec)
    170       throw utility::GSL_error("Vector::create_gsl_vector_copy failed to allocate memory");
     166    gsl_vector* vec = create_gsl_vector(other.size());
    171167    if (gsl_vector_memcpy(vec, other.gsl_vector_p()))
    172168      throw utility::GSL_error("Vector::create_gsl_vector_copy memcpy failed");
     
    181177    gsl_vector* vec = gsl_vector_alloc(n);
    182178    if (!vec)
    183       throw utility::GSL_error("Vector::create_gsl_vector failed to allocate memory");
     179      throw utility::GSL_error("Vector: failed to allocate memory");
    184180    return vec;
    185181  }
     
    205201    if (!n)
    206202      return;
    207     const_vec_ = vec_ = gsl_vector_alloc(n);
    208     if (!vec_)
    209       throw utility::GSL_error("Vector::resize failed to allocate memory");
     203    const_vec_ = vec_ = create_gsl_vector(n);
    210204    all(init_value);
    211205  }
Note: See TracChangeset for help on using the changeset viewer.