yat  0.21pre
MatrixView.h
1 #ifndef _theplu_yat_utility_matrix_view_
2 #define _theplu_yat_utility_matrix_view_
3 
4 // $Id: MatrixView.h 4141 2022-02-01 05:11:36Z peter $
5 
6 /*
7  Copyright (C) 2022 Peter Johansson
8 
9  This file is part of the yat library, https://dev.thep.lu.se/yat
10 
11  The yat library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU General Public License as
13  published by the Free Software Foundation; either version 3 of the
14  License, or (at your option) any later version.
15 
16  The yat library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with yat. If not, see <https://www.gnu.org/licenses/>.
23 */
24 
25 #include "config_public.h"
26 
27 #include "MatrixMutable.h"
28 
29 #include <gsl/gsl_matrix.h>
30 
31 #include <cstddef> // size_t
32 
33 namespace theplu {
34 namespace yat {
35 namespace utility {
36 
55  class MatrixView : public MatrixMutable
56  {
57  public:
62  MatrixView(void);
63 
69  MatrixView(MatrixView& other);
70 
74  explicit MatrixView(MatrixMutable& other);
75 
83  MatrixView(MatrixMutable& other, size_t row_offset, size_t col_offset,
84  size_t rows, size_t columns);
85 
89  explicit MatrixView(gsl_matrix* m);
90 
96  MatrixView(double* p, size_t rows, size_t cols);
97 
103  MatrixView(double* p, size_t rows, size_t cols, size_t tda);
104 
108  ~MatrixView(void);
109 
110  using MatrixMutable::operator=;
111 
115  gsl_matrix* gsl_matrix_p(void);
116 
120  const gsl_matrix* gsl_matrix_p(void) const;
121 
126  MatrixView& operator=(const MatrixView& other);
127 
128  protected:
134  void copy_assign(const gsl_matrix* rhs);
136 
140  void move_assign(MatrixMutable&& rhs);
141 
145  void move_assign(gsl_matrix*&& rhs);
146  private:
147  gsl_matrix_view* view_;
148  // create view of data in \c other
149  void copy(gsl_matrix* other);
150  // create view of data in \c other. Created view has dimension n1
151  // x n2 and view(0,0) points to other(k1, k2)
152  void copy(gsl_matrix* other, size_t k1, size_t k2, size_t n1, size_t n2);
153 
154 
155  // See VectorView::proxy for motivation.
156  struct proxy
157  {
158  proxy(void) = delete;
159  proxy(gsl_matrix_view*&& v);
160  gsl_matrix_view* view_;
161  };
162 
163  public:
167  MatrixView(proxy p);
168 
172  operator proxy();
173  };
174 
175 }}} // of namespace utility, yat, and theplu
176 
177 #endif
The Department of Theoretical Physics namespace as we define it.
MatrixView & operator=(const MatrixView &other)
void copy_assign(const MatrixBase &other)
Behaves like operator=(const MatrixBase&)
void move_assign(MatrixMutable &&rhs)
gsl_matrix * gsl_matrix_p(void)
Interface to GSL matrix_view.
Definition: MatrixView.h:55
void copy_assign(const gsl_matrix *rhs)
Definition: MatrixMutable.h:58

Generated on Wed Jan 25 2023 03:34:29 for yat by  doxygen 1.8.14