Ignore:
Timestamp:
Mar 11, 2007, 1:12:34 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Addresses #193. Added missing implementations.

File:
1 edited

Legend:

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

    r790 r791  
    199199
    200200
    201   gsl_vector* vector::create_gsl_vector_copy(void) const
    202   {
    203     gsl_vector* vec = gsl_vector_alloc(size());
    204     if (!vec)
    205       throw utility::GSL_error("vector::create_gsl_vector_copy failed to allocate memory");
    206     if (gsl_vector_memcpy(vec, proxy_v_))
    207       throw utility::GSL_error("vector::create_gsl_matrix_copy dimension mis-match");
    208     return vec;
    209   }
    210 
    211 
    212201  const vector& vector::clone(const vector& other)
    213202  {
     
    236225    return *this;
    237226  }
     227
     228
     229  gsl_vector* vector::create_gsl_vector_copy(void) const
     230  {
     231    gsl_vector* vec = gsl_vector_alloc(size());
     232    if (!vec)
     233      throw utility::GSL_error("vector::create_gsl_vector_copy failed to allocate memory");
     234    if (gsl_vector_memcpy(vec, proxy_v_))
     235      throw utility::GSL_error("vector::create_gsl_matrix_copy dimension mis-match");
     236    return vec;
     237  }
    238238
    239239
     
    417417
    418418
     419  const vector& vector::operator-=(const double d)
     420  {
     421    assert(v_);
     422    gsl_vector_add_constant(v_, -d);
     423    return *this;
     424  }
     425
     426
    419427  const vector& vector::operator*=(const double d)
    420428  {
     
    468476    gsl_vector_minmax_index(v.gsl_vector_p(), &minmax.first, &minmax.second);
    469477    return minmax;
     478  }
     479
     480
     481  bool nan(const vector& templat, vector& flag)
     482  {
     483    size_t rows=templat.size();
     484    if (rows!=flag.size())
     485      flag.clone(vector(rows,1.0));
     486    else
     487      flag.set_all(1.0);
     488    bool nan=false;
     489    for (size_t i=0; i<rows; i++)
     490      if (std::isnan(templat(i))) {
     491        flag(i)=0;
     492        nan=true;
     493      }
     494    return nan;
    470495  }
    471496
Note: See TracChangeset for help on using the changeset viewer.