Nektar++
Loading...
Searching...
No Matches
MatrixBase.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: MatrixBase.hpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Interface classes for matrices
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_MATRIX_BASE_HPP
36#define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_MATRIX_BASE_HPP
37
39
44
46
47#ifdef max
48#undef max
49#endif
50
51namespace Nektar
52{
53template <typename DataType> class ConstMatrix
54{
55public:
57
58public:
59 LIB_UTILITIES_EXPORT typename boost::call_traits<DataType>::value_type
60 operator()(unsigned int row, unsigned int column) const;
61
62 LIB_UTILITIES_EXPORT unsigned int GetStorageSize() const;
63
65 {
66 return m_storageType;
67 }
68
73
74 LIB_UTILITIES_EXPORT unsigned int GetRows() const;
75
76 LIB_UTILITIES_EXPORT unsigned int GetTransposedRows(char transpose) const;
77
78 LIB_UTILITIES_EXPORT unsigned int GetColumns() const;
79
81 char transpose) const;
82
83 LIB_UTILITIES_EXPORT const unsigned int *GetSize() const;
84
86
88
89 LIB_UTILITIES_EXPORT static unsigned int CalculateIndex(
90 MatrixStorage type, unsigned int row, unsigned int col,
91 unsigned int numRows, unsigned int numColumns,
92 const char transpose = 'N', unsigned int numSubDiags = 0,
93 unsigned int numSuperDiags = 0);
94
96 MatrixStorage type, unsigned int rows, unsigned int columns,
97 unsigned int subDiags = 0, unsigned int superDiags = 0);
98
99protected:
100 // All constructors are private to enforce the abstract nature of
101 // ConstMatrix without resorting to pure virtual functions.
102 LIB_UTILITIES_EXPORT ConstMatrix(unsigned int rows, unsigned int columns,
103 MatrixStorage policy = eFULL);
104
106
108 const ConstMatrix<DataType> &rhs);
109
110 /// \brief Resets the rows and columns in the array.
111 /// This method does not update the data storage to match the new row and
112 /// column counts.
113 LIB_UTILITIES_EXPORT void Resize(unsigned int rows, unsigned int columns);
114
115 LIB_UTILITIES_EXPORT void SetTransposeFlag(char newValue);
117 {
118 return m_transpose;
119 }
120
121 virtual typename boost::call_traits<DataType>::value_type v_GetValue(
122 unsigned int row, unsigned int column) const = 0;
123 virtual unsigned int v_GetStorageSize() const = 0;
124 LIB_UTILITIES_EXPORT virtual void v_Transpose();
125 LIB_UTILITIES_EXPORT virtual char v_GetTransposeFlag() const;
126
127private:
128 unsigned int m_size[2];
131};
132
133template <typename DataType> class Matrix : public ConstMatrix<DataType>
134{
135public:
136 LIB_UTILITIES_EXPORT ~Matrix() override;
137
139 unsigned int row, unsigned int column,
140 typename boost::call_traits<DataType>::const_reference d);
141
142protected:
143 // All constructors are private to enforce the abstract nature of
144 // ConstMatrix without resorting to pure virtual functions.
145 LIB_UTILITIES_EXPORT Matrix(unsigned int rows, unsigned int columns,
146 MatrixStorage policy = eFULL);
147
149
151 const Matrix<DataType> &rhs);
152
154 const ConstMatrix<DataType> &rhs);
155
156private:
158 unsigned int row, unsigned int column,
159 typename boost::call_traits<DataType>::const_reference d) = 0;
160};
161
162} // namespace Nektar
163
164#endif // NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_MATRIX_BASE_HPP
#define LIB_UTILITIES_EXPORT
void SetTransposeFlag(char newValue)
MatrixStorage GetType() const
MatrixStorage GetStorageType() const
unsigned int m_size[2]
ConstMatrix< DataType > & operator=(const ConstMatrix< DataType > &rhs)
boost::call_traits< DataType >::value_type operator()(unsigned int row, unsigned int column) const
unsigned int GetStorageSize() const
static unsigned int CalculateIndex(MatrixStorage type, unsigned int row, unsigned int col, unsigned int numRows, unsigned int numColumns, const char transpose='N', unsigned int numSubDiags=0, unsigned int numSuperDiags=0)
virtual unsigned int v_GetStorageSize() const =0
unsigned int GetTransposedColumns(char transpose) const
virtual ~ConstMatrix()=default
virtual char v_GetTransposeFlag() const
unsigned int GetRows() const
virtual boost::call_traits< DataType >::value_type v_GetValue(unsigned int row, unsigned int column) const =0
virtual void v_Transpose()
MatrixStorage m_storageType
unsigned int GetTransposedRows(char transpose) const
void Resize(unsigned int rows, unsigned int columns)
Resets the rows and columns in the array. This method does not update the data storage to match the n...
char GetRawTransposeFlag() const
static unsigned int GetRequiredStorageSize(MatrixStorage type, unsigned int rows, unsigned int columns, unsigned int subDiags=0, unsigned int superDiags=0)
char GetTransposeFlag() const
unsigned int GetColumns() const
const unsigned int * GetSize() const
void SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)
Matrix< DataType > & operator=(const Matrix< DataType > &rhs)
virtual void v_SetValue(unsigned int row, unsigned int column, typename boost::call_traits< DataType >::const_reference d)=0
~Matrix() override