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
fmspoint.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): Christoph Winkelmann <christoph.winkelmann@epfl.ch>
6  Date: 2006-10-23
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 __Fms_Point_H
30 #define __Fms_Point_H 1
31 
32 #include <boost/numeric/ublas/storage.hpp>
33 
34 namespace Feel
35 {
36 namespace details
37 {
38 
39 template<typename T, uint16_type Dim>
40 class FmsPoint
41  : public boost::numeric::ublas::bounded_array<T, Dim>
42 {
43 public:
44  typedef T value_type;
45  static const uint16_type dim = Dim;
46  typedef boost::numeric::ublas::bounded_array<T, Dim> super;
47  FmsPoint()
48  : super( dim, value_type(0.0) ) {}
49  FmsPoint( FmsPoint const& init )
50  : super( init )
51  {}
52  FmsPoint<T, Dim>& operator=( FmsPoint<T, Dim> r )
53  {
54  ((super*)this)->operator=( (super)r );
55  return *this;
56  }
57  void operator+=( FmsPoint<T, Dim> const& s )
58  {
59  for (uint16_type i=0; i<dim; ++i)
60  this->operator[]( i ) += s[i];
61  }
62  void operator-=( FmsPoint<T, Dim> const& s )
63  {
64  for (uint16_type i=0; i<dim; ++i)
65  this->operator[]( i ) -= s[i];
66  }
67  void operator*=( value_type f )
68  {
69  for (uint16_type i=0; i<dim; ++i)
70  this->operator[]( i ) *= f;
71  }
72 }; // class FmsPoint
73 
74 template<typename T, uint16_type Dim>
75 FmsPoint<T, Dim> operator-( FmsPoint<T, Dim> const& m,
76  FmsPoint<T, Dim> const& s )
77 {
78  FmsPoint<T, Dim> d(m);
79  d -= s;
80  return d;
81 }
82 
83 template<typename T, uint16_type Dim>
84 T dot( FmsPoint<T, Dim> const& a,
85  FmsPoint<T, Dim> const& b )
86 {
87  T retval(0.0);
88  for (uint16_type i=0; i<Dim; ++i)
89  retval += a[i]*b[i];
90  return retval;
91 }
92 
93 template<typename T, uint16_type Dim>
94 FmsPoint<T, Dim> operator*( FmsPoint<T, Dim> const& a, T f )
95 {
96  FmsPoint<T, Dim> retval( a );
97  retval *= f;
98  return retval;
99 }
100 
101 template<typename T, uint16_type Dim>
102 FmsPoint<T, Dim> operator*( T f, FmsPoint<T, Dim> const& a )
103 {
104  FmsPoint<T, Dim> retval( a );
105  retval *= f;
106  return retval;
107 }
108 
109 template<typename T, uint16_type Dim>
110 T norm( FmsPoint<T, Dim> const& a )
111 {
112  T norm2( dot(a,a) );
113  return std::sqrt( norm2 );
114 }
115 
116 } // namespace details
117 
118 } // namespace Feel
119 
120 
121 #endif /* __Fms_Point_H */
122 

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