yat  0.20.3pre
VectorView.h
1 #ifndef _theplu_yat_utility_vector_view_
2 #define _theplu_yat_utility_vector_view_
3 
4 // $Id: VectorView.h 4207 2022-08-26 04:36:28Z 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) 2012, 2017, 2021, 2022 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 "VectorMutable.h"
32 
33 #include <gsl/gsl_vector.h>
34 
35 namespace theplu {
36 namespace yat {
37 namespace utility {
38 
39  class MatrixMutable;
40  class Vector;
41 
79  class VectorView : public VectorMutable
80  {
81  public:
87  VectorView(void);
88 
97  VectorView(VectorView& other);
98 
106  explicit VectorView(VectorMutable& other);
107 
118  VectorView(VectorMutable& v, size_t offset, size_t n, size_t stride=1);
119 
137  VectorView(MatrixMutable& m, size_t i, bool row=true);
138 
144  explicit VectorView(gsl_vector* v);
145 
152  VectorView(double* v, size_t size, size_t stride=1);
153 
157  ~VectorView(void);
158 
162  bool isview(void) const;
163 
173  const VectorView& operator=(const VectorView&);
174 
184  const VectorView& operator=(const VectorBase&);
185 
189  template<class T>
191  {
192  assign(rhs.gsl_vector_p());
193  return *this;
194  }
195 
196  private:
197  const VectorView& assign(const VectorBase& other);
198  const VectorView& assign(const gsl_vector* rhs);
199  void copy(gsl_vector*);
200  void delete_allocated_memory(void);
201 
202  gsl_vector_view* view_;
203 
215  struct proxy
216  {
219  gsl_vector* vec_;
220  };
221 
222  public:
226  VectorView(proxy p);
227 
231  operator proxy();
232  };
233 
234 }}} // of namespace utility, yat, and theplu
235 
236 #endif
The Department of Theoretical Physics namespace as we define it.
This is the yat interface to gsl_vector_view.
Definition: VectorView.h:79
VectorView(void)
Default constructor.
This is the yat interface to GSL vector.
Definition: VectorBase.h:55
gsl_vector * vec_
Definition: VectorMutable.h:269
VectorView & operator=(const VectorExpression< T > &rhs)
assignment from vector expression
Definition: VectorView.h:190
An expression that can be converted to a Vector.
Definition: VectorExpression.h:67
This is the mutable interface to GSL vector.
Definition: VectorMutable.h:56
const VectorView & operator=(const VectorView &)
The assignment operator.
const gsl_vector * gsl_vector_p(void) const
return a GSL vector pointer
Definition: VectorExpression.h:110
Definition: MatrixMutable.h:58

Generated on Sat Feb 18 2023 03:31:44 for yat by  doxygen 1.8.14