yat
0.8.3pre
|
00001 #ifndef _theplu_yat_utility_vector_mutable_ 00002 #define _theplu_yat_utility_vector_mutable_ 00003 00004 // $Id: VectorMutable.h 2121 2009-12-13 16:17:07Z peter $ 00005 00006 /* 00007 Copyright (C) 2003 Daniel Dalevi, Peter Johansson 00008 Copyright (C) 2004 Jari Häkkinen, Peter Johansson 00009 Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér 00010 Copyright (C) 2006 Jari Häkkinen, Markus Ringnér 00011 Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér 00012 Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson 00013 00014 This file is part of the yat library, http://dev.thep.lu.se/trac/yat 00015 00016 The yat library is free software; you can redistribute it and/or 00017 modify it under the terms of the GNU General Public License as 00018 published by the Free Software Foundation; either version 3 of the 00019 License, or (at your option) any later version. 00020 00021 The yat library is distributed in the hope that it will be useful, 00022 but WITHOUT ANY WARRANTY; without even the implied warranty of 00023 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00024 General Public License for more details. 00025 00026 You should have received a copy of the GNU General Public License 00027 along with yat. If not, see <http://www.gnu.org/licenses/>. 00028 */ 00029 00030 #include "VectorBase.h" 00031 #include "StrideIterator.h" 00032 00033 #include <cstddef> // size_t 00034 00035 #include <gsl/gsl_vector.h> 00036 00037 namespace theplu { 00038 namespace yat { 00039 namespace utility { 00040 00041 class matrix; 00042 class Vector; 00043 00054 class VectorMutable : public VectorBase 00055 { 00056 public: 00062 typedef double& reference; 00063 00067 typedef StrideIterator<double*> iterator; 00068 00072 VectorMutable(void); 00073 00077 VectorMutable(gsl_vector*); 00078 00082 VectorMutable(const gsl_vector*); 00083 00087 virtual ~VectorMutable(void); 00088 00092 void all(double value); 00093 00097 iterator begin(void); 00098 00099 // to allow overload from base class 00100 using VectorBase::begin; 00101 00108 void div(const VectorBase& other); 00109 00113 iterator end(void); 00114 00115 // to allow overload from base class 00116 using VectorBase::end; 00117 00121 gsl_vector* gsl_vector_p(void); 00122 00123 using VectorBase::gsl_vector_p; 00124 00132 virtual bool isview(void) const=0; 00133 00140 void mul(const VectorBase& other); 00141 00145 void reverse(void); 00146 00150 void swap(size_t i, size_t j); 00151 00161 double& operator()(size_t i); 00162 00163 // to allow overload from base class 00164 using VectorBase::operator(); 00165 00174 const VectorMutable& operator+=(const VectorBase&); 00175 00182 const VectorMutable& operator+=(double d); 00183 00192 const VectorMutable& operator-=(const VectorBase&); 00193 00200 const VectorMutable& operator-=(double d); 00201 00208 const VectorMutable& operator*=(double d); 00209 00210 protected: 00217 gsl_vector* vec_; 00218 00219 private: 00220 // copy assignment not allowed 00221 const VectorMutable& operator=(const VectorMutable&); 00222 00223 }; 00224 00228 void shuffle(VectorMutable& invec); 00229 00235 void sort(VectorMutable& vec); 00236 00237 }}} // of namespace utility, yat, and theplu 00238 00239 #endif