5#ifndef DUNE_MULTIINDEX_HH
6#define DUNE_MULTIINDEX_HH
11#include <dune/common/fvector.hh>
24 template<
int dim,
class Field >
27 template<
int dim,
class Field >
35 template<
int dim,
class Field >
40 friend std::ostream &operator<<<> ( std::ostream &,
const This & );
60 : vecZ_( other.vecOMZ_ ),
61 vecOMZ_( other.vecZ_ ),
62 factor_( other.factor_ )
67 next_ =
new This( *(other.next_) );
74 : vecZ_( other.vecZ_ ),
75 vecOMZ_( other.vecOMZ_ ),
76 factor_( other.factor_ )
80 next_ =
new This( *(other.next_) );
108 vecOMZ_ = other.vecOMZ_;
109 factor_ = other.factor_;
111 next_ =
new This(*(other.next_));
136 factor_ = field_cast<Field>(f);
142 assert(!next_ && !other.next_);
143 return (vecZ_==other.vecZ_ && vecOMZ_==other.vecOMZ_ && factor_==other.factor_);
149 factor_ *= field_cast<Field>(f);
157 factor_ /= field_cast<Field>(f);
165 assert(!other.next_);
166 vecZ_ += other.vecZ_;
167 vecOMZ_ += other.vecOMZ_;
168 factor_ *= other.factor_;
175 assert(!other.next_);
176 vecZ_ -= other.vecZ_;
177 vecOMZ_ -= other.vecOMZ_;
178 factor_ /= other.factor_;
186 assert(!other.next_);
187 if (std::abs(other.factor_)<1e-10)
189 if (std::abs(factor_)<1e-10)
200 next_ =
new This(other);
204 factor_ += other.factor_;
209 assert(!other.next_);
216 next_ =
new This(other);
220 factor_ -= other.factor_;
259 void set (
int d,
int power = 1 )
268 ret += std::abs( vecZ_[ i ] );
276 ret += std::abs( vecOMZ_[ i ] );
284 if ( vecZ_[i] != ind.vecZ_[i] ||
285 vecOMZ_[i] != vecOMZ_[i] )
302 typedef Dune::FieldVector< int, dimension > Vector;
311 template <
int dim,
class Field,
class F>
318 template <
int dim,
class Field,
class F>
326 template <
int d,
class F>
328 for (
unsigned int r=0; r<y.size(); ++r) {
329 out <<
"f_{" << r <<
"}(" << char(
'a');
330 for (
int i=1; i<d; ++i)
331 out <<
"," <<
char(
'a'+i);
333 out << y[r] << std::endl;
337 template <
int d,
class F,
int dimR>
340 out <<
"\\begin{eqnarray*}" << std::endl;
341 for (
unsigned int k=0; k<y.size(); ++k) {
342 out <<
"f_{" << k <<
"}(" << char(
'a');
343 for (
int i=1; i<d; ++i)
344 out <<
"," <<
char(
'a'+i);
347 for (
unsigned int r=1; r<dimR; ++r) {
348 out <<
" , " << y[k][r] ;
350 out <<
" ) \\\\" << std::endl;
352 out <<
"\\end{eqnarray*}" << std::endl;
355 template <
int d,
class F,
int dimR1,
int dimR2>
357 const std::vector<Dune::FieldMatrix<
MultiIndex<d,F>,dimR1,dimR2> >& y) {
358 out <<
"\\begin{eqnarray*}" << std::endl;
359 for (
unsigned int k=0; k<y.size(); ++k) {
360 for (
int q=0; q<dimR2; q++) {
361 out <<
"d_{" << char(
'a'+q) <<
"}f_{" << k <<
"}(" << char(
'a');
362 for (
int i=1; i<d; ++i)
363 out <<
"," <<
char(
'a'+i);
366 for (
unsigned int r=1; r<dimR1; ++r) {
367 out <<
" , " << y[k][r][q] ;
369 out <<
" ) \\\\" << std::endl;
372 out <<
"\\end{eqnarray*}" << std::endl;
375 template <
int d,
class F>
381 if (m->
absZ()==0 && std::abs(m->
factor())<1e-10)
383 if (!m->next_ || !first)
393 if (m->
factor()>0 && !first)
403 F f = std::abs(m->
factor());
407 if ( std::abs(f)<1e-10)
413 if ( std::abs(f_1)>1e-10)
416 for (
int i=0; i<d; ++i) {
419 else if (m->vecZ_[i]==1)
421 else if (m->vecZ_[i]>0)
422 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
423 else if (m->vecZ_[i]<0)
424 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
425 absVal += m->vecZ_[i];
426 if (absVal<m->absZ()) out <<
"";
450 template<
int dim,
class F>
462 return Field( 1, other );
467 return Field() / other;
473 template<
int dim,
class F >
485 template<
int dim,
class Field >
491 template<
int dim,
class Field >
Definition bdfmcube.hh:18
Field operator-(const Unity< Field > &u, const Field &f)
Definition field.hh:44
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition field.hh:159
bool operator<(const Zero< Field > &, const Field &f)
Definition field.hh:119
Field operator/(const Unity< Field > &u, const Field &f)
Definition field.hh:56
std::ostream & operator<<(std::ostream &out, const LFEMatrix< Field > &mat)
Definition lfematrix.hh:152
Field operator*(const Unity< Field > &u, const Field &f)
Definition field.hh:50
A class representing the unit of a given Field.
Definition field.hh:30
A class representing the zero of a given Field.
Definition field.hh:79
Definition multiindex.hh:37
This operator+(const This &other) const
Definition multiindex.hh:248
int absOMZ() const
Definition multiindex.hh:272
~MultiIndex()
Definition multiindex.hh:86
This & operator-=(const This &other)
Definition multiindex.hh:207
MultiIndex(int, const This &other)
Definition multiindex.hh:59
static const int dimension
Definition multiindex.hh:43
int absZ() const
Definition multiindex.hh:264
int omz(int i) const
Definition multiindex.hh:95
This & operator+=(const This &other)
Definition multiindex.hh:184
bool operator==(const This &other) const
Definition multiindex.hh:140
bool sameMultiIndex(const This &ind)
Definition multiindex.hh:280
This & operator=(const This &other)
Definition multiindex.hh:104
MultiIndex(const This &other)
Definition multiindex.hh:73
This & operator*=(const F &f)
Definition multiindex.hh:147
const Field & factor() const
Definition multiindex.hh:99
This operator/(const F &f) const
Definition multiindex.hh:231
MultiIndex(const F &f)
Definition multiindex.hh:52
This & operator/=(const F &f)
Definition multiindex.hh:155
This operator*(const F &f) const
Definition multiindex.hh:225
void set(int d, int power=1)
Definition multiindex.hh:259
This operator-(const This &other) const
Definition multiindex.hh:253
int z(int i) const
Definition multiindex.hh:91
MultiIndex()
Definition multiindex.hh:45
MultiIndex< dim, F > Field
Definition multiindex.hh:453
MultiIndex< dim, F > Field
Definition multiindex.hh:476