Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description:
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
37 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
38 
40 
43 
44 #include <boost/shared_ptr.hpp>
45 
46 namespace Nektar
47 {
48  template<typename DataType, typename InnerMatrixType>
49  class NekMatrix<NekMatrix<DataType, InnerMatrixType>, ScaledMatrixTag> : public ConstMatrix<DataType>
50  {
51  public:
55  typedef typename boost::remove_const<typename InnerType::NumberType>::type NumberType;
56 
57  typedef NumberType GetValueType;
58  typedef NumberType ConstGetValueType;
59 
60  public:
61  /// \internal
62  /// \brief Iterator through elements of the matrix.
63  /// Not quite a real iterator in the C++ sense.
64  class const_iterator
65  {
66  public:
67  const_iterator(typename InnerType::const_iterator iter,
68  const NumberType& scale) :
69  m_iter(iter),
70  m_scale(scale)
71  {
72  }
73 
74  const_iterator operator++(int)
75  {
76  const_iterator out = *this;
77  ++m_iter;
78  return out;
79  }
80 
81  const_iterator& operator++()
82  {
83  ++m_iter;
84  return *this;
85  }
86 
87  NumberType operator*()
88  {
89  return m_scale*(*m_iter);
90  }
91 
92  bool operator==(const const_iterator& rhs)
93  {
94  return m_iter == rhs.m_iter;
95  }
96 
97  bool operator!=(const const_iterator& rhs)
98  {
99  return !(*this == rhs);
100  }
101 
102  private:
103  typename InnerType::const_iterator m_iter;
104  NumberType m_scale;
105  };
106 
107 
108 
109  public:
111 
112  LIB_UTILITIES_EXPORT NekMatrix(typename boost::call_traits<NumberType>::const_reference scale,
113  boost::shared_ptr<const InnerType> m);
114 
115  LIB_UTILITIES_EXPORT NekMatrix(const ThisType& rhs);
116 
117 
118  LIB_UTILITIES_EXPORT NekMatrix(typename boost::call_traits<NumberType>::const_reference scale, const ThisType& rhs);
119 
120 
121  LIB_UTILITIES_EXPORT ConstGetValueType operator()(unsigned int row, unsigned int col) const;
122 
123  LIB_UTILITIES_EXPORT unsigned int GetStorageSize() const ;
124 
125  LIB_UTILITIES_EXPORT MatrixStorage GetType() const;
126 
127  LIB_UTILITIES_EXPORT NumberType Scale() const;
128  LIB_UTILITIES_EXPORT void SetScale(const NumberType&);
129 
130  LIB_UTILITIES_EXPORT const NumberType* GetRawPtr() const;
131 
132  LIB_UTILITIES_EXPORT boost::shared_ptr<const InnerType> GetOwnedMatrix() const;
133 
134  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSubDiagonals() const;
135  LIB_UTILITIES_EXPORT unsigned int GetNumberOfSuperDiagonals() const;
136 
137  LIB_UTILITIES_EXPORT const_iterator begin() const;
138  LIB_UTILITIES_EXPORT const_iterator end() const;
139 
140  LIB_UTILITIES_EXPORT static ThisType CreateWrapper(const ThisType& rhs);
141 
142  LIB_UTILITIES_EXPORT static boost::shared_ptr<ThisType> CreateWrapper(const boost::shared_ptr<ThisType>& rhs);
143 
144  public:
145 
146  private:
147  LIB_UTILITIES_EXPORT virtual typename boost::call_traits<NumberType>::value_type
148  v_GetValue(unsigned int row, unsigned int column) const;
149 
150  LIB_UTILITIES_EXPORT virtual unsigned int v_GetStorageSize() const ;
151 
152  LIB_UTILITIES_EXPORT virtual MatrixStorage v_GetStorageType() const;
153 
154  LIB_UTILITIES_EXPORT virtual char v_GetTransposeFlag() const;
155 
156  boost::shared_ptr<const InnerType> m_matrix;
157  NumberType m_scale;
158  };
159 
160  template<typename DataType>
162 
163  template<typename DataType>
166 
167 }
168 
169 
170 #endif //NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_SCALED_MATRIX_HPP
boost::remove_const< typename InnerType::NumberType >::type NumberType
const_iterator(typename InnerType::const_iterator iter, const NumberType &scale)
#define LIB_UTILITIES_EXPORT
NekMatrix< InnerMatrixType, BlockMatrixTag > Transpose(NekMatrix< InnerMatrixType, BlockMatrixTag > &rhs)
void NegateInPlace(NekVector< DataType > &v)
Definition: NekVector.cpp:962