yat  0.14.5pre
VectorBase.h
1 #ifndef _theplu_yat_utility_vector_base_
2 #define _theplu_yat_utility_vector_base_
3 
4 // $Id: VectorBase.h 2992 2013-03-03 05:03:44Z 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 Jari Häkkinen, Peter Johansson
13  Copyright (C) 2009, 2012 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 "StrideIterator.h"
32 
33 #include <iosfwd>
34 #include <vector>
35 #include <cstddef> // size_t
36 
37 #include <gsl/gsl_vector.h>
38 
39 namespace theplu {
40 namespace yat {
41 namespace utility {
42 
43  class matrix;
44  class Vector;
45 
52  class VectorBase
53  {
54  public:
60  typedef double value_type;
61 
67  typedef const double& const_reference;
68 
71 
75  VectorBase(const gsl_vector* v=NULL);
76 
80  virtual ~VectorBase(void);
81 
85  const_iterator begin(void) const;
86 
90  const_iterator end(void) const;
91 
101  bool equal(const VectorBase&, const double precision=0) const;
102 
106  const gsl_vector* gsl_vector_p(void) const;
107 
114  virtual bool isview(void) const=0;
115 
119  size_t size(void) const;
120 
130  const double& operator()(size_t i) const;
131 
143  bool operator==(const VectorBase&) const;
144 
156  bool operator!=(const VectorBase&) const;
157 
161  double operator*(const VectorBase&) const;
162 
163  protected:
165  const gsl_vector* const_vec_;
166 
167  private:
168  // copy assignment not allowed
169  const VectorBase& operator=(const VectorBase&);
170  };
171 
180  bool isnull(const VectorBase&);
181 
189  double max(const VectorBase&);
190 
200  size_t max_index(const VectorBase&);
201 
209  double min(const VectorBase&);
210 
220  size_t min_index(const VectorBase&);
221 
237  bool nan(const VectorBase& templat, Vector& flag);
238 
251  void sort_index(std::vector<size_t>& sort_index, const VectorBase& invec);
252 
259  void sort_smallest_index(std::vector<size_t>& sort_index, size_t k,
260  const VectorBase& invec);
261 
268  void sort_largest_index(std::vector<size_t>& sort_index, size_t k,
269  const VectorBase& invec);
270 
278  double sum(const VectorBase&);
279 
293  std::ostream& operator<<(std::ostream& s, const VectorBase& v);
294 
295 }}} // of namespace utility, yat, and theplu
296 
297 #endif
const gsl_vector * gsl_vector_p(void) const
const double & operator()(size_t i) const
Element access operator.
double value_type
Definition: VectorBase.h:60
bool operator!=(const VectorBase &) const
Comparison operator. Takes linear time.
StrideIterator< const double * > const_iterator
VectorBase::const_iterator.
Definition: VectorBase.h:70
const gsl_vector * const_vec_
pointer to underlying GSL vector
Definition: VectorBase.h:165
void sort_smallest_index(std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
const_iterator begin(void) const
T max(const T &a, const T &b, const T &c)
Definition: stl_utility.h:697
bool operator==(const VectorBase &) const
Comparison operator. Takes linear time.
This is the yat interface to GSL vector.
Definition: Vector.h:57
This is the yat interface to GSL vector.
Definition: VectorBase.h:52
virtual bool isview(void) const =0
double operator*(const VectorBase &) const
bool equal(const VectorBase &, const double precision=0) const
Check whether VectorBases are equal within a user defined precision, set by precision.
const_iterator end(void) const
void sort_index(InputIterator first, InputIterator last, std::vector< size_t > &sort_index)
Definition: sort_index.h:146
const double & const_reference
Definition: VectorBase.h:67
VectorBase(const gsl_vector *v=NULL)
Constructor.
void sort_largest_index(std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
Adaptor using a stride on underlying iterator.
Definition: StrideIterator.h:50

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