00001 #ifndef _theplu_yat_utility_vector_mutable_ 00002 #define _theplu_yat_utility_vector_mutable_ 00003 00004 // $Id: VectorMutable.h 1924 2009-04-29 15:43:22Z 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 Jari Häkkinen, Peter Johansson 00013 Copyright (C) 2009 Peter Johansson 00014 00015 This file is part of the yat library, http://dev.thep.lu.se/trac/yat 00016 00017 The yat library is free software; you can redistribute it and/or 00018 modify it under the terms of the GNU General Public License as 00019 published by the Free Software Foundation; either version 3 of the 00020 License, or (at your option) any later version. 00021 00022 The yat library is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00025 General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License 00028 along with yat. If not, see <http://www.gnu.org/licenses/>. 00029 */ 00030 00031 #include "VectorBase.h" 00032 #include "Exception.h" 00033 #include "StrideIterator.h" 00034 00035 #include <cstddef> // size_t 00036 00037 #include <gsl/gsl_vector.h> 00038 00039 namespace theplu { 00040 namespace yat { 00041 namespace utility { 00042 00043 class matrix; 00044 class Vector; 00045 00056 class VectorMutable : public VectorBase 00057 { 00058 public: 00064 typedef double& reference; 00065 00069 typedef StrideIterator<double*> iterator; 00070 00074 VectorMutable(void); 00075 00079 VectorMutable(gsl_vector*); 00080 00084 VectorMutable(const gsl_vector*); 00085 00089 virtual ~VectorMutable(void); 00090 00094 void all(double value); 00095 00099 iterator begin(void); 00100 00101 // to allow overload from base class 00102 using VectorBase::begin; 00103 00110 void div(const VectorBase& other); 00111 00115 iterator end(void); 00116 00117 // to allow overload from base class 00118 using VectorBase::end; 00119 00123 gsl_vector* gsl_vector_p(void); 00124 00125 using VectorBase::gsl_vector_p; 00126 00134 virtual bool isview(void) const=0; 00135 00142 void mul(const VectorBase& other); 00143 00147 void reverse(void); 00148 00152 void swap(size_t i, size_t j); 00153 00163 double& operator()(size_t i); 00164 00165 // to allow overload from base class 00166 using VectorBase::operator(); 00167 00176 const VectorMutable& operator+=(const VectorBase&); 00177 00184 const VectorMutable& operator+=(double d); 00185 00194 const VectorMutable& operator-=(const VectorBase&); 00195 00202 const VectorMutable& operator-=(double d); 00203 00210 const VectorMutable& operator*=(double d); 00211 00212 protected: 00219 gsl_vector* vec_; 00220 00221 private: 00222 // copy assignment not allowed 00223 const VectorMutable& operator=(const VectorMutable&); 00224 00225 }; 00226 00230 void shuffle(VectorMutable& invec); 00231 00237 void sort(VectorMutable& vec); 00238 00239 }}} // of namespace utility, yat, and theplu 00240 00241 #endif