INMOST
A toolkit for distributed mathematical modeling
inmost_block_variable.h
1 
2 #ifndef INMOST_AUTODIFF_ETBVAR_H_INCLUDED
3 #define INMOST_AUTODIFF_ETBVAR_H_INCLUDED
4 #include "inmost_common.h"
5 #include "inmost_expression.h"
6 #include "inmost_mesh.h"
7 #include "inmost_autodiff.h"
8 #include "inmost_solver.h"
9 #include "inmost_variable.h"
10 #include <sstream> //for debug
11 #include <new>
12 
13 #if defined(USE_AUTODIFF) && defined(USE_MESH)
14 
15 //TODO:
16 // 1. Add operations ConcatRows, ConcatCols that help assemble matrix from pieces
17 
18 
19 //This should stop Visual Studio from complaining of very long auto-generated class types
20 #ifdef _MSC_VER
21 #pragma warning(disable : 4503)
22 #endif
23 
24 
25 
26 namespace INMOST
27 {
28 
30  {
31  public:
32  virtual rMatrix Value (const Storage & e) const = 0;
33  virtual vMatrix Variable(const Storage & e) const = 0;
34  virtual abstract_dynamic_block_variable * Copy() const = 0;
36  };
37 
38  template<typename RetType>
40  {
41  public:
42  virtual RetType operator()(const Storage & e) const = 0;
43  };
44 
45  template<>
47  {
49  public:
50  typedef vMatrix type;
51  get_block_variable(const abstract_dynamic_block_variable & var) : var(var) {}
52  vMatrix operator()(const Storage & e) const {return var.Variable(e);}
53  };
54 
55  template<>
56  class get_block_variable<INMOST_DATA_REAL_TYPE>
57  {
59  public:
60  typedef rMatrix type;
61  get_block_variable(const abstract_dynamic_block_variable & var) : var(var) {}
62  rMatrix operator()(const Storage & e) const {return var.Value(e);}
63  };
64 
65 
67  {
69  public:
70  stored_block_variable_expression() : var(NULL) {}
71  stored_block_variable_expression(const abstract_dynamic_block_variable & pvar) : var(pvar.Copy()) {}
72  stored_block_variable_expression(const stored_block_variable_expression & other) : var(other.var->Copy()) {}
73  ~stored_block_variable_expression() {delete var; var = NULL;}
74  stored_block_variable_expression operator =(stored_block_variable_expression const & other) {var = other.var->Copy(); return *this;}
75  stored_block_variable_expression operator =(const abstract_dynamic_block_variable & pvar) {var = pvar.Copy(); return *this;}
76  rMatrix Value(const Storage & e) const {return var->Value(e);}
77  vMatrix Variable(const Storage & e) const {return var->Variable(e);}
78 
79  template<typename T>
81  abstract_dynamic_block_variable & retrieve_expression() {return *var;}
82  const abstract_dynamic_block_variable & retrieve_expression() const {return *var;}
85  bool isDefined() const {return var != NULL;}
86  };
87 
88 
90  {
91  private:
92  const AbstractEntry * entry;
93  public:
94  dynamic_block_variable() :entry(NULL) {}
95  dynamic_block_variable(Automatizator & aut, INMOST_DATA_ENUM_TYPE reg_index) : entry(reg_index==ENUMUNDEF?NULL:&aut.GetEntry(reg_index)) {}
96  dynamic_block_variable(const AbstractEntry * re) : entry(re) {}
97  dynamic_block_variable(const dynamic_block_variable & other) : entry(other.entry) {}
98  dynamic_block_variable & operator =(const dynamic_block_variable & other)
99  {
100  entry = other.entry;
101  return * this;
102  }
103  rMatrix Value(const Storage & e) const {return entry->Value(e);}
104  //iMatrix Index(const Storage & e) const {return entry->isValid(e) ? entry->Index(e):iMatrix(entry->MatrixSize(e),1,ENUMUNDEF);}
105  vMatrix Variable(const Storage & e) const {return entry->Unknown(e);}
106  bool isUnknown(const Storage & e) const {return entry->isValid(e)?true:false;}
107  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new dynamic_block_variable(*this));}
108  };
109 
111  {
112  private:
113  rMatrix value;
114  public:
115  const_block_variable(const rMatrix & _value) : value(_value) {}
116  const_block_variable(const const_block_variable & other) : value(other.value) {}
117  const_block_variable & operator =(const const_block_variable & other)
118  {
119  value = other.value;
120  return * this;
121  }
122  rMatrix Value(const Storage & e) const {(void)e; return value;}
123  vMatrix Variable(const Storage & e) const {(void)e; return value;}
124  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new const_block_variable(*this));}
125  };
126 
128  {
129  private:
130  TagRealArray value_tag;
131  INMOST_DATA_ENUM_TYPE n,m;
132  public:
134  : value_tag(t), n(t.GetSize()), m(1) {assert(t.GetDataType() == DATA_REAL);}
135  static_block_variable(TagRealArray t, INMOST_DATA_ENUM_TYPE pn, INMOST_DATA_ENUM_TYPE pm)
136  : value_tag(t), n(pn), m(pm) {assert(t.GetDataType() == DATA_REAL);}
138  : value_tag(other.value_tag), n(other.n), m(other.m) {}
139  static_block_variable & operator =(const static_block_variable & other)
140  {
141  value_tag = other.value_tag;
142  n = other.n;
143  m = other.m;
144  return * this;
145  }
146  rMatrix Value(const Storage & e) const {return value_tag(e,n,m);}
147  vMatrix Variable(const Storage & e) const {return value_tag(e,n,m);}
148  TagRealArray ValueTag() {return value_tag;}
149  bool isUnknown(const Storage & e) const {(void)e; return false;}
150  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new static_block_variable(*this));}
151  };
152 
154  {
155  private:
156  TagVariableArray variable_tag;
157  INMOST_DATA_ENUM_TYPE n,m;
158  public:
160  : variable_tag(t), n(t.GetSize()), m(1) {}
161  stored_block_variable(TagVariableArray t, INMOST_DATA_ENUM_TYPE pn, INMOST_DATA_ENUM_TYPE pm)
162  : variable_tag(t), n(pn), m(pm) {assert(t.GetDataType() == DATA_VARIABLE);}
164  : variable_tag(other.variable_tag), n(other.n), m(other.m) {}
165  stored_block_variable & operator =(const stored_block_variable & other)
166  {
167  variable_tag = other.variable_tag;
168  n = other.n;
169  m = other.m;
170  return * this;
171  }
172  rMatrix Value(const Storage & e) const { return variable_tag(e,n,m);}
173  vMatrix Variable(const Storage & e) const { return variable_tag(e,n,m);}
174  TagVariableArray VariableTag() {return variable_tag;}
175  bool isUnknown(const Storage & e) const {(void)e; return false;}
176  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new stored_block_variable(*this));}
177  };
178 
179 
182  {
183  private:
184  TagReferenceArray tag_elems;
185  TagRealArray tag_coefs;
187  public:
188  stencil_block_variable(Tag tag_elems, Tag tag_coefs, const abstract_dynamic_block_variable & parg)
189  : tag_elems(tag_elems), tag_coefs(tag_coefs), Arg(parg) {}
191  : tag_elems(other.tag_elems), tag_coefs(other.tag_coefs), Arg(other.Arg) {}
192  stencil_block_variable & operator =(const stencil_block_variable & other)
193  {
194  tag_elems = other.tag_elems;
195  tag_coefs = other.tag_coefs;
196  Arg = other.Arg;
197  return * this;
198  }
199  rMatrix Value(const Storage & e) const
200  {
201  Storage::real_array coefs = tag_coefs[e];
202  Storage::reference_array elems = tag_elems[e];
203  assert(coefs.size() == elems.size());
204  rMatrix ret = coefs[0]*Arg.Value(elems[0]);
205  for(INMOST_DATA_ENUM_TYPE k = 1; k < elems.size(); ++k)
206  ret += coefs[k]*Arg.Value(elems[k]);
207  return ret;
208  }
209  vMatrix Variable(const Storage & e) const
210  {
211  Storage::real_array coefs = tag_coefs[e];
212  Storage::reference_array elems = tag_elems[e];
213  assert(coefs.size() == elems.size());
214  vMatrix ret = coefs[0]*Arg.Variable(elems[0]);
215  for(INMOST_DATA_ENUM_TYPE k = 1; k < elems.size(); ++k)
216  ret += coefs[k]*Arg.Variable(elems[k]);
217  return ret;
218  }
219  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new stencil_block_variable(*this));}
220  };
221 
224  {
226  keyval_table Table;
227  public:
228  table_block_variable(const abstract_dynamic_block_variable & parg, const keyval_table & ptable) : Arg(parg), Table(ptable) {}
229  table_block_variable(const table_block_variable & other) : Arg(other.Arg), Table(other.Table) {}
230  table_block_variable & operator = (table_block_variable const & other) {Arg = other.Arg; Table = other.Table; return * this;}
231  rMatrix Value(const Storage & e) const
232  {
233  rMatrix ret = Arg.Value(e);
234  for(INMOST_DATA_ENUM_TYPE k = 0; k < ret.Rows(); ++k)
235  for(INMOST_DATA_ENUM_TYPE l = 0; l < ret.Cols(); ++l)
236  ret(k,l) = get_table(ret(k,l),Table);
237  return ret;
238  }
239  vMatrix Variable(const Storage & e) const
240  {
241  vMatrix ret = Arg.Variable(e);
242  for(INMOST_DATA_ENUM_TYPE k = 0; k < ret.Rows(); ++k)
243  for(INMOST_DATA_ENUM_TYPE l = 0; l < ret.Cols(); ++l)
244  ret(k,l) = get_table(ret(k,l),Table);
245  return ret;
246  }
247  abstract_dynamic_block_variable * Copy() const {return static_cast<abstract_dynamic_block_variable *>(new table_block_variable(*this));}
248  };
249 
253  {
254  private:
255  stored_block_variable_expression ArgA; //< Variable expression to be evaluated when type of provided element matches selected types.
256  stored_block_variable_expression ArgB; //< Variable expression to be evaluated when type of provided element does not match selected types.
257  ElementType types_true; //< Selected types of elements.
258  public:
261  : ArgA(_ArgA), ArgB(_ArgB), types_true(_types_true) {}
264  : ArgA(other.ArgA), ArgB(other.ArgB), types_true(other.types_true) {}
267  {
268  types_true = other.types_true;
269  ArgA = other.ArgA;
270  ArgB = other.ArgB;
271  return *this;
272  }
274  rMatrix Value(const Storage & e) const
275  {return (e->GetElementType() & types_true) ? ArgA.Value(e) : ArgB.Value(e);}
278  vMatrix Variable(const Storage & e) const
279  {return (e->GetElementType() & types_true) ? ArgA.Variable(e) : ArgB.Variable(e);}
282  };
283 
288  {
289  private:
290  stored_block_variable_expression ArgA; //< Variable expression to be evaluated when marker is set on the element.
291  stored_block_variable_expression ArgB; //< Variable expression to be evaluated when marker is not set on the element.
292  MarkerType marker; //< Marker.
293  public:
295  marker_branch_block_variable(MarkerType _marker, const abstract_dynamic_block_variable & _ArgA, const abstract_dynamic_block_variable & _ArgB) : ArgA(_ArgA), ArgB(_ArgB), marker(_marker) {}
297  marker_branch_block_variable(const marker_branch_block_variable & other) : ArgA(other.ArgA), ArgB(other.ArgB), marker(other.marker) {}
300  {
301  marker = other.marker;
302  ArgA = other.ArgA;
303  ArgB = other.ArgB;
304  return *this;
305  }
307  rMatrix Value(const Storage & e) const
308  {return ( isPrivate(marker) ? e->GetPrivateMarker(marker) : e->GetMarker(marker) ) ? ArgA.Value(e) : ArgB.Value(e);}
311  vMatrix Variable(const Storage & e) const
312  {return ( isPrivate(marker) ? e->GetPrivateMarker(marker) : e->GetMarker(marker) ) ? ArgA.Variable(e) : ArgB.Variable(e);}
315  };
316 
319  {
320  private:
321  stored_block_variable_expression ArgA; //< Block variable expression on the left.
322  stored_block_variable_expression ArgB; //< Block variable expression on the right.
323  public:
326  const abstract_dynamic_block_variable & _ArgB)
327  : ArgA(_ArgA), ArgB(_ArgB) {}
330  : ArgA(other.ArgA), ArgB(other.ArgB) {}
333  {
334  ArgA = other.ArgA;
335  ArgB = other.ArgB;
336  return *this;
337  }
339  rMatrix Value(const Storage & e) const
340  {return ArgA.Value(e) + ArgB.Value(e);}
343  vMatrix Variable(const Storage & e) const
344  {return ArgA.Variable(e) + ArgB.Variable(e);}
347  };
348 
351  {
352  private:
353  stored_block_variable_expression ArgA; //< Block variable expression on the left.
354  stored_block_variable_expression ArgB; //< Block variable expression on the right.
355  public:
358  const abstract_dynamic_block_variable & _ArgB)
359  : ArgA(_ArgA), ArgB(_ArgB) {}
362  : ArgA(other.ArgA), ArgB(other.ArgB) {}
365  {
366  ArgA = other.ArgA;
367  ArgB = other.ArgB;
368  return *this;
369  }
371  rMatrix Value(const Storage & e) const
372  {return ArgA.Value(e) - ArgB.Value(e);}
375  vMatrix Variable(const Storage & e) const
376  {return ArgA.Variable(e) - ArgB.Variable(e);}
379  };
380 
383  {
384  private:
385  stored_block_variable_expression ArgA; //< Block variable expression on the left.
386  stored_block_variable_expression ArgB; //< Block variable expression on the right.
387  public:
390  const abstract_dynamic_block_variable & _ArgB)
391  : ArgA(_ArgA), ArgB(_ArgB) {}
394  : ArgA(other.ArgA), ArgB(other.ArgB) {}
397  {
398  ArgA = other.ArgA;
399  ArgB = other.ArgB;
400  return *this;
401  }
403  rMatrix Value(const Storage & e) const
404  {return ArgA.Value(e)*ArgB.Value(e);}
407  vMatrix Variable(const Storage & e) const
408  {return ArgA.Variable(e)*ArgB.Variable(e);}
411  };
412 
415  {
416  private:
417  stored_block_variable_expression ArgA; //< Block variable expression on the left.
418  stored_block_variable_expression ArgB; //< Block variable expression on the right.
419  public:
422  const abstract_dynamic_block_variable & _ArgB)
423  : ArgA(_ArgA), ArgB(_ArgB) {}
426  : ArgA(other.ArgA), ArgB(other.ArgB) {}
429  {
430  ArgA = other.ArgA;
431  ArgB = other.ArgB;
432  return *this;
433  }
435  rMatrix Value(const Storage & e) const
436  {return (ArgA.Value(e)/ArgB.Value(e));}
439  vMatrix Variable(const Storage & e) const
440  {return (ArgA.Variable(e)/ArgB.Variable(e));}
443  };
444 
447  {
448  private:
449  stored_block_variable_expression ArgA; //< Block variable expression on the left.
450  stored_block_variable_expression ArgB; //< Block variable expression on the right.
451  public:
454  const abstract_dynamic_block_variable & _ArgB)
455  : ArgA(_ArgA), ArgB(_ArgB) {}
458  : ArgA(other.ArgA), ArgB(other.ArgB) {}
461  {
462  ArgA = other.ArgA;
463  ArgB = other.ArgB;
464  return *this;
465  }
467  rMatrix Value(const Storage & e) const
468  {return ArgA.Value(e).ConcatCols(ArgB.Value(e));}
471  vMatrix Variable(const Storage & e) const
472  {return ArgA.Variable(e).ConcatCols(ArgB.Variable(e));}
475  };
476 
479  {
480  private:
481  stored_block_variable_expression ArgA; //< Block variable expression on the left.
482  stored_block_variable_expression ArgB; //< Block variable expression on the right.
483  public:
486  const abstract_dynamic_block_variable & _ArgB)
487  : ArgA(_ArgA), ArgB(_ArgB) {}
490  : ArgA(other.ArgA), ArgB(other.ArgB) {}
493  {
494  ArgA = other.ArgA;
495  ArgB = other.ArgB;
496  return *this;
497  }
499  rMatrix Value(const Storage & e) const
500  {return ArgA.Value(e).ConcatRows(ArgB.Value(e));}
503  vMatrix Variable(const Storage & e) const
504  {return ArgA.Variable(e).ConcatRows(ArgB.Variable(e));}
507  };
508 
509 
510 
513  {
514  private:
515  stored_block_variable_expression ArgA; //< Block variable expression
516  public:
519  : ArgA(_ArgA) {}
522  : ArgA(other.ArgA) {}
525  {
526  ArgA = other.ArgA;
527  return *this;
528  }
530  rMatrix Value(const Storage & e) const
531  {return ArgA.Value(e).Transpose();}
534  vMatrix Variable(const Storage & e) const
535  {return ArgA.Variable(e).Transpose();}
538  };
539 
542  {
543  private:
544  stored_block_variable_expression ArgA; //< Block variable expression
545  INMOST_DATA_ENUM_TYPE row1,row2,col1,col2;
546  public:
549  INMOST_DATA_ENUM_TYPE row1,
550  INMOST_DATA_ENUM_TYPE row2,
551  INMOST_DATA_ENUM_TYPE col1,
552  INMOST_DATA_ENUM_TYPE col2)
553  : ArgA(_ArgA), row1(row1), row2(row2), col1(col1), col2(col2) {}
556  : ArgA(b.ArgA), row1(b.row1), row2(b.row2), col1(b.col1), col2(b.col2) {}
559  {
560  row1 = b.row1;
561  row2 = b.row2;
562  col1 = b.col1;
563  col2 = b.col2;
564  ArgA = b.ArgA;
565  return *this;
566  }
568  rMatrix Value(const Storage & e) const
569  {return ArgA.Value(e)(row1,row2,col1,col2);}
572  vMatrix Variable(const Storage & e) const
573  {return ArgA.Variable(e)(row1,row2,col1,col2);}
576  };
577 
580  {
581  private:
582  stored_block_variable_expression ArgA; //< Block variable expression
583  INMOST_DATA_REAL_TYPE value;
584  public:
587  INMOST_DATA_REAL_TYPE val)
588  : ArgA(_ArgA), value(val) {}
591  : ArgA(b.ArgA), value(b.value) {}
594  {
595  value = b.value;
596  ArgA = b.ArgA;
597  return *this;
598  }
600  rMatrix Value(const Storage & e) const
601  {return ArgA.Value(e)*value;}
604  vMatrix Variable(const Storage & e) const
605  {return ArgA.Variable(e)*value;}
608  };
609 
612  {
613  private:
614  stored_block_variable_expression ArgA; //< Block variable expression
615  stored_block_variable_expression ArgB; //< Block variable expression
617  public:
620  const abstract_dynamic_block_variable & _ArgA,
621  const abstract_dynamic_block_variable & _ArgB)
622  : ArgA(_ArgA), ArgB(_ArgB), ArgC(_ArgC) {}
625  : ArgA(b.ArgA), ArgB(b.ArgB), ArgC(b.ArgC) {}
628  {
629  ArgB = b.ArgB;
630  ArgA = b.ArgA;
631  ArgC = b.ArgC;
632  return *this;
633  }
635  rMatrix Value(const Storage & e) const
636  {return ArgC.Value(e) > 0.0 ? ArgA.Value(e) : ArgB.Value(e);}
639  vMatrix Variable(const Storage & e) const
640  {return ArgC.Value(e) > 0.0 ? ArgA.Variable(e) : ArgB.Variable(e);}
643  };
644 
647  {
648  private:
649  stored_block_variable_expression ArgA; //< Block variable expression
651  public:
654  const abstract_dynamic_variable & _ArgB)
655  : ArgA(_ArgA), ArgB(_ArgB) {}
658  : ArgA(b.ArgA), ArgB(b.ArgB) {}
661  {
662  ArgB = b.ArgB;
663  ArgA = b.ArgA;
664  return *this;
665  }
667  rMatrix Value(const Storage & e) const
668  {return ArgA.Value(e)*ArgB.Value(e);}
671  vMatrix Variable(const Storage & e) const
672  {return ArgA.Variable(e)*ArgB.Variable(e);}
675  };
676 
679  {
680  private:
681  stored_block_variable_expression ArgA; //< Block variable expression
682  public:
685  : ArgA(_ArgA) {}
688  : ArgA(other.ArgA) {}
691  {
692  ArgA = other.ArgA;
693  return *this;
694  }
696  rMatrix Value(const Storage & e) const
697  {return ArgA.Value(e).Invert();}
700  vMatrix Variable(const Storage & e) const
701  {return ArgA.Variable(e).Invert();}
704  };
705 
708  {
709  private:
710  stored_block_variable_expression ArgA; //< Block variable expression
711  double eps;
712  public:
715  : ArgA(_ArgA), eps(_eps) {}
718  : ArgA(other.ArgA), eps(other.eps) {}
721  {
722  ArgA = other.ArgA;
723  eps = other.eps;
724  return *this;
725  }
727  rMatrix Value(const Storage & e) const
728  {return ArgA.Value(e).PseudoInvert(eps);}
731  vMatrix Variable(const Storage & e) const
732  {return ArgA.Variable(e).PseudoInvert(eps);}
735  };
736 
737 
738 
739 
740  typedef abstract_dynamic_block_variable abstract_block_variable;
741 }
742 
744 __INLINE
746 condition(INMOST::abstract_dynamic_variable const & control,
747  INMOST::abstract_dynamic_block_variable const & if_ge_zero,
748  INMOST::abstract_dynamic_block_variable const & if_lt_zero)
749 { return INMOST::condition_block_variable(control,if_ge_zero,if_lt_zero); }
751 __INLINE
753 operator+(INMOST::abstract_block_variable const & Left,
754  INMOST::abstract_block_variable const & Right)
755 { return INMOST::addition_block_variable(Left, Right); }
757 __INLINE
759 operator-(INMOST::abstract_block_variable const & Left,
760  INMOST::abstract_block_variable const & Right)
761 { return INMOST::subtraction_block_variable(Left, Right); }
763 __INLINE
765 operator*(INMOST::abstract_block_variable const & Left,
766  INMOST::abstract_block_variable const & Right)
767 { return INMOST::multiplication_block_variable(Left, Right); }
769 __INLINE
771 operator/(INMOST::abstract_block_variable const & Left,
772  INMOST::abstract_block_variable const & Right)
773 { return INMOST::division_block_variable(Left, Right); }
775 __INLINE
777 concat_rows(INMOST::abstract_block_variable const & Left,
778  INMOST::abstract_block_variable const & Right)
779 { return INMOST::concat_rows_block_variable(Left, Right); }
781 __INLINE
783 concat_cols(INMOST::abstract_block_variable const & Left,
784  INMOST::abstract_block_variable const & Right)
785 { return INMOST::concat_cols_block_variable(Left, Right); }
787 __INLINE
789 transpose(INMOST::abstract_block_variable const & Left)
790 { return INMOST::transpose_block_variable(Left); }
792 __INLINE
794 inv(INMOST::abstract_block_variable const & Left)
795 { return INMOST::inverse_block_variable(Left); }
797 __INLINE
799 pinv(INMOST::abstract_block_variable const & Left)
802 __INLINE
804 submatrix(INMOST::abstract_block_variable const & Left,
805  INMOST_DATA_ENUM_TYPE row1,
806  INMOST_DATA_ENUM_TYPE row2,
807  INMOST_DATA_ENUM_TYPE col1,
808  INMOST_DATA_ENUM_TYPE col2)
809 { return INMOST::submatrix_block_variable(Left,row1,row2,col1,col2); }
811 __INLINE
813 operator *(INMOST::abstract_block_variable const & Left,
814  INMOST_DATA_REAL_TYPE Right)
815 { return INMOST::multiply_const_block_variable(Left,Right); }
817 __INLINE
819 operator *(INMOST_DATA_REAL_TYPE Left,
820  INMOST::abstract_block_variable const & Right)
821 { return INMOST::multiply_const_block_variable(Right,Left); }
823 __INLINE
825 operator /(INMOST::abstract_block_variable const & Left,
826  INMOST_DATA_REAL_TYPE Right)
827 { return INMOST::multiply_const_block_variable(Left,1.0/Right); }
829 __INLINE
831 operator *(INMOST::abstract_block_variable const & Left,
832  INMOST::abstract_variable const & Right)
833 { return INMOST::multiply_variable_block_variable(Left,Right); }
835 __INLINE
837 operator *(INMOST::abstract_variable const & Left,
838  INMOST::abstract_block_variable const & Right)
839 { return INMOST::multiply_variable_block_variable(Right,Left); }
841 __INLINE
843 operator /(INMOST::abstract_block_variable const & Left,
844  INMOST::abstract_variable const & Right)
847 __INLINE
849 stencil(INMOST::Tag tag_elems,
850  INMOST::Tag tag_coefs,
852 { return INMOST::stencil_block_variable(tag_elems,tag_coefs,Arg); }
854 __INLINE
856 get_table(INMOST::abstract_dynamic_block_variable const & Arg,
857  INMOST::keyval_table const & Table)
858 {return INMOST::table_block_variable(Arg,Table);}
860 __INLINE
862 etype_branch(INMOST::ElementType true_type,
865 {return INMOST::etype_branch_block_variable(true_type,iftrue,iffalse);}
867 __INLINE
869 marker_branch(INMOST::MarkerType marker,
872 {return INMOST::marker_branch_block_variable(marker,iftrue,iffalse);}
873 
874 #endif //defined(USE_AUTODIFF) && defined(USE_MESH)
875 
876 
877 
878 
879 #endif //INMOST_AUTODIFF_ETBVAR_H_INCLUDED
880 
This class is used to organize unknowns in abstract way, it should be registered with and managed by ...
virtual unknown Unknown(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const =0
Return unknown in vector of variables of the block at certain position.
virtual INMOST_DATA_REAL_TYPE Value(const Storage &e, INMOST_DATA_ENUM_TYPE pos) const =0
Return value in vector of unknowns of the block at certain position.
bool isValid(const Storage &e) const
Check that the block is valid on given element.
Matrix< Var > Invert(int *ierr=NULL) const
Inverts matrix using Crout-LU decomposition with full pivoting for maximum element.
Matrix< Var > PseudoInvert(INMOST_DATA_REAL_TYPE tol=0, int *ierr=NULL) const
Calculates Moore-Penrose pseudo-inverse of the matrix.
MatrixConcatCols< Var > ConcatCols(AbstractMatrix< Var > &B)
Concatenate B matrix as columns of current matrix.
Definition: inmost_dense.h:808
MatrixTranspose< Var > Transpose()
Transpose the current matrix with access to elements.
Definition: inmost_dense.h:796
MatrixConcatRows< Var > ConcatRows(AbstractMatrix< Var > &B)
Concatenate B matrix as rows of current matrix.
Definition: inmost_dense.h:815
The Automatizator class helps in defining primary unknowns of the model and enhances user experience ...
AbstractEntry & GetEntry(INMOST_DATA_ENUM_TYPE ind)
Retrieve the block from automatizator by index.
__INLINE enumerator Cols() const
Obtain number of columns.
__INLINE enumerator Rows() const
Obtain number of rows.
Storage type for representing arrays of Element references.
Definition: inmost_data.h:338
Base class for Mesh, Element, and ElementSet classes.
Definition: inmost_data.h:310
This class provides the access to the individual mesh datum and general information about it.
Definition: inmost_data.h:193
This class represents addition of two matrices.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
addition_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
addition_block_variable & operator=(addition_block_variable const &other)
Assignment operator.
addition_block_variable(const addition_block_variable &other)
Copy constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
This class represents division of two matrices, this is technically B^{-1}A.
concat_cols_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
concat_cols_block_variable(const concat_cols_block_variable &other)
Copy constructor.
concat_cols_block_variable & operator=(concat_cols_block_variable const &other)
Assignment operator.
This class represents division of two matrices, this is technically B^{-1}A.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
concat_rows_block_variable(const concat_rows_block_variable &other)
Copy constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
concat_rows_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
concat_rows_block_variable & operator=(concat_rows_block_variable const &other)
Assignment operator.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
This class represents multiplication of the matrix by the variable.
condition_block_variable(const condition_block_variable &b)
Copy constructor.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
condition_block_variable(const abstract_dynamic_variable &_ArgC, const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
condition_block_variable & operator=(condition_block_variable const &b)
Assignment operator.
This class represents division of two matrices, this is technically B^{-1}A.
division_block_variable & operator=(division_block_variable const &other)
Assignment operator.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
division_block_variable(const division_block_variable &other)
Copy constructor.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
division_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
This class makes possible to evaluate different expressions on different element types.
etype_branch_block_variable(ElementType _types_true, const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor. Used by etype_branch function.
etype_branch_block_variable(const etype_branch_block_variable &other)
Copy constructor.
etype_branch_block_variable & operator=(etype_branch_block_variable const &other)
Assignment operator.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
This class represents inverse of the matrix, this is A^{-1}.
inverse_block_variable & operator=(inverse_block_variable const &other)
Assignment operator.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
inverse_block_variable(const abstract_dynamic_block_variable &_ArgA)
Constructor.
inverse_block_variable(const inverse_block_variable &other)
Copy constructor.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
This class makes possible to evaluate different expressions depending on the markers.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
marker_branch_block_variable(const marker_branch_block_variable &other)
Copy constructor.
marker_branch_block_variable(MarkerType _marker, const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor. Used by marker_branch function.
marker_branch_block_variable & operator=(marker_branch_block_variable const &other)
Assignment operator.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
This class represents multiplication of two matrices.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
multiplication_block_variable & operator=(multiplication_block_variable const &other)
Assignment operator.
multiplication_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
multiplication_block_variable(const multiplication_block_variable &other)
Copy constructor.
This class represents multiplication of the matrix by the constant.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
multiply_const_block_variable(const multiply_const_block_variable &b)
Copy constructor.
multiply_const_block_variable & operator=(multiply_const_block_variable const &b)
Assignment operator.
multiply_const_block_variable(const abstract_dynamic_block_variable &_ArgA, INMOST_DATA_REAL_TYPE val)
Constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
This class represents multiplication of the matrix by the variable.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
multiply_variable_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_variable &_ArgB)
Constructor.
multiply_variable_block_variable & operator=(multiply_variable_block_variable const &b)
Assignment operator.
multiply_variable_block_variable(const multiply_variable_block_variable &b)
Copy constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
This class represents pseudo-inverse of the matrix, this is A^{+}.
pseudo_inverse_block_variable(const pseudo_inverse_block_variable &other)
Copy constructor.
pseudo_inverse_block_variable & operator=(pseudo_inverse_block_variable const &other)
Assignment operator.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
pseudo_inverse_block_variable(const abstract_dynamic_block_variable &_ArgA, double _eps=1.0e-13)
Constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
bool isDefined() const
Checks that the stored expresison was defined.
This class represents submatrix of the matrix.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
submatrix_block_variable(const submatrix_block_variable &b)
Copy constructor.
submatrix_block_variable & operator=(submatrix_block_variable const &b)
Assignment operator.
submatrix_block_variable(const abstract_dynamic_block_variable &_ArgA, INMOST_DATA_ENUM_TYPE row1, INMOST_DATA_ENUM_TYPE row2, INMOST_DATA_ENUM_TYPE col1, INMOST_DATA_ENUM_TYPE col2)
Constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
This class represents subtraction of two matrices.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
subtraction_block_variable(const abstract_dynamic_block_variable &_ArgA, const abstract_dynamic_block_variable &_ArgB)
Constructor.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
subtraction_block_variable(const subtraction_block_variable &other)
Copy constructor.
subtraction_block_variable & operator=(subtraction_block_variable const &other)
Assignment operator.
Apply table component-wise on argument matrix.
This class represents transposition of the matrix, this is A^T.
vMatrix Variable(const Storage &e) const
Get value with derivatives of variable expression on provided element e.
transpose_block_variable(const abstract_dynamic_block_variable &_ArgA)
Constructor.
abstract_dynamic_block_variable * Copy() const
Make a copy of this class, used to reproduce and store a tree of variable expressions.
rMatrix Value(const Storage &e) const
Get value of variable expression on provided element e.
transpose_block_variable(const transpose_block_variable &other)
Copy constructor.
transpose_block_variable & operator=(transpose_block_variable const &other)
Assignment operator.