yat/utility/MatrixConstView.h

Code
Comments
Other
Rev Date Author Line
4129 19 Jan 22 peter 1 #ifndef _theplu_yat_utility_matrix_const_view_
4129 19 Jan 22 peter 2 #define _theplu_yat_utility_matrix_const_view_
4129 19 Jan 22 peter 3
4129 19 Jan 22 peter 4 // $Id$
4129 19 Jan 22 peter 5
4129 19 Jan 22 peter 6 /*
4129 19 Jan 22 peter 7   Copyright (C) 2022 Peter Johansson
4129 19 Jan 22 peter 8
4129 19 Jan 22 peter 9   This file is part of the yat library, https://dev.thep.lu.se/yat
4129 19 Jan 22 peter 10
4129 19 Jan 22 peter 11   The yat library is free software; you can redistribute it and/or
4129 19 Jan 22 peter 12   modify it under the terms of the GNU General Public License as
4129 19 Jan 22 peter 13   published by the Free Software Foundation; either version 3 of the
4129 19 Jan 22 peter 14   License, or (at your option) any later version.
4129 19 Jan 22 peter 15
4129 19 Jan 22 peter 16   The yat library is distributed in the hope that it will be useful,
4129 19 Jan 22 peter 17   but WITHOUT ANY WARRANTY; without even the implied warranty of
4129 19 Jan 22 peter 18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4129 19 Jan 22 peter 19   General Public License for more details.
4129 19 Jan 22 peter 20
4129 19 Jan 22 peter 21   You should have received a copy of the GNU General Public License
4129 19 Jan 22 peter 22   along with yat. If not, see <https://www.gnu.org/licenses/>.
4129 19 Jan 22 peter 23 */
4129 19 Jan 22 peter 24
4129 19 Jan 22 peter 25 #include "config_public.h"
4129 19 Jan 22 peter 26
4129 19 Jan 22 peter 27 #include "MatrixBase.h"
4129 19 Jan 22 peter 28
4129 19 Jan 22 peter 29 #include <gsl/gsl_matrix.h>
4129 19 Jan 22 peter 30
4129 19 Jan 22 peter 31 #include <cstddef> // size_t
4129 19 Jan 22 peter 32
4129 19 Jan 22 peter 33 namespace theplu {
4129 19 Jan 22 peter 34 namespace yat {
4129 19 Jan 22 peter 35 namespace utility {
4129 19 Jan 22 peter 36
4129 19 Jan 22 peter 37   /**
4129 19 Jan 22 peter 38      \since New in yat 0.20
4129 19 Jan 22 peter 39    */
4129 19 Jan 22 peter 40   class MatrixConstView : public MatrixBase
4129 19 Jan 22 peter 41   {
4129 19 Jan 22 peter 42   public:
4129 19 Jan 22 peter 43     /**
4129 19 Jan 22 peter 44        Default constructor. Constructed view behaves like viewing into
4129 19 Jan 22 peter 45        an empty Matrix.
4129 19 Jan 22 peter 46      */
4129 19 Jan 22 peter 47     MatrixConstView(void);
4129 19 Jan 22 peter 48
4129 19 Jan 22 peter 49     /**
4129 19 Jan 22 peter 50        Copy constructor
4129 19 Jan 22 peter 51      */
4129 19 Jan 22 peter 52     MatrixConstView(const MatrixConstView& other);
4129 19 Jan 22 peter 53
4129 19 Jan 22 peter 54     /**
4129 19 Jan 22 peter 55        Create a view into a matrix \c other.
4129 19 Jan 22 peter 56      */
4129 19 Jan 22 peter 57     explicit MatrixConstView(const MatrixBase& other);
4129 19 Jan 22 peter 58
4129 19 Jan 22 peter 59     /**  for (size_t i=0; i<matrix.rows(); ++i)
4129 19 Jan 22 peter 60
4129 19 Jan 22 peter 61        Create view into sub-matrix into \c other.
4129 19 Jan 22 peter 62
4129 19 Jan 22 peter 63        view(0,) will view into other(row_offset, col_offset) and have
4129 19 Jan 22 peter 64        dimension row x column.
4129 19 Jan 22 peter 65      */
4129 19 Jan 22 peter 66     MatrixConstView(const MatrixBase& other,
4129 19 Jan 22 peter 67                     size_t row_offset, size_t col_offset,
4129 19 Jan 22 peter 68                     size_t rows, size_t columns);
4129 19 Jan 22 peter 69
4129 19 Jan 22 peter 70     /**
4141 01 Feb 22 peter 71        Create a view into \c m.
4141 01 Feb 22 peter 72      */
4141 01 Feb 22 peter 73     explicit MatrixConstView(const gsl_matrix* m);
4141 01 Feb 22 peter 74
4141 01 Feb 22 peter 75     /**
4141 01 Feb 22 peter 76        Create a view with \c rows rows and \c cols columns. Data are
4141 01 Feb 22 peter 77        stored in row-major order such that p[1] correspond to
4141 01 Feb 22 peter 78        view(0,1).
4141 01 Feb 22 peter 79      */
4141 01 Feb 22 peter 80     MatrixConstView(const double* p, size_t rows, size_t cols);
4141 01 Feb 22 peter 81
4141 01 Feb 22 peter 82     /**
4141 01 Feb 22 peter 83        Create a view with \c rows rows and \c cols columns. The
4141 01 Feb 22 peter 84        physical row dimension is \c tda, i.e., the first element on
4141 01 Feb 22 peter 85        the second row is p[tda].
4141 01 Feb 22 peter 86      */
4141 01 Feb 22 peter 87     MatrixConstView(const double* p, size_t rows, size_t cols, size_t tda);
4141 01 Feb 22 peter 88
4141 01 Feb 22 peter 89     /**
4129 19 Jan 22 peter 90        \brief Destructor
4129 19 Jan 22 peter 91      */
4129 19 Jan 22 peter 92     ~MatrixConstView(void);
4129 19 Jan 22 peter 93
4129 19 Jan 22 peter 94     const gsl_matrix* gsl_matrix_p(void) const;
4129 19 Jan 22 peter 95   private:
4129 19 Jan 22 peter 96     gsl_matrix_const_view* view_;
4129 19 Jan 22 peter 97     void copy(const gsl_matrix* other);
4129 19 Jan 22 peter 98     void copy(const gsl_matrix* other, size_t, size_t, size_t, size_t);
4129 19 Jan 22 peter 99   };
4129 19 Jan 22 peter 100
4129 19 Jan 22 peter 101 }}} // of namespace utility, yat, and theplu
4129 19 Jan 22 peter 102
4129 19 Jan 22 peter 103 #endif