- Timestamp:
- Mar 9, 2007, 10:40:34 AM (16 years ago)
- Location:
- trunk/yat/utility
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/vector.cc
r784 r787 5 5 Copyright (C) 2004 Jari Häkkinen, Peter Johansson 6 6 Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér 7 Copyright (C) 2006 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2007 Jari Häkkinen 7 Copyright (C) 2006, 2007 Jari Häkkinen, Peter Johansson 9 8 10 9 This file is part of the yat library, http://lev.thep.lu.se/trac/yat … … 42 41 43 42 vector::vector(void) 44 : v_(NULL), v _const_(NULL), view_(NULL), view_const_(NULL), proxy_v_(NULL)43 : v_(NULL), view_(NULL), view_const_(NULL), proxy_v_(NULL) 45 44 { 46 45 } … … 48 47 49 48 vector::vector(size_t n, double init_value) 50 : v_(gsl_vector_alloc(n)), v _const_(NULL), view_(NULL), view_const_(NULL),49 : v_(gsl_vector_alloc(n)), view_(NULL), view_const_(NULL), 51 50 proxy_v_(v_) 52 51 { … … 59 58 60 59 vector::vector(const vector& other) 61 : v_(other.create_gsl_vector_copy()), v _const_(NULL), view_(NULL),60 : v_(other.create_gsl_vector_copy()), view_(NULL), 62 61 view_const_(NULL), proxy_v_(v_) 63 62 { … … 66 65 67 66 vector::vector(vector& v, size_t offset, size_t n, size_t stride) 68 : v _const_(NULL), view_const_(NULL)67 : view_const_(NULL) 69 68 { 70 69 view_ = new gsl_vector_view(gsl_vector_subvector_with_stride(v.v_,offset, … … 83 82 if (!view_const_) 84 83 throw utility::GSL_error("vector::vector failed to setup view"); 85 proxy_v_ = v_const_ = &(view_const_->vector); 84 proxy_v_ = &(view_const_->vector); 85 const_cast<const gsl_vector*>(proxy_v_); 86 86 } 87 87 88 88 89 89 vector::vector(matrix& m, size_t i, bool row) 90 : v _const_(NULL), view_const_(NULL)90 : view_const_(NULL) 91 91 { 92 92 view_=new gsl_vector_view(row ? … … 107 107 if (!view_const_) 108 108 throw utility::GSL_error("vector::vector failed to setup view"); 109 proxy_v_ = v_const_ =&(view_const_->vector);109 proxy_v_ = &(view_const_->vector); 110 110 } 111 111 … … 113 113 vector::vector(std::istream& is, char sep) 114 114 throw (utility::IO_error, std::exception) 115 : v _const_(NULL), view_(NULL), view_const_(NULL)115 : view_(NULL), view_const_(NULL) 116 116 { 117 117 // read the data file and store in stl vectors (dynamically … … 347 347 else if ( v_ ) 348 348 gsl_vector_free( v_ ); 349 v_const_=NULL;350 349 proxy_v_ = v_ = other.create_gsl_vector_copy(); 351 350 } -
trunk/yat/utility/vector.h
r785 r787 8 8 Copyright (C) 2004 Jari Häkkinen, Peter Johansson 9 9 Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér 10 Copyright (C) 2006, 2007 Jari Häkkinen 10 Copyright (C) 2006 Jari Häkkinen 11 Copyright (C) 2007 Jari Häkkinen, Peter Johansson 11 12 12 13 This file is part of the yat library, http://lev.thep.lu.se/trac/yat … … 413 414 414 415 gsl_vector* v_; 415 const gsl_vector* v_const_;416 416 gsl_vector_view* view_; 417 417 const gsl_vector_const_view* view_const_; 418 // proxy_v_ is used to access the proper underlying v_ or v_const_418 // proxy_v_ is used to access the proper underlying gsl_vector 419 419 // in all const member functions. It is not used by design for 420 420 // non-const vector functions and operators. This is to make sure
Note: See TracChangeset
for help on using the changeset viewer.