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/VectorView.cc

    r1026 r1027  
    2626
    2727#include "VectorView.h"
     28#include "VectorMutable.h"
    2829#include "matrix.h"
    2930#include "utility.h"
     
    4445
    4546  VectorView::VectorView(void)
    46     : VectorBase(), view_(NULL), const_view_(NULL)
     47    : VectorMutable(), view_(NULL)
    4748  {
    4849  }
     
    5051
    5152  VectorView::VectorView(VectorView& other)
    52     : VectorBase(), const_view_(NULL)
     53    : VectorMutable()
    5354  {
    5455    view_ = new gsl_vector_view(gsl_vector_subvector(other.gsl_vector_p(),
     
    5960
    6061
    61   VectorView::VectorView(const VectorView& other)
    62     : VectorBase(), view_(NULL)
     62  VectorView::VectorView(VectorMutable& other)
     63    : VectorMutable()
    6364  {
    64     const_view_ = new gsl_vector_const_view(
    65         gsl_vector_const_subvector(other.gsl_vector_p(), 0, other.size()));
    66     const_vec_ = &(const_view_->vector);
    67   }
    68 
    69 
    70   VectorView::VectorView(VectorBase& other)
    71     : VectorBase(other.gsl_vector_p()), const_view_(NULL)
    72   {
    73     view_ =
    74       new gsl_vector_view(gsl_vector_subvector_with_stride(other.gsl_vector_p(),
    75                                                            0, 1,other.size()));
     65    view_ = new gsl_vector_view(gsl_vector_subvector(other.gsl_vector_p(),
     66                                                     0,other.size()));
    7667    const_vec_ = vec_ = &(view_->vector);
    7768  }
    7869
    7970
    80   /*
    81   VectorView::VectorView(const VectorBase& other)
    82     : VectorBase(other.const_vec_), view_(NULL)
    83   {
    84   }
    85   */
    86 
    87   VectorView::VectorView(VectorBase& v, size_t offset,size_t n,size_t stride)
    88     : VectorBase(), const_view_(NULL)
     71  VectorView::VectorView(VectorMutable& v,size_t offset,size_t n,size_t stride)
     72    : VectorMutable()
    8973  {
    9074    view_ =
     
    9579
    9680
    97   VectorView::VectorView(const VectorBase& v, size_t offset,size_t n,
    98                          size_t stride)
    99     : VectorBase(), view_(NULL)
    100   {
    101     const_view_ = new gsl_vector_const_view(
    102                    gsl_vector_const_subvector_with_stride(v.gsl_vector_p(),
    103                                                           offset, stride,n));
    104     const_vec_ = &(const_view_->vector);
    105   }
    106 
    107 
    10881  VectorView::VectorView(matrix& m, size_t i, bool row)
    109     : VectorBase(), const_view_(NULL)
     82    : VectorMutable()
    11083  {
    11184    view_=new gsl_vector_view(row ?
     
    11689
    11790
    118   VectorView::VectorView(const matrix& m, size_t i, bool row)
    119     : VectorBase(), view_(NULL)
     91  VectorView::VectorView(proxy p)
     92    : VectorMutable(p.vec_), view_(NULL)
    12093  {
    121     const_view_ =
    122       new gsl_vector_const_view(row ?
    123                                 gsl_matrix_const_row(m.gsl_matrix_p(),i) :
    124                                 gsl_matrix_const_column(m.gsl_matrix_p(),i));
    125     const_vec_ = &(const_view_->vector);
    12694  }
    12795
    128 
    129   /*
    130   VectorView::VectorView(proxy p)
    131     : VectorBase()
    132   {
    133     view_ = new gsl_vector_view(gsl_vector_subvector(p.vec_, 0, p.vec_->size));
    134     const_vec_ = vec_ = &(view_->vector);
    135   }
    136   */
    13796
    13897  VectorView::~VectorView(void)
     
    173132
    174133 
    175   /*
    176   const VectorView& VectorView::operator=(proxy p)
    177   {
    178     if (size()!=p.vec_->size)
    179       throw utility::GSL_error("VectorView::dimension mis-match");
    180     if (!size())
    181       return *this;
    182     clean_up();
    183     view_ = new gsl_vector_view(gsl_vector_subvector(p.vec_,0, p.vec_->size));
    184     const_vec_=vec_ = &view_->vector;
    185     return *this;
    186   }
    187   */
    188 
    189134  void VectorView::delete_allocated_memory(void)
    190135  {
     
    193138      view_=NULL;
    194139    }
    195     else if (const_view_){
    196       delete const_view_;
    197       const_view_=NULL;
    198     }
    199140    const_vec_ = vec_ = NULL;
    200141  }
Note: See TracChangeset for help on using the changeset viewer.