Ignore:
Timestamp:
Feb 2, 2008, 10:29:29 PM (14 years ago)
Author:
Peter
Message:

going back to previous design in which view and const_view are in different classes. Having them in same didnt work as expected. There is a problem converting vector::iterator to vector::const_iterator. I'll open a separate ticket for this issue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/utility/VectorBase.h

    r1015 r1027  
    8989  {
    9090  public:
    91 
    92     /// \brief VectorBase::iterator
    93     typedef Iterator<double&, VectorBase> iterator;
    94 
    9591    /// \brief VectorBase::const_iterator
    96     typedef Iterator<const double, const VectorBase> const_iterator;
    97 
    98     /**
    99        \brief default constructor
    100     */
    101     VectorBase(void);
     92    typedef Iterator<const double&, const VectorBase> const_iterator;
    10293
    10394    /**
    10495       \brief Constructor.
    10596    */
    106     VectorBase(gsl_vector*);
    107 
    108     /**
    109        \brief Constructor.
    110     */
    111     VectorBase(const gsl_vector*);
     97    VectorBase(const gsl_vector* v=NULL);
    11298
    11399    ///
     
    115101    ///
    116102    virtual ~VectorBase(void);
    117 
    118     ///
    119     /// Set all elements to \a value.
    120     ///
    121     void all(double value);
    122 
    123     /**
    124        \return mutable iterator to start of VectorBase
    125      */
    126     iterator begin(void);
    127103
    128104    /**
     
    132108
    133109    /**
    134        \brief This function performs element-wise division, \f$ this_i =
    135        this_i/other_i \; \forall i \f$.
    136 
    137        \throw GSL_error if dimensions mis-match.
    138     */
    139     void div(const VectorBase& other);
    140 
    141     /**
    142        \return mutable iterator to end of VectorBase
    143      */
    144     iterator end(void);
    145 
    146     /**
    147110       \return read-only iterator to end of VectorBase
    148111     */
     
    161124
    162125    ///
    163     /// @return A pointer to the internal GSL vector,
    164     ///
    165     gsl_vector* gsl_vector_p(void);
    166 
    167     ///
    168126    /// @return A const pointer to the internal GSL vector,
    169127    ///
     
    171129
    172130    /**
    173    
    174131       Check if the vector object is a view (sub-vector) to another
    175132       vector.
    176133   
    177134       \return True if the object is a view, false othwerwise.
    178    
    179135     */
    180136    virtual bool isview(void) const=0;
    181137
    182     /**
    183        \brief This function performs element-wise multiplication, \f$
    184        this_i = this_i * other_i \; \forall i \f$.
    185 
    186        \throw GSL_error if dimensions mis-match.
    187     */
    188     void mul(const VectorBase& other);
    189 
    190     /**
    191        \brief Reverse the order of elements in the VectorBase.
    192     */
    193     void reverse(void);
    194 
    195138    ///
    196139    /// @return the number of elements in the VectorBase.
     
    199142
    200143    /**
    201        \brief Exchange elements \a i and \a j.
    202 
    203        \throw GSL_error if VectorBase lengths differs.
    204     */
    205     void swap(size_t i, size_t j);
    206 
    207     /**
    208144       \brief Element access operator.
    209145
    210        \return Reference to element \a i.
     146       \return Const reference to element \a i.
    211147
    212148       \throw If GSL range checks are enabled in the underlying GSL
     
    214150       of range.
    215151    */
    216     double& operator()(size_t i);
    217     // Peter, remove this one
    218     double& operator[](size_t i);
    219 
    220     /**
    221        \brief Element access operator.
    222 
    223        \return Const reference to element \a i.
    224 
    225        \throw If GSL range checks are enabled in the underlying GSL
    226        library a GSL_error exception is thrown if either index is out
    227        of range.
    228     */
    229152    const double& operator()(size_t i) const;
    230153    // Peter, remove this one
     
    262185    double operator*(const VectorBase&) const;
    263186
    264     /**
    265        \brief The assignment operator.
    266 
    267        Dimensions of the VectorBases must match. If the LHS VectorBase is a
    268        view, the underlying data will be changed.
    269 
    270        \return A const reference to the resulting VectorBase.
    271 
    272        \see void set(const VectorBase&).
    273 
    274        \throw GSL_error if dimensions mis-match.
    275     */
    276     //const VectorBase& operator=(VectorBase&);
    277 
    278     /**
    279        \brief Addition and assign operator. VectorBase addition, \f$
    280        this_i = this_i + other_i \; \forall i \f$.
    281 
    282        \return A const reference to the resulting VectorBase.
    283 
    284        \throw GSL_error if dimensions mis-match.
    285     */
    286     const VectorBase& operator+=(const VectorBase&);
    287 
    288     /**
    289        \brief Add a constant to a VectorBase, \f$ this_i = this_i + d \;
    290        \forall i \f$.
    291 
    292        \return A const reference to the resulting VectorBase.
    293     */
    294     const VectorBase& operator+=(double d);
    295 
    296     /**
    297        \brief Subtract and assign operator. VectorBase subtraction, \f$
    298        this_i = this_i - other_i \; \forall i \f$.
    299 
    300        \return A const reference to the resulting VectorBase.
    301 
    302        \throw GSL_error if dimensions mis-match.
    303     */
    304     const VectorBase& operator-=(const VectorBase&);
    305 
    306     /**
    307        \brief Subtract a constant to a VectorBase, \f$ this_i = this_i - d
    308        \; \forall i \f$.
    309 
    310        \return A const reference to the resulting VectorBase.
    311     */
    312     const VectorBase& operator-=(double d);
    313 
    314     /**
    315        \brief Multiply with scalar and assign operator, \f$ this_i =
    316        this_i * d \; \forall i \f$.
    317 
    318        \return A const reference to the resulting VectorBase.
    319     */
    320     const VectorBase& operator*=(double d);
    321 
    322 
    323 
    324187  protected:
    325     gsl_vector* vec_;
    326188    const gsl_vector* const_vec_;
    327 
    328     /*
    329     struct proxy
    330     {
    331       gsl_vector* vec_;
    332     };
    333     */
    334189
    335190  private:
    336191    // copy assignment no allowed
    337192    const VectorBase& operator=(const VectorBase&);
    338   public:
    339     /**
    340      */
    341     //operator proxy();
    342 
    343193  };
    344194
     
    397247  */
    398248  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&);
    409249
    410250  /**
     
    442282
    443283  /**
    444      \brief Swap vector elements by copying.
    445 
    446      The two vectorMutables must have the same length.
    447 
    448      \throw GSL_error if vectorMutable lengths differs.
    449   */
    450   //void swap(vectorMutable&, vectorMutable&);
    451 
    452   /**
    453284     \brief The output operator for the VectorBase class.
    454285  */
Note: See TracChangeset for help on using the changeset viewer.