Changeset 1099


Ignore:
Timestamp:
Feb 18, 2008, 4:42:46 AM (14 years ago)
Author:
Jari Häkkinen
Message:

Readded resize() to vector.

Location:
trunk/yat/utility
Files:
2 edited

Legend:

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

    r1068 r1099  
    195195  {
    196196    delete_allocated_memory();
    197     if (!other.size())
    198       vec_=NULL;
    199     else  {   
     197    if (other.size()) {
    200198      if (size()!=other.size())
    201199        vec_ = gsl_vector_alloc(other.size());
     
    203201        throw utility::GSL_error("vector failed to allocate memory");
    204202      gsl_vector_memcpy(vec_,other.gsl_vector_p());
     203      const_vec_ = vec_;
    205204    }
    206     const_vec_ = vec_;
    207205    return *this;
    208206  }
     207
     208
     209  void vector::resize(size_t n, double init_value)
     210  {
     211    delete_allocated_memory();
     212    const_vec_ = vec_ = gsl_vector_alloc(n);
     213    if (!vec_)
     214      throw utility::GSL_error("vector::vector failed to allocate memory");
     215    all(init_value);
     216  }
    209217
    210218
  • trunk/yat/utility/vector.h

    r1068 r1099  
    116116
    117117    /**
     118      \brief Resize vector
     119
     120      All elements are set to \a init_value.
     121
     122      \note Underlying GSL vector is destroyed and a view into this
     123      vector becomes invalid.
     124    */
     125    void resize(size_t, double init_value=0);
     126
     127    /**
    118128       \brief The assignment operator.
    119129
Note: See TracChangeset for help on using the changeset viewer.