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> : public ConstMatrix<DataType>
47  {
48  public:
52  typedef typename std::remove_const<typename InnerType::NumberType>::type NumberType;
53 
56 
57  public:
58  /// \internal
59  /// \brief Iterator through elements of the matrix.
60  /// Not quite a real iterator in the C++ sense.
61  class const_iterator
62  {
63  public:
64  const_iterator(typename InnerType::const_iterator iter,
65  const NumberType& scale) :
66  m_iter(iter),
67  m_scale(scale)
68  {
69  }
70 
71  const_iterator operator++(int)
72  {
73  const_iterator out = *this;
74  ++m_iter;
75  return out;
76  }
77 
78  const_iterator& operator++()
79  {
80  ++m_iter;
81  return *this;
82  }
83 
85  {
86  return m_scale*(*m_iter);
87  }
88 
89  bool operator==(const const_iterator& rhs)
90  {
91  return m_iter == rhs.m_iter;
92  }
93 
94  bool operator!=(const const_iterator& rhs)
95  {
96  return !(*this == rhs);
97  }
98 
99  private:
100  typename InnerType::const_iterator m_iter;
102  };
103 
104 
105 
106  public:
108 
109  LIB_UTILITIES_EXPORT NekMatrix(typename boost::call_traits<NumberType>::const_reference scale,
110  std::shared_ptr<const InnerType> m);
111 
113 
114 
115  LIB_UTILITIES_EXPORT NekMatrix(typename boost::call_traits<NumberType>::const_reference scale, const ThisType& rhs);
116 
117 
119 
120  LIB_UTILITIES_EXPORT ConstGetValueType operator()(unsigned int row, unsigned int col) const;
121 
122  LIB_UTILITIES_EXPORT unsigned int GetStorageSize() const ;
123 
124  LIB_UTILITIES_EXPORT NumberType Scale() const;
125  LIB_UTILITIES_EXPORT void SetScale(const NumberType&);
126 
127  LIB_UTILITIES_EXPORT const NumberType* GetRawPtr() const;
128 
129  LIB_UTILITIES_EXPORT std::shared_ptr<const InnerType> GetOwnedMatrix() const;
130 
131  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSubDiagonals() const;
132  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSuperDiagonals() const;
133 
134  LIB_UTILITIES_EXPORT const_iterator begin() const;
135  LIB_UTILITIES_EXPORT const_iterator end() const;
136 
138 
139  LIB_UTILITIES_EXPORT static std::shared_ptr<ThisType> CreateWrapper(const std::shared_ptr<ThisType>& rhs);
140 
141  public:
142 
143  private:
144  LIB_UTILITIES_EXPORT virtual typename boost::call_traits<NumberType>::value_type
145  v_GetValue(unsigned int row, unsigned int column) const;
146 
147  LIB_UTILITIES_EXPORT virtual unsigned int v_GetStorageSize() const ;
148 
149  LIB_UTILITIES_EXPORT virtual char v_GetTransposeFlag() const;
150 
151  std::shared_ptr<const InnerType> m_matrix;
153  };
154 
155  template<typename DataType>
157 
158  template<typename DataType>
161 
162 }
163 
164 
165 #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:1
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void NegateInPlace(NekVector< DataType > &v)
Definition: NekVector.cpp:1184