yat  0.14.5pre
VectorMutable.h
1 #ifndef _theplu_yat_utility_vector_mutable_
2 #define _theplu_yat_utility_vector_mutable_
3 
4 // $Id: VectorMutable.h 3550 2017-01-03 05:41:02Z peter $
5 
6 /*
7  Copyright (C) 2003 Daniel Dalevi, Peter Johansson
8  Copyright (C) 2004 Jari Häkkinen, Peter Johansson
9  Copyright (C) 2005 Jari Häkkinen, Peter Johansson, Markus Ringnér
10  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
11  Copyright (C) 2007 Jari Häkkinen, Peter Johansson, Markus Ringnér
12  Copyright (C) 2008, 2009 Jari Häkkinen, Peter Johansson
13  Copyright (C) 2012, 2016 Peter Johansson
14 
15  This file is part of the yat library, http://dev.thep.lu.se/trac/yat
16 
17  The yat library is free software; you can redistribute it and/or
18  modify it under the terms of the GNU General Public License as
19  published by the Free Software Foundation; either version 3 of the
20  License, or (at your option) any later version.
21 
22  The yat library is distributed in the hope that it will be useful,
23  but WITHOUT ANY WARRANTY; without even the implied warranty of
24  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25  General Public License for more details.
26 
27  You should have received a copy of the GNU General Public License
28  along with yat. If not, see <http://www.gnu.org/licenses/>.
29 */
30 
31 #include "VectorBase.h"
32 #include "StrideIterator.h"
33 
34 #include <gsl/gsl_vector.h>
35 
36 #include <cstddef> // size_t
37 
38 namespace theplu {
39 namespace yat {
40 namespace utility {
41 
42  class matrix;
43  class Vector;
44 
55  class VectorMutable : public VectorBase
56  {
57  public:
63  typedef double& reference;
64 
69 
73  VectorMutable(void);
74 
78  VectorMutable(gsl_vector*);
79 
83  VectorMutable(const gsl_vector*);
84 
88  virtual ~VectorMutable(void);
89 
93  void all(double value);
94 
98  iterator begin(void);
99 
100  // to allow overload from base class
101  using VectorBase::begin;
102 
109  void div(const VectorBase& other);
110 
114  iterator end(void);
115 
116  // to allow overload from base class
117  using VectorBase::end;
118 
122  gsl_vector* gsl_vector_p(void);
123 
125 
133  virtual bool isview(void) const=0;
134 
141  void mul(const VectorBase& other);
142 
146  void reverse(void);
147 
151  void swap(size_t i, size_t j);
152 
162  double& operator()(size_t i);
163 
164  // to allow overload from base class
165  using VectorBase::operator();
166 
175  const VectorMutable& operator+=(const VectorBase&);
176 
183  const VectorMutable& operator+=(double d);
184 
193  const VectorMutable& operator-=(const VectorBase&);
194 
201  const VectorMutable& operator-=(double d);
202 
209  const VectorMutable& operator*=(double d);
210 
216  const VectorMutable& operator=(const VectorMutable&);
217 
223  const VectorMutable& operator=(const VectorBase&);
224 
225  protected:
232  gsl_vector* vec_;
233 
234  private:
235  virtual const VectorMutable& assign(const VectorBase& rhs)=0;
236  };
237 
241  void shuffle(VectorMutable& invec);
242 
248  void sort(VectorMutable& vec);
249 
250 }}} // of namespace utility, yat, and theplu
251 
252 #endif
const gsl_vector * gsl_vector_p(void) const
void shuffle(VectorMutable &invec)
StrideIterator< double * > iterator
mutable iterator
Definition: VectorMutable.h:68
void swap(size_t i, size_t j)
Exchange elements i and j.
const_iterator begin(void) const
VectorMutable(void)
default constructor
const VectorMutable & operator+=(const VectorBase &)
Addition and assign operator. VectorBase addition, .
const VectorMutable & operator-=(const VectorBase &)
Subtract and assign operator. VectorBase subtraction, .
virtual bool isview(void) const =0
This is the yat interface to GSL vector.
Definition: VectorBase.h:52
gsl_vector * vec_
Definition: VectorMutable.h:232
const VectorMutable & operator*=(double d)
Multiply with scalar and assign operator, .
const_iterator end(void) const
This is the mutable interface to GSL vector.
Definition: VectorMutable.h:55
void div(const VectorBase &other)
This function performs element-wise division, .
void sort(VectorMutable &vec)
double & operator()(size_t i)
Element access operator.
void mul(const VectorBase &other)
This function performs element-wise multiplication, .
double & reference
Definition: VectorMutable.h:63
const VectorMutable & operator=(const VectorMutable &)
assignment
Adaptor using a stride on underlying iterator.
Definition: StrideIterator.h:50
void reverse(void)
Reverse the order of elements in the VectorMutable.

Generated on Tue Sep 26 2017 02:33:29 for yat by  doxygen 1.8.5