Changeset 714 for trunk/yat/utility


Ignore:
Timestamp:
Dec 22, 2006, 1:10:54 AM (15 years ago)
Author:
Jari Häkkinen
Message:

Addresses #170..

Location:
trunk/yat/utility
Files:
2 edited

Legend:

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

    r703 r714  
    189189
    190190
     191  int vector::add(const vector& other)
     192  {
     193    return gsl_vector_add(v_,other.v_);
     194  }
     195
     196
     197  int vector::add(double term)
     198  {
     199    return gsl_vector_add_constant(v_,term);
     200  }
     201
     202
    191203  gsl_vector* vector::create_gsl_vector_copy(void) const
    192204  {
     
    197209
    198210
     211  int vector::div(const vector& other)
     212  {
     213    return gsl_vector_div(v_,other.v_);
     214  }
     215
     216
     217  const gsl_vector* vector::gsl_vector_p(void) const
     218  {
     219    return proxy_v_;
     220  }
     221
     222
     223  gsl_vector* vector::gsl_vector_p(void)
     224  {
     225    return v_;
     226  }
     227
     228
     229  bool vector::isnull(void) const
     230  {
     231    return gsl_vector_isnull(proxy_v_);
     232  }
     233
     234
     235  bool vector::isview(void) const
     236  {
     237    return view_ || view_const_;
     238  }
     239
     240
     241  double vector::max(void) const
     242  {
     243    return gsl_vector_max(proxy_v_);
     244  }
     245
     246
     247  size_t vector::max_index(void) const
     248  {
     249    return gsl_vector_max_index(proxy_v_);
     250  }
     251
     252
     253  double vector::min(void) const
     254  {
     255    return gsl_vector_min(proxy_v_);
     256  }
     257
     258
     259  size_t vector::min_index(void) const
     260  {
     261    return gsl_vector_min_index(proxy_v_);
     262  }
     263
     264
    199265  std::pair<double,double> vector::minmax(void) const
    200266  {
     
    210276    gsl_vector_minmax_index(proxy_v_, &min_index, &max_index);
    211277    return std::pair<size_t,size_t>(min_index,max_index);
     278  }
     279
     280
     281  int vector::mul(const vector& other)
     282  {
     283    return gsl_vector_mul(v_,other.v_);
     284  }
     285
     286
     287  int vector::reverse(void)
     288  {
     289    return gsl_vector_reverse(v_);
     290  }
     291
     292
     293  int vector::scale(double factor)
     294  {
     295    return gsl_vector_scale(v_,factor);
     296  }
     297
     298
     299  int vector::set(const vector& vec)
     300  {
     301    return gsl_vector_memcpy(v_,vec.v_);
     302  }
     303
     304
     305  void vector::set_all(const double& value)
     306  {
     307    gsl_vector_set_all(v_,value);
     308  }
     309
     310
     311  void vector::set_basis(const size_t i)
     312  {
     313    gsl_vector_set_basis(v_,i);
     314  }
     315
     316
     317  void vector::set_zero(void)
     318  {
     319    gsl_vector_set_zero(v_);
     320  }
     321
     322
     323  size_t vector::size(void) const
     324  {
     325    return proxy_v_->size;
     326  }
     327
     328
     329  void vector::sort(void)
     330  {
     331    gsl_sort_vector(v_);
     332  }
     333
     334
     335  int vector::sub(const vector& other)
     336  {
     337    return gsl_vector_sub(v_,other.v_);
    212338  }
    213339
     
    219345      sum += (*this)(i);
    220346    return( sum );
     347  }
     348
     349
     350  int vector::swap(vector& other)
     351  {
     352    return gsl_vector_swap(v_,other.v_);
     353  }
     354
     355
     356  int vector::swap_elements(size_t i, size_t j)
     357  {
     358    return gsl_vector_swap_elements(v_,i,j);
     359  }
     360
     361
     362  double& vector::operator()(size_t i)
     363  {
     364    return *gsl_vector_ptr(v_,i);
     365  }
     366
     367
     368  const double& vector::operator()(size_t i) const
     369  {
     370    return *gsl_vector_const_ptr(proxy_v_,i);
     371  }
     372
     373
     374  double& vector::operator[](size_t i)
     375  {
     376    return *gsl_vector_ptr(v_,i);
     377  }
     378
     379
     380  const double& vector::operator[](size_t i) const
     381  {
     382    return *gsl_vector_const_ptr(proxy_v_,i);
    221383  }
    222384
  • trunk/yat/utility/vector.h

    r703 r714  
    209209    ///
    210210    // Jari, group as vector_operators
    211     inline int add(const vector& other) { return gsl_vector_add(v_,other.v_); }
     211    int add(const vector& other);
    212212
    213213    ///
     
    218218    ///
    219219    // Jari, group as vector_operators
    220     inline int add(double term) { return gsl_vector_add_constant(v_,term); }
     220    int add(double term);
    221221
    222222    ///
     
    227227    ///
    228228    // Jari, doxygen group as Vector operators
    229     inline int div(const vector& other) { return gsl_vector_div(v_,other.v_); }
     229    int div(const vector& other);
    230230
    231231    ///
    232232    /// @return A const pointer to the internal GSL vector,
    233233    ///
    234     inline const gsl_vector* gsl_vector_p(void) const { return proxy_v_; }
     234    const gsl_vector* gsl_vector_p(void) const;
    235235
    236236    ///
    237237    /// @return A pointer to the internal GSL vector,
    238238    ///
    239     inline gsl_vector* gsl_vector_p(void) { return v_; }
     239    gsl_vector* gsl_vector_p(void);
    240240
    241241    ///
     
    243243    /// othwerwise;
    244244    ///
    245     inline bool isnull(void) const { return gsl_vector_isnull(proxy_v_); }
     245    bool isnull(void) const;
    246246
    247247    ///
     
    251251    /// @return True if the object is a view, false othwerwise.
    252252    ///
    253     inline bool isview(void) const { return view_ || view_const_; }
     253    bool isview(void) const;
    254254
    255255    ///
     
    257257    ///
    258258    // Jari, doxygen group as Finding maximum and minimum elements
    259     inline double max(void) const { return gsl_vector_max(proxy_v_); }
     259    double max(void) const;
    260260
    261261    ///
     
    264264    ///
    265265    // Jari, doxygen group as Finding maximum and minimum elements
    266     inline size_t
    267     max_index(void) const { return gsl_vector_max_index(proxy_v_); }
     266    size_t max_index(void) const;
    268267
    269268    ///
     
    271270    ///
    272271    // Jari, doxygen group as Finding maximum and minimum elements
    273     inline double min(void) const { return gsl_vector_min(proxy_v_); }
     272    double min(void) const;
    274273
    275274    ///
     
    278277    ///
    279278    // Jari, doxygen group as Finding maximum and minimum elements
    280     inline size_t
    281     min_index(void) const { return gsl_vector_min_index(proxy_v_); }
     279    size_t min_index(void) const;
    282280
    283281    ///
     
    304302    ///
    305303    // Jari, doxygen group as Vector operators
    306     inline int mul(const vector& other) { return gsl_vector_mul(v_,other.v_); }
     304    int mul(const vector& other);
    307305
    308306    ///
     
    312310    ///
    313311    // Jari, doxygen group as Exchanging elements
    314     inline int reverse(void) { return gsl_vector_reverse(v_);}
     312    int reverse(void);
    315313
    316314    ///
     
    320318    ///
    321319    // Jari, doxygen group as Vector operators
    322     inline int scale(double factor) { return gsl_vector_scale(v_,factor); }
     320    int scale(double factor);
    323321
    324322    ///
     
    332330    /// @see const vector& operator=(const vector&)
    333331    ///
    334     inline int set(const vector& vec) { return gsl_vector_memcpy(v_,vec.v_); }
     332    int set(const vector& vec);
    335333
    336334    ///
     
    338336    ///
    339337    // Jari, doxygen group as Initializing vector elements
    340     inline void set_all(const double& value) { gsl_vector_set_all(v_,value); }
     338    void set_all(const double& value);
    341339
    342340    ///
     
    346344    ///
    347345    // Jari, doxygen group as Initializing vector elements
    348     inline void set_basis(const size_t i) { gsl_vector_set_basis(v_,i); }
     346    void set_basis(const size_t i);
    349347   
    350348    ///
     
    352350    ///
    353351    // Jari, doxygen group as Initializing vector elements
    354     inline void set_zero(void) { gsl_vector_set_zero(v_); }
     352    void set_zero(void);
    355353
    356354    ///
    357355    /// @return the number of elements in the vector.
    358356    ///
    359     inline size_t size(void) const { return proxy_v_->size; }
     357    size_t size(void) const;
    360358
    361359    ///
     
    365363    ///
    366364    // Markus to Jari, doxygen group as Exchanging elements ????
    367     inline void sort(void) { gsl_sort_vector(v_); }
     365    void sort(void);
    368366
    369367    ///
     
    373371    ///
    374372    // Jari, doxygen group as Vector operators
    375     inline int sub(const vector& other) { return gsl_vector_sub(v_,other.v_); }
     373    int sub(const vector& other);
    376374
    377375    ///
     
    388386    /// @return GSL_SUCCESS on normal exit.
    389387    ///
    390     inline int swap(vector& other) { return gsl_vector_swap(v_,other.v_); }
     388    int swap(vector& other);
    391389
    392390    ///
     
    396394    ///
    397395    // Jari, doxygen group as Exchanging elements
    398     inline int
    399     swap_elements(size_t i,size_t j) { return gsl_vector_swap_elements(v_,i,j);}
     396    int swap_elements(size_t i,size_t j);
    400397
    401398    ///
     
    405402    ///
    406403    // Jari, doxygen group as Accessing vector elements
    407     inline double& operator()(size_t i) { return *gsl_vector_ptr(v_,i); }
     404    double& operator()(size_t i);
    408405
    409406    ///
     
    413410    ///
    414411    // Jari, doxygen group as Accessing vector elements
    415     inline const double&
    416     operator()(size_t i) const { return *gsl_vector_const_ptr(proxy_v_,i); }
     412    const double& operator()(size_t i) const;
    417413
    418414    ///
     
    422418    ///
    423419    // Jari, doxygen group as Accessing vector elements
    424     inline double& operator[](size_t i) { return *gsl_vector_ptr(v_,i); }
     420    double& operator[](size_t i);
    425421
    426422    ///
     
    430426    ///
    431427    // Jari, doxygen group as Accessing vector elements
    432     inline const double&
    433     operator[](size_t i) const { return *gsl_vector_const_ptr(proxy_v_,i); }
    434 
    435     ///
    436     /// @return The dot product.
    437     ///
    438     double operator*(const vector&) const;
     428    const double& operator[](size_t i) const;
    439429
    440430    ///
     
    445435    ///
    446436    bool operator==(const vector&) const;
     437
     438    ///
     439    /// @return The dot product.
     440    ///
     441    double operator*(const vector&) const;
    447442
    448443    ///
Note: See TracChangeset for help on using the changeset viewer.