Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
functional.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2005-10-06
7 
8  Copyright (C) 2005-2006 EPFL
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 3.0 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __Functional_H
30 #define __Functional_H 1
31 
32 #include <boost/operators.hpp>
33 #include <boost/numeric/ublas/vector_proxy.hpp>
34 #include <boost/numeric/ublas/matrix_proxy.hpp>
35 
36 #include <feel/feelcore/feel.hpp>
37 
38 
39 namespace Feel
40 {
41 namespace ublas = boost::numeric::ublas;
42 
54 template<typename Space>
55 class Functional
56  :
57 public boost::addable<Functional<Space> >
58 {
59  typedef boost::addable<Functional<Space> > super;
60 public:
61 
62 
66 
67  typedef typename Space::value_type value_type;
68  typedef Functional<Space> self_type;
69  typedef Space space_type;
70  typedef Space polynomialset_type;
71  typedef typename space_type::polynomial_type polynomial_type;
72  typedef typename space_type::basis_type basis_type;
73  typedef typename space_type::matrix_type matrix_type;
74 
75  static const uint16_type nComponents = space_type::nComponents;
76 
77  // representation type for the functionals
78  typedef ublas::matrix<value_type> rep_type;
79 
81 
85 
86  Functional()
87  :
88  super(),
89  M_p(),
90  M_coeff()
91  {}
92 
93  Functional( space_type const& P )
94  :
95  super(),
96  M_p( P ),
97  M_coeff( M_p.coeff() )
98 
99  {
100 
101  }
102 
103  //template<class AE>
104  Functional( space_type const& P,
105  matrix_type const& coeff )
106  //ublas::matrix_expression<AE> const& coeff )
107  :
108  super(),
109  M_p( P ),
110  M_coeff( coeff )
111  {
112  //FEELPP_ASSERT( M_coeff.size1() == nComponents && M_coeff.size2() == M_p.polynomialDimensionPerComponent() )
113  //( M_coeff.size1() )( M_coeff.size2() )( M_p.polynomialDimension() ).error( "invalid coefficient size" );
114  // FEELPP_ASSERT( M_coeff.size2() == 1 )( M_coeff.size2() ).error( "there should be only one column" );
115  }
116 
117  Functional( Functional const & __f )
118  :
119  M_p( __f.M_p ),
120  M_coeff( __f.M_coeff )
121  {
122  //FEELPP_ASSERT( M_coeff.size1() == nComponents && M_coeff.size2() == M_p.polynomialDimensionPerComponent() )
123  //( M_coeff.size1() )( M_coeff.size2() )( M_p.polynomialDimensionPerComponent() ).error( "invalid coefficient size" );
124  }
125 
126  virtual ~Functional()
127  {}
128 
130 
134 
135  self_type& operator=( self_type const& __f )
136  {
137  if ( this != &__f )
138  {
139  M_p = __f.M_p;
140  M_coeff = __f.M_coeff;
141  }
142 
143  return *this;
144  }
145 
151  {
152  M_coeff += __f.M_coeff;
153  return *this;
154  }
155 
163  virtual matrix_type operator()( polynomial_type const& p ) const
164  {
165  FEELPP_ASSERT( p.coeff().size2() == M_coeff.size2() )
166  ( p.coeff() )( M_coeff ).error( "invalid polynomial" );
167 
168  return ublas::prod( p.coeff(), ublas::trans( M_coeff ) );
169  }
170 
172 
176 
180  uint16_type size() const
181  {
182  return M_coeff.size2();
183  }
184 
189  rep_type const& coeff() const
190  {
191  return M_coeff;
192  }
193 
195 
199 
200  //template<class AE>
201  //void setCoefficient( ublas::matrix_expression<AE> const& __coeff )
202  void setCoefficient( matrix_type const& __coeff )
203  {
204  M_coeff = __coeff;
205  }
206 
207 
209 
213 
214 
216 
217 
218 
219 protected:
220 
221 private:
222  space_type M_p;
223  rep_type M_coeff;
224 };
225 
226 }
227 #endif /* __Functional_H */

Generated on Fri Oct 25 2013 14:24:11 for Feel++ by doxygen 1.8.4