Mantid
Loading...
Searching...
No Matches
EigenMatrixView.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2022 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8#include "MantidCurveFitting/DllConfig.h"
9
10#include <Eigen/Core>
11
12namespace {
13#define SIZE_T_NULL (UINT64_MAX)
14} // namespace
15
16namespace Mantid::CurveFitting {
17typedef Eigen::Stride<Eigen::Dynamic, Eigen::Dynamic> dynamic_stride;
18typedef Eigen::Map<Eigen::MatrixXd, 0, dynamic_stride> map_type;
19typedef Eigen::Map<const Eigen::MatrixXd, 0, dynamic_stride> const_map_type;
20
21class MANTID_CURVEFITTING_DLL EigenMatrix_View {
22public:
23 // EigenMatrix_View Constructors
24 // default constructor
26
27 // constructor: array->matrix view
28 EigenMatrix_View(double *base, const size_t nTotalRows, size_t nTotalCols, size_t nElements_1 = SIZE_T_NULL,
29 size_t nElements_2 = SIZE_T_NULL, const size_t startElement_1 = 0, const size_t startElement_2 = 0);
30
31 // constructor: matrix->matrix view
32 EigenMatrix_View(Eigen::MatrixXd &matrix, size_t nElements_1 = SIZE_T_NULL, size_t nElements_2 = SIZE_T_NULL,
33 const size_t startElement_1 = 0, const size_t startElement_2 = 0);
34
35 // constructor: map->matrix view
36 EigenMatrix_View(map_type &matrix, size_t nElements_1 = SIZE_T_NULL, size_t nElements_2 = SIZE_T_NULL,
37 const size_t startElement_1 = 0, const size_t startElement_2 = 0);
38
39 // CONST constructor: array->matrix view
40 EigenMatrix_View(const double *base, const size_t nTotalRows, size_t nTotalCols, size_t nElements_1 = SIZE_T_NULL,
41 size_t nElements_2 = SIZE_T_NULL, const size_t startElement_1 = 0, const size_t startElement_2 = 0);
42
43 // CONST constructor: matrix->matrix view
44 EigenMatrix_View(const Eigen::MatrixXd &matrix, size_t nElements_1 = SIZE_T_NULL, size_t nElements_2 = SIZE_T_NULL,
45 const size_t startElement_1 = 0, const size_t startElement_2 = 0);
46
47 // CONST constructor: map->matrix view
48 EigenMatrix_View(const map_type &matrix, size_t nElements_1 = SIZE_T_NULL, size_t nElements_2 = SIZE_T_NULL,
49 const size_t startElement_1 = 0, const size_t startElement_2 = 0);
50
51 // copy constructor
53
54 // CONST copy constructor
56
57 map_type &matrix_mutator();
58 inline const map_type matrix_inspector() const { return m_view; };
59 inline map_type matrix_copy() const { return m_view; };
60 inline size_t rows() const { return m_view.rows(); }
61 inline size_t cols() const { return m_view.cols(); };
62 inline size_t outerStride() const { return m_view.outerStride(); }
63 inline size_t innerStride() const { return m_view.innerStride(); }
64
66 EigenMatrix_View &operator=(EigenMatrix_View &&V);
67
68protected:
69 void initialiseMatrix(const size_t nTotalRows, const size_t nTotalCols, size_t &nElements_1, size_t &nElements_2) {
70 if (nElements_1 == SIZE_T_NULL)
71 nElements_1 = nTotalRows;
72 if (nElements_2 == SIZE_T_NULL)
73 nElements_2 = nTotalCols;
74 }
75
77 bool m_isConst = false;
78};
79} // namespace Mantid::CurveFitting
#define SIZE_T_NULL
void initialiseMatrix(const size_t nTotalRows, const size_t nTotalCols, size_t &nElements_1, size_t &nElements_2)
const map_type matrix_inspector() const
Eigen::Map< Eigen::MatrixXd, 0, dynamic_stride > map_type
Eigen::Stride< Eigen::Dynamic, Eigen::Dynamic > dynamic_stride
Eigen::Map< const Eigen::MatrixXd, 0, dynamic_stride > const_map_type