3#ifndef DUNE_MULTIINDEX_HH
4#define DUNE_MULTIINDEX_HH
9#include <dune/common/fvector.hh>
22 template<
int dim,
class Field >
25 template<
int dim,
class Field >
33 template<
int dim,
class Field >
38 friend std::ostream &operator<<<> ( std::ostream &,
const This & );
58 : vecZ_( other.vecOMZ_ ),
59 vecOMZ_( other.vecZ_ ),
60 factor_( other.factor_ )
65 next_ =
new This( *(other.next_) );
72 : vecZ_( other.vecZ_ ),
73 vecOMZ_( other.vecOMZ_ ),
74 factor_( other.factor_ )
78 next_ =
new This( *(other.next_) );
106 vecOMZ_ = other.vecOMZ_;
107 factor_ = other.factor_;
109 next_ =
new This(*(other.next_));
134 factor_ = field_cast<Field>(f);
140 assert(!next_ && !other.next_);
141 return (vecZ_==other.vecZ_ && vecOMZ_==other.vecOMZ_ && factor_==other.factor_);
147 factor_ *= field_cast<Field>(f);
155 factor_ /= field_cast<Field>(f);
163 assert(!other.next_);
164 vecZ_ += other.vecZ_;
165 vecOMZ_ += other.vecOMZ_;
166 factor_ *= other.factor_;
173 assert(!other.next_);
174 vecZ_ -= other.vecZ_;
175 vecOMZ_ -= other.vecOMZ_;
176 factor_ /= other.factor_;
184 assert(!other.next_);
185 if (std::abs(other.factor_)<1e-10)
187 if (std::abs(factor_)<1e-10)
198 next_ =
new This(other);
202 factor_ += other.factor_;
207 assert(!other.next_);
214 next_ =
new This(other);
218 factor_ -= other.factor_;
257 void set (
int d,
int power = 1 )
266 ret += std::abs( vecZ_[ i ] );
274 ret += std::abs( vecOMZ_[ i ] );
282 if ( vecZ_[i] != ind.vecZ_[i] ||
283 vecOMZ_[i] != vecOMZ_[i] )
300 typedef Dune::FieldVector< int, dimension > Vector;
309 template <
int dim,
class Field,
class F>
316 template <
int dim,
class Field,
class F>
324 template <
int d,
class F>
326 for (
unsigned int r=0; r<y.size(); ++r) {
327 out <<
"f_{" << r <<
"}(" << char(
'a');
328 for (
int i=1; i<d; ++i)
329 out <<
"," <<
char(
'a'+i);
331 out << y[r] << std::endl;
335 template <
int d,
class F,
int dimR>
338 out <<
"\\begin{eqnarray*}" << std::endl;
339 for (
unsigned int k=0; k<y.size(); ++k) {
340 out <<
"f_{" << k <<
"}(" << char(
'a');
341 for (
int i=1; i<d; ++i)
342 out <<
"," <<
char(
'a'+i);
345 for (
unsigned int r=1; r<dimR; ++r) {
346 out <<
" , " << y[k][r] ;
348 out <<
" ) \\\\" << std::endl;
350 out <<
"\\end{eqnarray*}" << std::endl;
353 template <
int d,
class F,
int dimR1,
int dimR2>
355 const std::vector<Dune::FieldMatrix<
MultiIndex<d,F>,dimR1,dimR2> >& y) {
356 out <<
"\\begin{eqnarray*}" << std::endl;
357 for (
unsigned int k=0; k<y.size(); ++k) {
358 for (
int q=0; q<dimR2; q++) {
359 out <<
"d_{" << char(
'a'+q) <<
"}f_{" << k <<
"}(" << char(
'a');
360 for (
int i=1; i<d; ++i)
361 out <<
"," <<
char(
'a'+i);
364 for (
unsigned int r=1; r<dimR1; ++r) {
365 out <<
" , " << y[k][r][q] ;
367 out <<
" ) \\\\" << std::endl;
370 out <<
"\\end{eqnarray*}" << std::endl;
373 template <
int d,
class F>
379 if (m->
absZ()==0 && std::abs(m->
factor())<1e-10)
381 if (!m->next_ || !first)
391 if (m->
factor()>0 && !first)
401 F f = std::abs(m->
factor());
405 if ( std::abs(f)<1e-10)
411 if ( std::abs(f_1)>1e-10)
414 for (
int i=0; i<d; ++i) {
417 else if (m->vecZ_[i]==1)
419 else if (m->vecZ_[i]>0)
420 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
421 else if (m->vecZ_[i]<0)
422 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
423 absVal += m->vecZ_[i];
424 if (absVal<m->absZ()) out <<
"";
448 template<
int dim,
class F>
460 return Field( 1, other );
465 return Field() / other;
471 template<
int dim,
class F >
483 template<
int dim,
class Field >
489 template<
int dim,
class Field >
Definition: bdfmcube.hh:16
Field operator-(const Unity< Field > &u, const Field &f)
Definition: field.hh:42
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157
bool operator<(const Zero< Field > &, const Field &f)
Definition: field.hh:117
Field operator/(const Unity< Field > &u, const Field &f)
Definition: field.hh:54
std::ostream & operator<<(std::ostream &out, const LFEMatrix< Field > &mat)
Definition: lfematrix.hh:150
Field operator*(const Unity< Field > &u, const Field &f)
Definition: field.hh:48
A class representing the unit of a given Field.
Definition: field.hh:28
A class representing the zero of a given Field.
Definition: field.hh:77
Definition: multiindex.hh:35
This operator+(const This &other) const
Definition: multiindex.hh:246
int absOMZ() const
Definition: multiindex.hh:270
~MultiIndex()
Definition: multiindex.hh:84
This & operator-=(const This &other)
Definition: multiindex.hh:205
MultiIndex(int, const This &other)
Definition: multiindex.hh:57
static const int dimension
Definition: multiindex.hh:41
int absZ() const
Definition: multiindex.hh:262
int omz(int i) const
Definition: multiindex.hh:93
This & operator+=(const This &other)
Definition: multiindex.hh:182
bool operator==(const This &other) const
Definition: multiindex.hh:138
bool sameMultiIndex(const This &ind)
Definition: multiindex.hh:278
This & operator=(const This &other)
Definition: multiindex.hh:102
MultiIndex(const This &other)
Definition: multiindex.hh:71
This & operator*=(const F &f)
Definition: multiindex.hh:145
const Field & factor() const
Definition: multiindex.hh:97
This operator/(const F &f) const
Definition: multiindex.hh:229
MultiIndex(const F &f)
Definition: multiindex.hh:50
This & operator/=(const F &f)
Definition: multiindex.hh:153
This operator*(const F &f) const
Definition: multiindex.hh:223
void set(int d, int power=1)
Definition: multiindex.hh:257
This operator-(const This &other) const
Definition: multiindex.hh:251
int z(int i) const
Definition: multiindex.hh:89
MultiIndex()
Definition: multiindex.hh:43
MultiIndex< dim, F > Field
Definition: multiindex.hh:451
MultiIndex< dim, F > Field
Definition: multiindex.hh:474