Changeset 1015


Ignore:
Timestamp:
Feb 1, 2008, 5:35:32 PM (14 years ago)
Author:
Peter
Message:

changing class names vectorView => VectorView? and vectorBase => VectorBase?. Refs #256

Location:
trunk
Files:
10 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/matrix_test.cc

    r1009 r1015  
    3636    : m_(i,j,value) {}
    3737
    38   inline theplu::yat::utility::vectorView
     38  inline theplu::yat::utility::VectorView
    3939  row(const size_t& i) { return m_.row_vec(i); }
    4040
     
    258258    for (size_t j=0; j<m5.columns(); ++j)
    259259      m5_sum2+=m5(i,j);
    260   utility::vectorView v5subrow(m5,3);
     260  utility::VectorView v5subrow(m5,3);
    261261  double v5subrow_sum=0;
    262262  for (size_t i=0; i<v5subrow.size(); ++i) {
     
    280280    for (size_t j=0; j<m5.columns(); ++j)
    281281      m5_sum3+=m5(i,j);
    282   utility::vectorView v5subcolumn = m5.column_vec(0);
     282  utility::VectorView v5subcolumn = m5.column_vec(0);
    283283  double v5subcolumn_sum=0;
    284284  for (size_t i=0; i<v5subcolumn.size(); ++i) {
     
    332332  *error << "\tthat class member returns a view" << std::endl;
    333333  matrixwrapper mw(5,2);
    334   utility::vectorView mwrow=mw.row(2);
     334  utility::VectorView mwrow=mw.row(2);
    335335  if (mwrow.gsl_vector_p()->data != &(mw.matrix()(2,0))) {
    336336    ok=false;
  • trunk/test/score_test.cc

    r1009 r1015  
    3232#include "yat/utility/matrix.h"
    3333#include "yat/utility/vector.h"
    34 #include "yat/utility/vectorView.h"
     34#include "yat/utility/VectorView.h"
    3535
    3636#include <cmath>
     
    9393  const double tol = 0.001;
    9494  for (size_t i=0; i<data.rows(); i++){
    95     utility::vectorView vec(data,i);
     95    utility::VectorView vec(data,i);
    9696    if (vec.size()!=target2.size()){
    9797      *error << "vec.size() is " << vec.size() << " and target2.size() is "
     
    109109  utility::vector weight(target2.size(),1);
    110110  for (size_t i=0; i<data.rows(); i++){
    111     utility::vectorView vec = data.row_vec(i);
     111    utility::VectorView vec = data.row_vec(i);
    112112    area = auc.score(target2, vec, weight);
    113113    if (area<correct_area(i)-tol || area>correct_area(i)+tol){
  • trunk/test/vector_test.cc

    r1009 r1015  
    2929#include "yat/utility/utility.h"
    3030#include "yat/utility/vector.h"
    31 #include "yat/utility/vectorView.h"
     31#include "yat/utility/VectorView.h"
    3232
    3333#include <fstream>
     
    7474  for (size_t i=0; i<vec.size(); i+=2)
    7575    sum_before+=vec[i];
    76   utility::vectorView vec_view(vec,0,6,2);
     76  utility::VectorView vec_view(vec,0,6,2);
    7777  sum_after=utility::sum(vec_view);
    7878  ok &= (sum_after==sum_before);
     
    8888    *message << "const view implementation" << std::endl;
    8989    const utility::vector vv(10,3.0);
    90     utility::vectorView vview(vv,0,5,1);
     90    utility::VectorView vview(vv,0,5,1);
    9191    // const utility::vector vview(vv,0,5,1); // this is the proper line
    9292    utility::vector vv2(5,2.0);
     
    148148    *message << "assignment operator on view" << std::endl;
    149149    vec[3]=vec[4]=vec[5]=13;
    150     utility::vectorView vec_view(vec,3,3,1);
     150    utility::VectorView vec_view(vec,3,3,1);
    151151    utility::vector vec2(3,123.0);
    152152    vec_view=vec2;
     
    173173      this_ok=false;
    174174    *message << "\tcloning vector view" << std::endl;
    175     utility::vectorView* vec_view=new utility::vectorView(vec,3,3,1);
    176     utility::vectorView vec_view2(*vec_view);
     175    utility::VectorView* vec_view=new utility::VectorView(vec,3,3,1);
     176    utility::VectorView vec_view2(*vec_view);
    177177    if (!vec_view2.isview())
    178178      this_ok=false;
  • trunk/yat/regression/Local.cc

    r1009 r1015  
    2727#include "OneDimensionalWeighted.h"
    2828#include "yat/utility/vector.h"
    29 #include "yat/utility/vectorView.h"
     29#include "yat/utility/VectorView.h"
    3030
    3131#include <algorithm>
     
    103103      assert(max_index<data_.size());
    104104                               
    105       utility::vectorView x_local(x, min_index, max_index-min_index+1);
    106       utility::vectorView y_local(y, min_index, max_index-min_index+1);
     105      utility::VectorView x_local(x, min_index, max_index-min_index+1);
     106      utility::VectorView y_local(y, min_index, max_index-min_index+1);
    107107
    108108      // calculating weights
  • trunk/yat/utility/Makefile.am

    r1014 r1015  
    3030  OptionHelp.cc OptionSwitch.cc \
    3131  PCA.cc stl_utility.cc SVD.cc TypeInfo.cc utility.cc vector.cc \
    32   vectorBase.cc vectorView.cc WeNNI.cc
     32  VectorBase.cc VectorView.cc WeNNI.cc
    3333
    3434include_utilitydir = $(includedir)/yat/utility
     
    4141  OptionHelp.h OptionSwitch.h \
    4242  PCA.h stl_utility.h SVD.h TypeInfo.h utility.h vector.h \
    43   vectorBase.h vectorView.h \
     43  VectorBase.h VectorView.h \
    4444  WeNNI.h yat_assert.h
    4545
  • trunk/yat/utility/PCA.cc

    r1009 r1015  
    2929#include "SVD.h"
    3030#include "utility.h"
    31 #include "vectorView.h"
     31#include "VectorView.h"
    3232
    3333#include <iostream>
     
    193193    utility::vector A_row_sum(A_.rows());
    194194    for (size_t i=0; i<A_row_sum.size(); ++i){
    195       const vectorView tmp(A_.row_vec(i));
     195      const VectorView tmp(A_.row_vec(i));
    196196      A_row_sum(i) = sum(tmp);
    197197    }
  • trunk/yat/utility/VectorBase.cc

    r1013 r1015  
    2525*/
    2626
    27 #include "vectorBase.h"
     27#include "VectorBase.h"
    2828#include "matrix.h"
    2929#include "utility.h"
     
    4343
    4444
    45   vectorBase::vectorBase(void)
     45  VectorBase::VectorBase(void)
    4646    : vec_(NULL), const_vec_(NULL)
    4747  {
     
    4949
    5050
    51   vectorBase::vectorBase(gsl_vector* v)
     51  VectorBase::VectorBase(gsl_vector* v)
    5252    : vec_(v), const_vec_(v)
    5353  {
     
    5555
    5656
    57   vectorBase::vectorBase(const gsl_vector* v)
     57  VectorBase::VectorBase(const gsl_vector* v)
    5858    : vec_(NULL), const_vec_(v)
    5959  {
     
    6161
    6262
    63   vectorBase::~vectorBase(void)
    64   {
    65   }
    66 
    67 
    68   void vectorBase::all(double value)
     63  VectorBase::~VectorBase(void)
     64  {
     65  }
     66
     67
     68  void VectorBase::all(double value)
    6969  {
    7070    assert(vec_);
     
    7373
    7474
    75   vectorBase::const_iterator vectorBase::begin(void) const
     75  VectorBase::const_iterator VectorBase::begin(void) const
    7676  {
    7777    return const_iterator(*this, 0);
     
    7979
    8080
    81   vectorBase::iterator vectorBase::begin(void)
     81  VectorBase::iterator VectorBase::begin(void)
    8282  {
    8383    return iterator(*this, 0);
     
    8585
    8686
    87   void vectorBase::div(const vectorBase& other)
     87  void VectorBase::div(const VectorBase& other)
    8888  {
    8989    assert(vec_);
    9090    int status=gsl_vector_div(vec_,other.gsl_vector_p());
    9191    if (status)
    92       throw utility::GSL_error(std::string("vectorBase::div",status));
    93   }
    94 
    95 
    96   vectorBase::const_iterator vectorBase::end(void) const
     92      throw utility::GSL_error(std::string("VectorBase::div",status));
     93  }
     94
     95
     96  VectorBase::const_iterator VectorBase::end(void) const
    9797  {
    9898    return const_iterator(*this, size());
     
    100100
    101101
    102   vectorBase::iterator vectorBase::end(void)
     102  VectorBase::iterator VectorBase::end(void)
    103103  {
    104104    return iterator(*this, size());
     
    106106
    107107
    108   bool vectorBase::equal(const vectorBase& other, const double d) const
     108  bool VectorBase::equal(const VectorBase& other, const double d) const
    109109  {
    110110    if (this==&other)
     
    122122
    123123
    124   const gsl_vector* vectorBase::gsl_vector_p(void) const
     124  const gsl_vector* VectorBase::gsl_vector_p(void) const
    125125  {
    126126    return const_vec_;
     
    128128
    129129
    130   gsl_vector* vectorBase::gsl_vector_p(void)
     130  gsl_vector* VectorBase::gsl_vector_p(void)
    131131  {
    132132    return vec_;
     
    134134
    135135
    136   void vectorBase::mul(const vectorBase& other)
     136  void VectorBase::mul(const VectorBase& other)
    137137  {
    138138    assert(vec_);
    139139    int status=gsl_vector_mul(vec_,other.gsl_vector_p());
    140140    if (status)
    141       throw utility::GSL_error(std::string("vectorBase::div",status));
    142   }
    143 
    144 
    145   size_t vectorBase::size(void) const
     141      throw utility::GSL_error(std::string("VectorBase::div",status));
     142  }
     143
     144
     145  size_t VectorBase::size(void) const
    146146  {
    147147    if (!const_vec_)
     
    151151
    152152
    153   const double& vectorBase::operator()(size_t i) const
     153  const double& VectorBase::operator()(size_t i) const
    154154  {
    155155    const double* d=gsl_vector_const_ptr(const_vec_, i);
    156156    if (!d)
    157       throw utility::GSL_error("vectorBase::operator()",GSL_EINVAL);
     157      throw utility::GSL_error("VectorBase::operator()",GSL_EINVAL);
    158158    return *d;
    159159  }
    160160
    161161
    162   double& vectorBase::operator()(size_t i)
     162  double& VectorBase::operator()(size_t i)
    163163  {
    164164    double* d=gsl_vector_ptr(vec_, i);
    165165    if (!d)
    166       throw utility::GSL_error("vectorBase::operator()",GSL_EINVAL);
     166      throw utility::GSL_error("VectorBase::operator()",GSL_EINVAL);
    167167    return *d;
    168168  }
    169169
    170170
    171   double& vectorBase::operator[](size_t i)
     171  double& VectorBase::operator[](size_t i)
    172172  {
    173173    return this->operator()(i);
     
    175175
    176176
    177   const double& vectorBase::operator[](size_t i) const
     177  const double& VectorBase::operator[](size_t i) const
    178178  {
    179179    return this->operator()(i);
     
    181181
    182182
    183   bool vectorBase::operator==(const vectorBase& other) const
     183  bool VectorBase::operator==(const VectorBase& other) const
    184184  {
    185185    return equal(other);
     
    187187
    188188
    189   bool vectorBase::operator!=(const vectorBase& other) const
     189  bool VectorBase::operator!=(const VectorBase& other) const
    190190  {
    191191    return !equal(other);
     
    193193
    194194
    195   double vectorBase::operator*( const vectorBase &other ) const
     195  double VectorBase::operator*( const VectorBase &other ) const
    196196  {
    197197    double res = 0.0;;
     
    202202
    203203
    204   const vectorBase& vectorBase::operator+=(double d)
     204  const VectorBase& VectorBase::operator+=(double d)
    205205  {
    206206    assert(vec_);
     
    210210
    211211
    212   const vectorBase& vectorBase::operator-=(const vectorBase& other)
     212  const VectorBase& VectorBase::operator-=(const VectorBase& other)
    213213  {
    214214    assert(vec_);
    215215    int status=gsl_vector_sub(vec_, other.gsl_vector_p());
    216216    if (status)
    217       throw utility::GSL_error(std::string("vectorBase::sub", status));
     217      throw utility::GSL_error(std::string("VectorBase::sub", status));
    218218    return *this;
    219219  }
    220220
    221221
    222   const vectorBase& vectorBase::operator-=(const double d)
     222  const VectorBase& VectorBase::operator-=(const double d)
    223223  {
    224224    assert(vec_);
     
    228228
    229229
    230   const vectorBase& vectorBase::operator*=(double d)
     230  const VectorBase& VectorBase::operator*=(double d)
    231231  {
    232232    assert(vec_);
     
    236236
    237237
    238   bool isnull(const vectorBase& v)
     238  bool isnull(const VectorBase& v)
    239239  {
    240240    return gsl_vector_isnull(v.gsl_vector_p());
     
    242242
    243243
    244   double max(const vectorBase& v)
     244  double max(const VectorBase& v)
    245245  {
    246246    return gsl_vector_max(v.gsl_vector_p());
     
    248248
    249249
    250   size_t max_index(const vectorBase& v)
     250  size_t max_index(const VectorBase& v)
    251251  {
    252252    return gsl_vector_max_index(v.gsl_vector_p());
     
    254254
    255255
    256   double min(const vectorBase& v)
     256  double min(const VectorBase& v)
    257257  {
    258258    return gsl_vector_min(v.gsl_vector_p());
     
    260260
    261261
    262   size_t min_index(const vectorBase& v)
     262  size_t min_index(const VectorBase& v)
    263263  {
    264264    return gsl_vector_min_index(v.gsl_vector_p());
     
    266266
    267267
    268   bool nan(const vectorBase& templat, vector& flag)
     268  bool nan(const VectorBase& templat, vector& flag)
    269269  {
    270270    size_t vsize(templat.size());
     
    280280
    281281
    282   void shuffle(vectorBase& invec)
     282  void shuffle(VectorBase& invec)
    283283  {
    284284    random::DiscreteUniform rnd;
     
    287287
    288288
    289   void sort_index(std::vector<size_t>& sort_index, const vectorBase& invec)
     289  void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec)
    290290  {
    291291    assert(invec.gsl_vector_p());
     
    294294    if (status) {
    295295      gsl_permutation_free(p);
    296       throw utility::GSL_error(std::string("sort_index(vector&,const vectorBase&)",status));     
     296      throw utility::GSL_error(std::string("sort_index(vector&,const VectorBase&)",status));     
    297297    }
    298298    sort_index=std::vector<size_t>(p->data,p->data+p->size);
     
    302302
    303303  void sort_smallest_index(std::vector<size_t>& sort_index, size_t k,
    304                             const vectorBase& invec)
     304                            const VectorBase& invec)
    305305  {
    306306    assert(invec.gsl_vector_p());
     
    311311 
    312312  void sort_largest_index(std::vector<size_t>& sort_index, size_t k,
    313                             const vectorBase& invec)
     313                            const VectorBase& invec)
    314314  {
    315315    assert(invec.gsl_vector_p());
     
    320320
    321321
    322   double sum(const vectorBase& v)
     322  double sum(const VectorBase& v)
    323323  {
    324324    double sum = 0;
     
    330330
    331331
    332   std::ostream& operator<<(std::ostream& s, const vectorBase& a)
     332  std::ostream& operator<<(std::ostream& s, const VectorBase& a)
    333333  {
    334334    s.setf(std::ios::dec);
  • trunk/yat/utility/VectorBase.h

    r1013 r1015  
    8686  */
    8787
    88   class vectorBase
     88  class VectorBase
    8989  {
    9090  public:
    9191
    92     /// \brief vectorBase::iterator
    93     typedef Iterator<double&, vectorBase> iterator;
    94 
    95     /// \brief vectorBase::const_iterator
    96     typedef Iterator<const double, const vectorBase> const_iterator;
     92    /// \brief VectorBase::iterator
     93    typedef Iterator<double&, VectorBase> iterator;
     94
     95    /// \brief VectorBase::const_iterator
     96    typedef Iterator<const double, const VectorBase> const_iterator;
    9797
    9898    /**
    9999       \brief default constructor
    100100    */
    101     vectorBase(void);
     101    VectorBase(void);
    102102
    103103    /**
    104104       \brief Constructor.
    105105    */
    106     vectorBase(gsl_vector*);
     106    VectorBase(gsl_vector*);
    107107
    108108    /**
    109109       \brief Constructor.
    110110    */
    111     vectorBase(const gsl_vector*);
     111    VectorBase(const gsl_vector*);
    112112
    113113    ///
    114114    /// The destructor.
    115115    ///
    116     virtual ~vectorBase(void);
     116    virtual ~VectorBase(void);
    117117
    118118    ///
     
    122122
    123123    /**
    124        \return mutable iterator to start of vectorBase
     124       \return mutable iterator to start of VectorBase
    125125     */
    126126    iterator begin(void);
    127127
    128128    /**
    129        \return read-only iterator to start of vectorBase
     129       \return read-only iterator to start of VectorBase
    130130     */
    131131    const_iterator begin(void) const;
     
    137137       \throw GSL_error if dimensions mis-match.
    138138    */
    139     void div(const vectorBase& other);
    140 
    141     /**
    142        \return mutable iterator to end of vectorBase
     139    void div(const VectorBase& other);
     140
     141    /**
     142       \return mutable iterator to end of VectorBase
    143143     */
    144144    iterator end(void);
    145145
    146146    /**
    147        \return read-only iterator to end of vectorBase
     147       \return read-only iterator to end of VectorBase
    148148     */
    149149    const_iterator end(void) const;
    150150
    151151    /**
    152        \brief Check whether vectorBases are equal within a user defined
     152       \brief Check whether VectorBases are equal within a user defined
    153153       precision, set by \a precision.
    154154
    155155       \return True if each element deviates less or equal than \a
    156        d. If any vectorBase contain a NaN, false is always returned.
     156       d. If any VectorBase contain a NaN, false is always returned.
    157157
    158158       \see operator== and operator!=
    159159    */
    160     bool equal(const vectorBase&, const double precision=0) const;
     160    bool equal(const VectorBase&, const double precision=0) const;
    161161
    162162    ///
     
    186186       \throw GSL_error if dimensions mis-match.
    187187    */
    188     void mul(const vectorBase& other);
    189 
    190     /**
    191        \brief Reverse the order of elements in the vectorBase.
     188    void mul(const VectorBase& other);
     189
     190    /**
     191       \brief Reverse the order of elements in the VectorBase.
    192192    */
    193193    void reverse(void);
    194194
    195195    ///
    196     /// @return the number of elements in the vectorBase.
     196    /// @return the number of elements in the VectorBase.
    197197    ///
    198198    size_t size(void) const;
     
    201201       \brief Exchange elements \a i and \a j.
    202202
    203        \throw GSL_error if vectorBase lengths differs.
     203       \throw GSL_error if VectorBase lengths differs.
    204204    */
    205205    void swap(size_t i, size_t j);
     
    240240       \return True if all elements are equal otherwise false.
    241241
    242        \see equal(const vectorBase&, const double precision=0)
    243     */
    244     bool operator==(const vectorBase&) const;
     242       \see equal(const VectorBase&, const double precision=0)
     243    */
     244    bool operator==(const VectorBase&) const;
    245245
    246246    /**
     
    253253       \return False if all elements are equal otherwise true.
    254254
    255        \see equal(const vectorBase&, const double precision=0)
    256     */
    257     bool operator!=(const vectorBase&) const;
     255       \see equal(const VectorBase&, const double precision=0)
     256    */
     257    bool operator!=(const VectorBase&) const;
    258258
    259259    ///
    260260    /// @return The dot product.
    261261    ///
    262     double operator*(const vectorBase&) const;
     262    double operator*(const VectorBase&) const;
    263263
    264264    /**
    265265       \brief The assignment operator.
    266266
    267        Dimensions of the vectorBases must match. If the LHS vectorBase is a
     267       Dimensions of the VectorBases must match. If the LHS VectorBase is a
    268268       view, the underlying data will be changed.
    269269
    270        \return A const reference to the resulting vectorBase.
    271 
    272        \see void set(const vectorBase&).
     270       \return A const reference to the resulting VectorBase.
     271
     272       \see void set(const VectorBase&).
    273273
    274274       \throw GSL_error if dimensions mis-match.
    275275    */
    276     //const vectorBase& operator=(vectorBase&);
     276    //const VectorBase& operator=(VectorBase&);
    277277
    278278    /**
     
    280280       this_i = this_i + other_i \; \forall i \f$.
    281281
    282        \return A const reference to the resulting vectorBase.
     282       \return A const reference to the resulting VectorBase.
    283283
    284284       \throw GSL_error if dimensions mis-match.
    285285    */
    286     const vectorBase& operator+=(const vectorBase&);
    287 
    288     /**
    289        \brief Add a constant to a vectorBase, \f$ this_i = this_i + d \;
     286    const VectorBase& operator+=(const VectorBase&);
     287
     288    /**
     289       \brief Add a constant to a VectorBase, \f$ this_i = this_i + d \;
    290290       \forall i \f$.
    291291
    292        \return A const reference to the resulting vectorBase.
    293     */
    294     const vectorBase& operator+=(double d);
     292       \return A const reference to the resulting VectorBase.
     293    */
     294    const VectorBase& operator+=(double d);
    295295
    296296    /**
     
    298298       this_i = this_i - other_i \; \forall i \f$.
    299299
    300        \return A const reference to the resulting vectorBase.
     300       \return A const reference to the resulting VectorBase.
    301301
    302302       \throw GSL_error if dimensions mis-match.
    303303    */
    304     const vectorBase& operator-=(const vectorBase&);
    305 
    306     /**
    307        \brief Subtract a constant to a vectorBase, \f$ this_i = this_i - d
     304    const VectorBase& operator-=(const VectorBase&);
     305
     306    /**
     307       \brief Subtract a constant to a VectorBase, \f$ this_i = this_i - d
    308308       \; \forall i \f$.
    309309
    310        \return A const reference to the resulting vectorBase.
    311     */
    312     const vectorBase& operator-=(double d);
     310       \return A const reference to the resulting VectorBase.
     311    */
     312    const VectorBase& operator-=(double d);
    313313
    314314    /**
     
    316316       this_i * d \; \forall i \f$.
    317317
    318        \return A const reference to the resulting vectorBase.
    319     */
    320     const vectorBase& operator*=(double d);
     318       \return A const reference to the resulting VectorBase.
     319    */
     320    const VectorBase& operator*=(double d);
    321321
    322322
     
    335335  private:
    336336    // copy assignment no allowed
    337     const vectorBase& operator=(const vectorBase&);
     337    const VectorBase& operator=(const VectorBase&);
    338338  public:
    339339    /**
     
    344344
    345345  /**
    346      \brief Check if all elements of the vectorBase are zero.
    347 
    348      \return True if all elements in the vectorBase is zero, false
     346     \brief Check if all elements of the VectorBase are zero.
     347
     348     \return True if all elements in the VectorBase is zero, false
    349349     othwerwise.
    350350  */
    351   bool isnull(const vectorBase&);
    352 
    353   /**
    354      \brief Get the maximum value of the vectorBase.
    355 
    356      \return The maximum value of the vectorBase.
    357   */
    358   double max(const vectorBase&);
    359 
    360   /**
    361      \brief Locate the maximum value in the vectorBase.
    362 
    363      \return The index to the maximum value of the vectorBase.
     351  bool isnull(const VectorBase&);
     352
     353  /**
     354     \brief Get the maximum value of the VectorBase.
     355
     356     \return The maximum value of the VectorBase.
     357  */
     358  double max(const VectorBase&);
     359
     360  /**
     361     \brief Locate the maximum value in the VectorBase.
     362
     363     \return The index to the maximum value of the VectorBase.
    364364
    365365     \note Lower index has precedence.
    366366  */
    367   size_t max_index(const vectorBase&);
    368 
    369   /**
    370      \brief Get the minimum value of the vectorBase.
    371 
    372      \return The minimum value of the vectorBase.
    373   */
    374   double min(const vectorBase&);
    375 
    376   /**
    377      \brief Locate the minimum value in the vectorBase.
    378 
    379      \return The index to the minimum value of the vectorBase.
     367  size_t max_index(const VectorBase&);
     368
     369  /**
     370     \brief Get the minimum value of the VectorBase.
     371
     372     \return The minimum value of the VectorBase.
     373  */
     374  double min(const VectorBase&);
     375
     376  /**
     377     \brief Locate the minimum value in the VectorBase.
     378
     379     \return The index to the minimum value of the VectorBase.
    380380
    381381     \note Lower index has precedence.
    382382  */
    383   size_t min_index(const vectorBase&);
    384 
    385   /**
    386      \brief Create a vectorBase \a flag indicating NaN's in another vectorBase
     383  size_t min_index(const VectorBase&);
     384
     385  /**
     386     \brief Create a VectorBase \a flag indicating NaN's in another VectorBase
    387387     \a templat.
    388388
    389      The \a flag vectorBase is changed to contain 1's and 0's only. A 1
    390      means that the corresponding element in the \a templat vectorBase is
     389     The \a flag VectorBase is changed to contain 1's and 0's only. A 1
     390     means that the corresponding element in the \a templat VectorBase is
    391391     valid and a zero means that the corresponding element is a NaN.
    392392
    393      \note Space for vectorBase \a flag is reallocated to fit the size of
    394      vectorBase \a templat if sizes mismatch.
    395 
    396      \return True if the \a templat vectorBase contains at least one NaN.
    397   */
    398   bool nan(const vectorBase& templat, vector& flag);
    399 
    400   /**
    401      Randomly shuffles the elements in vectorBase \a invec
    402   */
    403   void shuffle(vectorBase& invec);
    404 
    405   /**
    406      Sort the elements in the vectorBase.
    407   */
    408   void sort(vectorBase&);
     393     \note Space for VectorBase \a flag is reallocated to fit the size of
     394     VectorBase \a templat if sizes mismatch.
     395
     396     \return True if the \a templat VectorBase contains at least one NaN.
     397  */
     398  bool nan(const VectorBase& templat, vector& flag);
     399
     400  /**
     401     Randomly shuffles the elements in VectorBase \a invec
     402  */
     403  void shuffle(VectorBase& invec);
     404
     405  /**
     406     Sort the elements in the VectorBase.
     407  */
     408  void sort(VectorBase&);
    409409
    410410  /**
    411411     Create a vector \a sort_index containing the indeces of
    412      elements in a another vectorBase \a invec.  The elements of \a
    413      sort_index give the index of the vectorBase element which would
    414      have been stored in that position if the vectorBase had been sorted
     412     elements in a another VectorBase \a invec.  The elements of \a
     413     sort_index give the index of the VectorBase element which would
     414     have been stored in that position if the VectorBase had been sorted
    415415     in place. The first element of \a sort_index gives the index of the least
    416416     element in \a invec, and the last element of \a sort_index gives the
    417      index of the greatest element in \a invec . The vectorBase \a invec
     417     index of the greatest element in \a invec . The VectorBase \a invec
    418418     is not changed.
    419419  */
    420   void sort_index(std::vector<size_t>& sort_index, const vectorBase& invec);
     420  void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec);
    421421
    422422  /**
    423       Similar to sort_index but creates a vectorBase with indices to the \a k
     423      Similar to sort_index but creates a VectorBase with indices to the \a k
    424424  smallest elements in \a invec. 
    425425  */
    426426  void sort_smallest_index(std::vector<size_t>& sort_index, size_t k,
    427                            const vectorBase& invec);
     427                           const VectorBase& invec);
    428428
    429429  /**
    430       Similar to sort_index but creates a vectorBase with indices to the \a k
     430      Similar to sort_index but creates a VectorBase with indices to the \a k
    431431  largest elements in \a invec. 
    432432  */
    433433  void sort_largest_index(std::vector<size_t>& sort_index, size_t k,
    434                           const vectorBase& invec);
    435 
    436   /**
    437      \brief Calculate the sum of all vectorBase elements.
     434                          const VectorBase& invec);
     435
     436  /**
     437     \brief Calculate the sum of all VectorBase elements.
    438438
    439439     \return The sum.
    440440  */
    441   double sum(const vectorBase&);
     441  double sum(const VectorBase&);
    442442
    443443  /**
     
    451451
    452452  /**
    453      \brief The output operator for the vectorBase class.
    454   */
    455   std::ostream& operator<<(std::ostream&, const vectorBase&);
     453     \brief The output operator for the VectorBase class.
     454  */
     455  std::ostream& operator<<(std::ostream&, const VectorBase&);
    456456
    457457}}} // of namespace utility, yat, and theplu
  • trunk/yat/utility/VectorView.cc

    r1013 r1015  
    2525*/
    2626
    27 #include "vectorView.h"
     27#include "VectorView.h"
    2828#include "matrix.h"
    2929#include "utility.h"
     
    4343
    4444
    45   vectorView::vectorView(void)
    46     : vectorBase(), view_(NULL), const_view_(NULL)
    47   {
    48   }
    49 
    50 
    51   vectorView::vectorView(vectorView& other)
    52     : vectorBase(), const_view_(NULL)
     45  VectorView::VectorView(void)
     46    : VectorBase(), view_(NULL), const_view_(NULL)
     47  {
     48  }
     49
     50
     51  VectorView::VectorView(VectorView& other)
     52    : VectorBase(), const_view_(NULL)
    5353  {
    5454    view_ = new gsl_vector_view(gsl_vector_subvector(other.gsl_vector_p(),
     
    5959
    6060
    61   vectorView::vectorView(const vectorView& other)
    62     : vectorBase(), view_(NULL)
     61  VectorView::VectorView(const VectorView& other)
     62    : VectorBase(), view_(NULL)
    6363  {
    6464    const_view_ = new gsl_vector_const_view(
     
    6868
    6969
    70   vectorView::vectorView(vectorBase& other)
    71     : vectorBase(other.gsl_vector_p()), const_view_(NULL)
     70  VectorView::VectorView(VectorBase& other)
     71    : VectorBase(other.gsl_vector_p()), const_view_(NULL)
    7272  {
    7373    view_ =
     
    7979
    8080  /*
    81   vectorView::vectorView(const vectorBase& other)
    82     : vectorBase(other.const_vec_), view_(NULL)
     81  VectorView::VectorView(const VectorBase& other)
     82    : VectorBase(other.const_vec_), view_(NULL)
    8383  {
    8484  }
    8585  */
    8686
    87   vectorView::vectorView(vectorBase& v, size_t offset,size_t n,size_t stride)
    88     : vectorBase(), const_view_(NULL)
     87  VectorView::VectorView(VectorBase& v, size_t offset,size_t n,size_t stride)
     88    : VectorBase(), const_view_(NULL)
    8989  {
    9090    view_ =
     
    9595
    9696
    97   vectorView::vectorView(const vectorBase& v, size_t offset,size_t n,
     97  VectorView::VectorView(const VectorBase& v, size_t offset,size_t n,
    9898                         size_t stride)
    99     : vectorBase(), view_(NULL)
     99    : VectorBase(), view_(NULL)
    100100  {
    101101    const_view_ = new gsl_vector_const_view(
     
    106106
    107107
    108   vectorView::vectorView(matrix& m, size_t i, bool row)
    109     : vectorBase(), const_view_(NULL)
     108  VectorView::VectorView(matrix& m, size_t i, bool row)
     109    : VectorBase(), const_view_(NULL)
    110110  {
    111111    view_=new gsl_vector_view(row ?
     
    116116
    117117
    118   vectorView::vectorView(const matrix& m, size_t i, bool row)
    119     : vectorBase(), view_(NULL)
     118  VectorView::VectorView(const matrix& m, size_t i, bool row)
     119    : VectorBase(), view_(NULL)
    120120  {
    121121    const_view_ =
     
    128128
    129129  /*
    130   vectorView::vectorView(proxy p)
    131     : vectorBase()
     130  VectorView::VectorView(proxy p)
     131    : VectorBase()
    132132  {
    133133    view_ = new gsl_vector_view(gsl_vector_subvector(p.vec_, 0, p.vec_->size));
     
    136136  */
    137137
    138   vectorView::~vectorView(void)
     138  VectorView::~VectorView(void)
    139139  {
    140140    delete_allocated_memory();
     
    142142
    143143
    144   const vectorBase& vectorView::assign(const vectorBase& other )
     144  const VectorBase& VectorView::assign(const VectorBase& other )
    145145  {
    146146    if (size()!=other.size())
    147       throw utility::GSL_error("vectorView::dimension mis-match");
     147      throw utility::GSL_error("VectorView::dimension mis-match");
    148148    if (!other.size())
    149149      return *this;
     
    154154
    155155
    156   bool vectorView::isview(void) const
     156  bool VectorView::isview(void) const
    157157  {
    158158    return true;
     
    161161
    162162
    163   const vectorBase& vectorView::operator=(const vectorView& other )
     163  const VectorBase& VectorView::operator=(const VectorView& other )
    164164  {
    165165    return assign(other);
     
    167167
    168168 
    169   const vectorBase& vectorView::operator=(const vectorBase& other )
     169  const VectorBase& VectorView::operator=(const VectorBase& other )
    170170  {
    171171    return assign(other);
     
    174174 
    175175  /*
    176   const vectorBase& vectorView::operator=(proxy p)
     176  const VectorBase& VectorView::operator=(proxy p)
    177177  {
    178178    if (size()!=p.vec_->size)
    179       throw utility::GSL_error("vectorView::dimension mis-match");
     179      throw utility::GSL_error("VectorView::dimension mis-match");
    180180    if (!size())
    181181      return *this;
     
    187187  */
    188188
    189   void vectorView::delete_allocated_memory(void)
     189  void VectorView::delete_allocated_memory(void)
    190190  {
    191191    if (view_){
  • trunk/yat/utility/VectorView.h

    r1013 r1015  
    2929*/
    3030
    31 #include "vectorBase.h"
     31#include "VectorBase.h"
    3232#include "Exception.h"
    3333
     
    8585  */
    8686
    87   class vectorView : public vectorBase
     87  class VectorView : public VectorBase
    8888  {
    8989  public:
     
    9191       \brief Default constructor.
    9292    */
    93     vectorView(void);
     93    VectorView(void);
    9494
    9595    /**
    9696       \brief The copy constructor.
    97     */
    98     vectorView(vectorBase& other);
    99     vectorView(vectorView& other);
     97    */ 
     98    VectorView(VectorBase& other);
     99    VectorView(VectorView& other);
    100100    // Peter, privatize
    101     vectorView(const vectorView& other);
     101    VectorView(const VectorView& other);
    102102
    103103    /**
    104104       \brief VectorView constructor.
    105105
    106        Create a view of vectorView \a v, with starting index \a offset,
     106       Create a view of VectorView \a v, with starting index \a offset,
    107107       size \a n, and an optional \a stride.
    108108
    109        A vectorView view can be used as any vectorView with the difference
     109       A VectorView view can be used as any VectorView with the difference
    110110       that changes made to the view will also change the object that
    111111       is viewed. Also, using the copy constructor will create a new
    112        vectorView object that is a copy of whatever is viewed. If a copy
     112       VectorView object that is a copy of whatever is viewed. If a copy
    113113       of the view is needed then you should use this constructor to
    114114       obtain a copy.
     
    120120       \throw GSL_error if a view cannot be set up.
    121121    */
    122     vectorView(vectorBase& v, size_t offset, size_t n, size_t stride=1);
     122    VectorView(VectorBase& v, size_t offset, size_t n, size_t stride=1);
    123123    // Peter, privatize
    124     vectorView(const vectorBase& v, size_t offset, size_t n, size_t stride=1);
     124    VectorView(const VectorBase& v, size_t offset, size_t n, size_t stride=1);
    125125
    126126    ///
    127127    /// Matrix row/column view constructor.
    128128    ///
    129     /// Create a row/column vectorView view of matrix \a m, pointing at
     129    /// Create a row/column VectorView view of matrix \a m, pointing at
    130130    /// row/column \a i. The parameter \a row is used to set whether
    131131    /// the view should be a row or column view. If \a row is set to
     
    133133    /// naturally, a column view otherwise.
    134134    ///
    135     /// A vectorView view can be used as any vectorView with the difference
     135    /// A VectorView view can be used as any VectorView with the difference
    136136    /// that changes made to the view will also change the object that
    137137    /// is viewed. Also, using the copy constructor will create a new
    138     /// vectorView object that is a copy of whatever is viewed. If a copy
    139     /// of the view is needed then you should use the vectorView view
     138    /// VectorView object that is a copy of whatever is viewed. If a copy
     139    /// of the view is needed then you should use the VectorView view
    140140    /// constructor to obtain a copy.
    141141    ///
     
    144144    /// use is undefined.
    145145    ///
    146     vectorView(matrix& m, size_t i, bool row=true);
     146    VectorView(matrix& m, size_t i, bool row=true);
    147147
    148148    // Peter should be private
    149     vectorView(const matrix& m, size_t i, bool row=true);
     149    VectorView(const matrix& m, size_t i, bool row=true);
    150150
    151151    /**
    152152     */
    153     //vectorView(proxy p);
     153    //VectorView(proxy p);
    154154
    155155    ///
    156156    /// The destructor.
    157157    ///
    158     ~vectorView(void);
     158    ~VectorView(void);
    159159
    160160    /**
     
    170170       \throw GSL_error if dimensions mis-match.
    171171    */
    172     const vectorBase& operator=(const vectorBase&);
    173     const vectorBase& operator=(const vectorView&);
     172    const VectorBase& operator=(const VectorBase&);
     173    const VectorBase& operator=(const VectorView&);
    174174
    175     //const vectorBase& operator=(proxy);
     175    //const VectorBase& operator=(proxy);
    176176
    177177  private:
    178     const vectorBase& assign(const vectorBase& other);
     178    const VectorBase& assign(const VectorBase& other);
    179179    void delete_allocated_memory(void);
    180180
  • trunk/yat/utility/matrix.cc

    r1009 r1015  
    2727#include "matrix.h"
    2828#include "vector.h"
    29 #include "vectorView.h"
     29#include "VectorView.h"
    3030#include "utility.h"
    3131
     
    303303
    304304
    305   vectorView matrix::column_vec(size_t col)
    306   {
    307     vectorView res(*this, col, false);
     305  VectorView matrix::column_vec(size_t col)
     306  {
     307    VectorView res(*this, col, false);
    308308    return res;
    309309  }
    310310
    311311
    312   const vectorView matrix::column_vec(size_t col) const
    313   {
    314     return vectorView(*this, col, false);
    315   }
    316 
    317 
    318   const vectorView matrix::row_vec(size_t col) const
    319   {
    320     return vectorView(*this, col, true);
    321   }
    322 
    323 
    324   vectorView matrix::row_vec(size_t row)
    325   {
    326     vectorView res(*this, row, true);
     312  const VectorView matrix::column_vec(size_t col) const
     313  {
     314    return VectorView(*this, col, false);
     315  }
     316
     317
     318  const VectorView matrix::row_vec(size_t col) const
     319  {
     320    return VectorView(*this, col, true);
     321  }
     322
     323
     324  VectorView matrix::row_vec(size_t row)
     325  {
     326    VectorView res(*this, row, true);
    327327    return res;
    328328  }
     
    558558
    559559
    560   vector operator*(const matrix& m, const vectorBase& v)
     560  vector operator*(const matrix& m, const VectorBase& v)
    561561  {
    562562    utility::vector res(m.rows());
    563563    for (size_t i=0; i<res.size(); ++i)
    564       res(i) = vectorView(m,i) * v;
     564      res(i) = VectorView(m,i) * v;
    565565    return res;
    566566  }
     
    571571    utility::vector res(m.columns());
    572572    for (size_t i=0; i<res.size(); ++i)
    573       res(i) = v * vectorView(m,i,false);
     573      res(i) = v * VectorView(m,i,false);
    574574    return res;
    575575  }
  • trunk/yat/utility/matrix.h

    r1014 r1015  
    2828*/
    2929
    30 #include "vectorBase.h"
    3130#include "vector.h"
    32 #include "vectorView.h"
     31#include "VectorBase.h"
     32#include "VectorView.h"
    3333#include "Exception.h"
    3434
     
    158158    /**
    159159     */
    160     vectorView column_vec(size_t);
     160    VectorView column_vec(size_t);
    161161
    162162    /**
    163163     */
    164     const vectorView column_vec(size_t) const;
     164    const VectorView column_vec(size_t) const;
    165165
    166166    ///
     
    233233    /**
    234234     */
    235     vectorView row_vec(size_t);
     235    VectorView row_vec(size_t);
    236236
    237237    /**
    238238     */
    239     const vectorView row_vec(size_t) const;
     239    const VectorView row_vec(size_t) const;
    240240
    241241    /**
     
    500500     \brief vector matrix multiplication
    501501   */
    502   vector operator*(const matrix&, const vectorBase&);
     502  vector operator*(const matrix&, const VectorBase&);
    503503
    504504  /**
  • trunk/yat/utility/vector.cc

    r1010 r1015  
    4444
    4545  vector::vector(void)
    46     : vectorBase()
     46    : VectorBase()
    4747  {
    4848  }
     
    5050
    5151  vector::vector(size_t n, double init_value)
    52     : vectorBase(gsl_vector_alloc(n))
     52    : VectorBase(gsl_vector_alloc(n))
    5353  {
    5454    if (!vec_)
     
    6060
    6161  vector::vector(const vector& other)
    62     : vectorBase(create_gsl_vector_copy(other))
    63   {
    64   }
    65 
    66 
    67   vector::vector(const vectorBase& other)
    68     : vectorBase(create_gsl_vector_copy(other))
     62    : VectorBase(create_gsl_vector_copy(other))
     63  {
     64  }
     65
     66
     67  vector::vector(const VectorBase& other)
     68    : VectorBase(create_gsl_vector_copy(other))
    6969  {
    7070  }
     
    7373  vector::vector(std::istream& is, char sep)
    7474    throw (utility::IO_error, std::exception)
    75     : vectorBase()
     75    : VectorBase()
    7676  {
    7777    // read the data file and store in stl vectors (dynamically
     
    155155
    156156
    157   gsl_vector* vector::create_gsl_vector_copy(const vectorBase& other) const
     157  gsl_vector* vector::create_gsl_vector_copy(const VectorBase& other) const
    158158  {
    159159    gsl_vector* vec = gsl_vector_alloc(other.size());
     
    193193  /*
    194194  //Peter use swap idiom
    195   const vectorBase& vector::operator=( const vectorBase& other )
     195  const VectorBase& vector::operator=( const VectorBase& other )
    196196  {
    197197    if (!other.size())
     
    206206  */
    207207
    208   const vectorBase& vector::operator=( const vector& other )
     208  const VectorBase& vector::operator=( const vector& other )
    209209  {
    210210    return assign(other);
     
    212212
    213213  /* 
    214   const vectorBase& vector::assign(vectorBase& other)
     214  const VectorBase& vector::assign(VectorBase& other)
    215215  {
    216216    assign(other);
     
    218218  */
    219219
    220   const vectorBase& vector::assign(const vectorBase& other)
     220  const VectorBase& vector::assign(const VectorBase& other)
    221221  {
    222222    if (!other.size())
  • trunk/yat/utility/vector.h

    r1009 r1015  
    2929*/
    3030
    31 #include "vectorBase.h"
     31#include "VectorBase.h"
    3232#include "Exception.h"
    3333#include "Iterator.h"
     
    8585  */
    8686
    87   class vector : public vectorBase
     87  class vector : public VectorBase
    8888  {
    8989  public:
     
    122122       fails.
    123123    */
    124     vector(const vectorBase& other);
     124    vector(const VectorBase& other);
    125125
    126126    /**
     
    159159    void resize(size_t n, double init_value);
    160160
    161     //    using vectorBase::operator=;
     161    //    using VectorBase::operator=;
    162162
    163163    /**
     
    166166       \return A const reference to the resulting vector.
    167167    */
    168     //const vectorBase& operator=(const vectorBase&);
    169     const vectorBase& operator=(const vector&);
     168    //const VectorBase& operator=(const VectorBase&);
     169    const VectorBase& operator=(const vector&);
    170170
    171171  private:
    172     const vectorBase& assign(const vectorBase& other);
    173     //const vectorBase& assign(vectorBase& other);
     172    const VectorBase& assign(const VectorBase& other);
     173    //const VectorBase& assign(VectorBase& other);
    174174
    175175    /**
     
    184184       copy, or if dimensions mis-match.
    185185    */
    186     gsl_vector* create_gsl_vector_copy(const vectorBase&) const;
     186    gsl_vector* create_gsl_vector_copy(const VectorBase&) const;
    187187
    188188    void delete_allocated_memory(void);
Note: See TracChangeset for help on using the changeset viewer.