Nektar++
ScaledMatrix.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: ScaledMatrix.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:
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
36 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
37 
39 
42 
43 namespace Nektar
44 {
45 template <typename DataType, typename InnerMatrixType>
46 class NekMatrix<NekMatrix<DataType, InnerMatrixType>, ScaledMatrixTag>
47  : public ConstMatrix<DataType>
48 {
49 public:
53  typedef typename std::remove_const<typename InnerType::NumberType>::type
55 
58 
59 public:
60  /// \internal
61  /// \brief Iterator through elements of the matrix.
62  /// Not quite a real iterator in the C++ sense.
63  class const_iterator
64  {
65  public:
66  const_iterator(typename InnerType::const_iterator iter,
67  const NumberType &scale)
68  : m_iter(iter), m_scale(scale)
69  {
70  }
71 
72  const_iterator operator++(int)
73  {
74  const_iterator out = *this;
75  ++m_iter;
76  return out;
77  }
78 
79  const_iterator &operator++()
80  {
81  ++m_iter;
82  return *this;
83  }
84 
86  {
87  return m_scale * (*m_iter);
88  }
89 
90  bool operator==(const const_iterator &rhs)
91  {
92  return m_iter == rhs.m_iter;
93  }
94 
95  bool operator!=(const const_iterator &rhs)
96  {
97  return !(*this == rhs);
98  }
99 
100  private:
101  typename InnerType::const_iterator m_iter;
103  };
104 
105 public:
107 
109  typename boost::call_traits<NumberType>::const_reference scale,
110  std::shared_ptr<const InnerType> m);
111 
113 
115  typename boost::call_traits<NumberType>::const_reference scale,
116  const ThisType &rhs);
117 
119 
120  LIB_UTILITIES_EXPORT ConstGetValueType operator()(unsigned int row,
121  unsigned int col) const;
122 
123  LIB_UTILITIES_EXPORT unsigned int GetStorageSize() const;
124 
125  LIB_UTILITIES_EXPORT NumberType Scale() const;
126  LIB_UTILITIES_EXPORT void SetScale(const NumberType &);
127 
128  LIB_UTILITIES_EXPORT const NumberType *GetRawPtr() const;
129 
130  LIB_UTILITIES_EXPORT std::shared_ptr<const InnerType> GetOwnedMatrix()
131  const;
132 
133  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSubDiagonals() const;
134  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSuperDiagonals() const;
135 
136  LIB_UTILITIES_EXPORT const_iterator begin() const;
137  LIB_UTILITIES_EXPORT const_iterator end() const;
138 
140 
141  LIB_UTILITIES_EXPORT static std::shared_ptr<ThisType> CreateWrapper(
142  const std::shared_ptr<ThisType> &rhs);
143 
144 protected:
145  LIB_UTILITIES_EXPORT virtual
146  typename boost::call_traits<NumberType>::value_type
147  v_GetValue(unsigned int row, unsigned int column) const override;
148 
149  LIB_UTILITIES_EXPORT virtual unsigned int v_GetStorageSize() const override;
150 
151  LIB_UTILITIES_EXPORT virtual char v_GetTransposeFlag() const override;
152 
153 private:
154  std::shared_ptr<const InnerType> m_matrix;
156 };
157 
158 template <typename DataType>
161 
162 template <typename DataType>
165 
166 } // namespace Nektar
167 
168 #endif // NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
#define LIB_UTILITIES_EXPORT
const_iterator(typename InnerType::const_iterator iter, const NumberType &scale)
static std::shared_ptr< ThisType > CreateWrapper(const std::shared_ptr< ThisType > &rhs)
std::remove_const< typename InnerType::NumberType >::type NumberType
NekMatrix(typename boost::call_traits< NumberType >::const_reference scale, const ThisType &rhs)
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void NegateInPlace(NekVector< DataType > &v)
Definition: NekVector.cpp:1160