5#ifndef DUNE_MULTIINDEX_HH
6#define DUNE_MULTIINDEX_HH
11#include <dune/common/ftraits.hh>
12#include <dune/common/fvector.hh>
25 template<
int dim,
class Field >
28 template<
int dim,
class Field >
36 template<
int dim,
class Field >
41 friend std::ostream &operator<<<> ( std::ostream &,
const This & );
61 : vecZ_( other.vecOMZ_ ),
62 vecOMZ_( other.vecZ_ ),
63 factor_( other.factor_ )
68 next_ =
new This( *(other.next_) );
75 : vecZ_( other.vecZ_ ),
76 vecOMZ_( other.vecOMZ_ ),
77 factor_( other.factor_ )
81 next_ =
new This( *(other.next_) );
109 vecOMZ_ = other.vecOMZ_;
110 factor_ = other.factor_;
112 next_ =
new This(*(other.next_));
137 factor_ = field_cast<Field>(f);
143 assert(!next_ && !other.next_);
144 return (vecZ_==other.vecZ_ && vecOMZ_==other.vecOMZ_ && factor_==other.factor_);
150 factor_ *= field_cast<Field>(f);
158 factor_ /= field_cast<Field>(f);
166 assert(!other.next_);
167 vecZ_ += other.vecZ_;
168 vecOMZ_ += other.vecOMZ_;
169 factor_ *= other.factor_;
176 assert(!other.next_);
177 vecZ_ -= other.vecZ_;
178 vecOMZ_ -= other.vecOMZ_;
179 factor_ /= other.factor_;
187 assert(!other.next_);
188 if (std::abs(other.factor_)<1e-10)
190 if (std::abs(factor_)<1e-10)
201 next_ =
new This(other);
205 factor_ += other.factor_;
210 assert(!other.next_);
217 next_ =
new This(other);
221 factor_ -= other.factor_;
260 void set (
int d,
int power = 1 )
269 ret += std::abs( vecZ_[ i ] );
277 ret += std::abs( vecOMZ_[ i ] );
285 if ( vecZ_[i] != ind.vecZ_[i] ||
286 vecOMZ_[i] != vecOMZ_[i] )
303 typedef Dune::FieldVector< int, dimension > Vector;
313 template<
int dim,
class Field >
317 using real_type =
typename FieldTraits<field_type>::real_type;
320 template <
int dim,
class Field,
class F>
327 template <
int dim,
class Field,
class F>
335 template <
int d,
class F>
337 for (
unsigned int r=0; r<y.size(); ++r) {
338 out <<
"f_{" << r <<
"}(" << char(
'a');
339 for (
int i=1; i<d; ++i)
340 out <<
"," <<
char(
'a'+i);
342 out << y[r] << std::endl;
346 template <
int d,
class F,
int dimR>
349 out <<
"\\begin{eqnarray*}" << std::endl;
350 for (
unsigned int k=0; k<y.size(); ++k) {
351 out <<
"f_{" << k <<
"}(" << char(
'a');
352 for (
int i=1; i<d; ++i)
353 out <<
"," <<
char(
'a'+i);
356 for (
unsigned int r=1; r<dimR; ++r) {
357 out <<
" , " << y[k][r] ;
359 out <<
" ) \\\\" << std::endl;
361 out <<
"\\end{eqnarray*}" << std::endl;
364 template <
int d,
class F,
int dimR1,
int dimR2>
366 const std::vector<Dune::FieldMatrix<
MultiIndex<d,F>,dimR1,dimR2> >& y) {
367 out <<
"\\begin{eqnarray*}" << std::endl;
368 for (
unsigned int k=0; k<y.size(); ++k) {
369 for (
int q=0; q<dimR2; q++) {
370 out <<
"d_{" << char(
'a'+q) <<
"}f_{" << k <<
"}(" << char(
'a');
371 for (
int i=1; i<d; ++i)
372 out <<
"," <<
char(
'a'+i);
375 for (
unsigned int r=1; r<dimR1; ++r) {
376 out <<
" , " << y[k][r][q] ;
378 out <<
" ) \\\\" << std::endl;
381 out <<
"\\end{eqnarray*}" << std::endl;
384 template <
int d,
class F>
390 if (m->
absZ()==0 && std::abs(m->
factor())<1e-10)
392 if (!m->next_ || !first)
402 if (m->
factor()>0 && !first)
412 F f = std::abs(m->
factor());
416 if ( std::abs(f)<1e-10)
422 if ( std::abs(f_1)>1e-10)
425 for (
int i=0; i<d; ++i) {
428 else if (m->vecZ_[i]==1)
430 else if (m->vecZ_[i]>0)
431 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
432 else if (m->vecZ_[i]<0)
433 out << char(
'a'+i) <<
"^" << m->vecZ_[i] <<
"";
434 absVal += m->vecZ_[i];
435 if (absVal<m->absZ()) out <<
"";
459 template<
int dim,
class F>
471 return Field( 1, other );
476 return Field() / other;
482 template<
int dim,
class F >
494 template<
int dim,
class Field >
500 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:151
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:38
This operator+(const This &other) const
Definition multiindex.hh:249
int absOMZ() const
Definition multiindex.hh:273
~MultiIndex()
Definition multiindex.hh:87
This & operator-=(const This &other)
Definition multiindex.hh:208
MultiIndex(int, const This &other)
Definition multiindex.hh:60
static const int dimension
Definition multiindex.hh:44
int absZ() const
Definition multiindex.hh:265
int omz(int i) const
Definition multiindex.hh:96
This & operator+=(const This &other)
Definition multiindex.hh:185
bool operator==(const This &other) const
Definition multiindex.hh:141
bool sameMultiIndex(const This &ind)
Definition multiindex.hh:281
This & operator=(const This &other)
Definition multiindex.hh:105
MultiIndex(const This &other)
Definition multiindex.hh:74
This & operator*=(const F &f)
Definition multiindex.hh:148
const Field & factor() const
Definition multiindex.hh:100
This operator/(const F &f) const
Definition multiindex.hh:232
MultiIndex(const F &f)
Definition multiindex.hh:53
This & operator/=(const F &f)
Definition multiindex.hh:156
This operator*(const F &f) const
Definition multiindex.hh:226
void set(int d, int power=1)
Definition multiindex.hh:260
This operator-(const This &other) const
Definition multiindex.hh:254
int z(int i) const
Definition multiindex.hh:92
MultiIndex()
Definition multiindex.hh:46
Field field_type
Definition multiindex.hh:316
typename FieldTraits< field_type >::real_type real_type
Definition multiindex.hh:317
MultiIndex< dim, F > Field
Definition multiindex.hh:462
MultiIndex< dim, F > Field
Definition multiindex.hh:485