2 #ifndef DUNE_MONOMLOCALBASIS_HH
3 #define DUNE_MONOMLOCALBASIS_HH
7 #include <dune/common/fmatrix.hh>
9 #include"../common/localbasis.hh"
17 template<
int d,
int k>
49 template <
typename Traits>
51 std::vector<typename Traits::RangeType> &out;
53 unsigned int first_unused_index;
57 EvalAccess(std::vector<typename Traits::RangeType> &out_)
60 , first_unused_index(0)
65 assert(first_unused_index == out.size());
68 typename Traits::RangeFieldType &
operator[](
unsigned int index)
70 assert(index < out.size());
72 if(first_unused_index <= index)
73 first_unused_index = index+1;
80 template <
typename Traits>
82 std::vector<typename Traits::JacobianType> &out;
85 unsigned int first_unused_index;
91 : out(out_), row(row_)
93 , first_unused_index(0)
98 assert(first_unused_index == out.size());
101 typename Traits::RangeFieldType &
operator[](
unsigned int index)
103 assert(index < out.size());
105 if(first_unused_index <= index)
106 first_unused_index = index+1;
108 return out[index][0][row];
124 template <
typename Traits,
int c>
129 d = Traits::dimDomain - c
137 template <
typename Access>
139 const typename Traits::DomainType &in,
142 const array<int, Traits::dimDomain> &derivatives,
145 typename Traits::RangeFieldType prod,
154 for (
int e = bound; e >= 0; --e)
158 int newbound = bound - e;
159 if(e < derivatives[
d])
161 eval(in, derivatives, 0, newbound, index, access);
164 for(
int i = e - derivatives[d] + 1; i <= e; ++i)
172 prod *
ipow(in[d], e-derivatives[d]) * coeff,
188 template <
typename Traits>
191 enum {
d = Traits::dimDomain-1 };
193 template <
typename Access>
194 static void eval (
const typename Traits::DomainType &in,
195 const array<int, Traits::dimDomain> &derivatives,
196 typename Traits::RangeFieldType prod,
197 int bound,
int& index, Access &access)
199 if(bound < derivatives[
d])
203 for(
int i = bound - derivatives[d] + 1; i <= bound; ++i)
205 prod *=
ipow(in[d], bound-derivatives[d]) * coeff;
207 access[index] = prod;
228 template<
class D,
class R,
unsigned int d,
unsigned int p,
unsigned diffOrder = p>
236 Dune::FieldMatrix<R,1,d>,diffOrder>
Traits;
246 std::vector<typename Traits::RangeType>& out)
const
248 evaluate<0>(array<int, 0>(), in, out);
252 template<
unsigned int k>
253 inline void evaluate (
const array<int,k>& directions,
255 std::vector<typename Traits::RangeType>& out)
const
259 array<int, d> derivatives;
260 for(
unsigned int i = 0; i < d; ++i) derivatives[i] = 0;
261 for(
unsigned int i = 0; i < k; ++i) ++derivatives[directions[i]];
263 for(
unsigned int lp = 0; lp <= p; ++lp)
271 std::vector<typename Traits::JacobianType>& out)
const
274 array<int, d> derivatives;
275 for(
unsigned int i = 0; i < d; ++i)
277 for(
unsigned int i = 0; i < d; ++i)
282 for(
unsigned int lp = 0; lp <= p; ++lp)
297 #endif // DUNE_MONOMLOCALBASIS_HH