Changeset 784


Ignore:
Timestamp:
Mar 6, 2007, 5:02:30 PM (17 years ago)
Author:
Jari Häkkinen
Message:

References #155. Removed potential null pointer usage. Some unwanted asserts removed.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/vector_test.cc

    r782 r784  
    173173    ok=false;
    174174
     175  // test of const view implementation (make sure no zero pointer used.
     176  const utility::vector vv(10,3.0);
     177  const utility::vector vview(vv,0,5,1);
     178  utility::vector vv2(5,2.0);
     179  vv2.mul(vview); // should work without an abort due to zero pointer in mul
     180  vv2.div(vview); // should work without an abort due to zero pointer in mul
     181
    175182  return (ok ? 0 : -1);
    176183}
  • trunk/yat/utility/vector.cc

    r783 r784  
    212212  void vector::div(const vector& other)
    213213  {
    214     assert(v_); assert(other.v_);
    215     int status=gsl_vector_div(v_,other.v_);
     214    assert(v_);
     215    int status=gsl_vector_div(v_,other.gsl_vector_p());
    216216    if (status)
    217217      throw utility::GSL_error(std::string("vector::div",status));
     
    239239  void vector::mul(const vector& other)
    240240  {
    241     assert(v_); assert(other.v_);
    242     int status=gsl_vector_mul(v_,other.v_);
     241    assert(v_);
     242    int status=gsl_vector_mul(v_,other.gsl_vector_p());
    243243    if (status)
    244244      throw utility::GSL_error(std::string("vector::mul",status));
     
    255255  void vector::set(const vector& vec)
    256256  {
    257     assert(v_); assert(vec.v_);
    258     if (gsl_vector_memcpy(v_,vec.v_))
     257    assert(v_);
     258    if (gsl_vector_memcpy(v_,vec.gsl_vector_p()))
    259259      throw utility::GSL_error("vector::set dimension mis-match");
    260260  }
     
    357357  {
    358358    assert(v_);
    359     int status=gsl_vector_add(v_, other.v_);
     359    int status=gsl_vector_add(v_, other.gsl_vector_p());
    360360    if (status)
    361361      throw utility::GSL_error(std::string("vector::add", status));
     
    375375  {
    376376    assert(v_);
    377     int status=gsl_vector_sub(v_, other.v_);
     377    int status=gsl_vector_sub(v_, other.gsl_vector_p());
    378378    if (status)
    379379      throw utility::GSL_error(std::string("vector::sub", status));
Note: See TracChangeset for help on using the changeset viewer.