GiNaC  1.8.0
ex.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 Johannes Gutenberg University Mainz, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_EX_H
24 #define GINAC_EX_H
25 
26 #include "basic.h"
27 #include "ptr.h"
28 
29 #include <functional>
30 #include <iosfwd>
31 #include <iterator>
32 #include <memory>
33 #include <stack>
34 
35 namespace GiNaC {
36 #ifdef _MSC_VER
37  // MSVC produces a different symbol for _ex0 when it is declared inside
38  // ex::is_zero() than when it is declared at top level as follows
39  extern const ex _ex0;
40 #endif
41 
50 class library_init {
51  static void init_unarchivers();
52 public:
53  library_init();
54  ~library_init();
55 private:
56  static int count;
57 };
60 
61 class scalar_products;
62 class const_iterator;
65 
66 
72 class ex {
73  friend class archive_node;
74  friend inline bool are_ex_trivially_equal(const ex &, const ex &);
75  template<class T> friend inline const T &ex_to(const ex &);
76  template<class T> friend inline bool is_a(const ex &);
77  template<class T> friend inline bool is_exactly_a(const ex &);
78 
79  // default constructor, copy constructor and assignment operator
80 public:
81  ex() noexcept;
82 
83  // other constructors
84 public:
85  ex(const basic & other);
86  ex(int i);
87  ex(unsigned int i);
88  ex(long i);
89  ex(unsigned long i);
90  ex(long long i);
91  ex(unsigned long long i);
92  ex(double const d);
93 
98  ex(const std::string &s, const ex &l);
99 
100 public:
101  // non-virtual functions in this class
102 public:
104  void swap(ex & other) noexcept
105  {
107  GINAC_ASSERT(other.bp->flags & status_flags::dynallocated);
108  bp.swap(other.bp);
109  }
110 
111  // iterators
112  const_iterator begin() const noexcept;
113  const_iterator end() const noexcept;
115  const_preorder_iterator preorder_end() const noexcept;
117  const_postorder_iterator postorder_end() const noexcept;
118 
119  // evaluation
120  ex eval() const { return bp->eval(); }
121  ex evalf() const { return bp->evalf(); }
122  ex evalm() const { return bp->evalm(); }
123  ex eval_ncmul(const exvector & v) const { return bp->eval_ncmul(v); }
124  ex eval_integ() const { return bp->eval_integ(); }
125 
126  // printing
127  void print(const print_context & c, unsigned level = 0) const;
128  void dbgprint() const;
129  void dbgprinttree() const;
130 
131  // info
132  bool info(unsigned inf) const { return bp->info(inf); }
133 
134  // operand access
135  size_t nops() const { return bp->nops(); }
136  ex op(size_t i) const { return bp->op(i); }
137  ex operator[](const ex & index) const { return (*bp)[index]; }
138  ex operator[](size_t i) const { return (*bp)[i]; }
139  ex & let_op(size_t i);
140  ex & operator[](const ex & index);
141  ex & operator[](size_t i);
142  ex lhs() const;
143  ex rhs() const;
144 
145  // function for complex expressions
146  ex conjugate() const { return bp->conjugate(); }
147  ex real_part() const { return bp->real_part(); }
148  ex imag_part() const { return bp->imag_part(); }
149 
150  // pattern matching
151  bool has(const ex & pattern, unsigned options = 0) const { return bp->has(pattern, options); }
152  bool find(const ex & pattern, exset& found) const;
153  bool match(const ex & pattern) const;
154  bool match(const ex & pattern, exmap & repls) const { return bp->match(pattern, repls); }
155 
156  // substitutions
157  ex subs(const exmap & m, unsigned options = 0) const;
158  ex subs(const lst & ls, const lst & lr, unsigned options = 0) const;
159  ex subs(const ex & e, unsigned options = 0) const;
160 
161  // function mapping
162  ex map(map_function & f) const { return bp->map(f); }
163  ex map(ex (*f)(const ex & e)) const;
164 
165  // visitors and tree traversal
166  void accept(visitor & v) const { bp->accept(v); }
167  void traverse_preorder(visitor & v) const;
168  void traverse_postorder(visitor & v) const;
169  void traverse(visitor & v) const { traverse_preorder(v); }
170 
171  // degree/coeff
172  bool is_polynomial(const ex & vars) const;
173  int degree(const ex & s) const { return bp->degree(s); }
174  int ldegree(const ex & s) const { return bp->ldegree(s); }
175  ex coeff(const ex & s, int n = 1) const { return bp->coeff(s, n); }
176  ex lcoeff(const ex & s) const { return coeff(s, degree(s)); }
177  ex tcoeff(const ex & s) const { return coeff(s, ldegree(s)); }
178 
179  // expand/collect
180  ex expand(unsigned options=0) const;
181  ex collect(const ex & s, bool distributed = false) const { return bp->collect(s, distributed); }
182 
183  // differentiation and series expansion
184  ex diff(const symbol & s, unsigned nth = 1) const;
185  ex series(const ex & r, int order, unsigned options = 0) const;
186 
187  // rational functions
188  ex normal() const;
189  ex to_rational(exmap & repl) const;
190  ex to_polynomial(exmap & repl) const;
191  ex numer() const;
192  ex denom() const;
193  ex numer_denom() const;
194 
195  // polynomial algorithms
196  ex unit(const ex &x) const;
197  ex content(const ex &x) const;
198  numeric integer_content() const;
199  ex primpart(const ex &x) const;
200  ex primpart(const ex &x, const ex &cont) const;
201  void unitcontprim(const ex &x, ex &u, ex &c, ex &p) const;
202  ex smod(const numeric &xi) const { return bp->smod(xi); }
203  numeric max_coefficient() const;
204 
205  // indexed objects
206  exvector get_free_indices() const { return bp->get_free_indices(); }
207  ex simplify_indexed(unsigned options = 0) const;
208  ex simplify_indexed(const scalar_products & sp, unsigned options = 0) const;
209 
210  // comparison
211  int compare(const ex & other) const;
212  bool is_equal(const ex & other) const;
213  bool is_zero() const {
214 #ifndef _MSC_VER
215  extern const ex _ex0;
216 #endif
217  return is_equal(_ex0);
218  }
219  bool is_zero_matrix() const;
220 
221  // symmetry
222  ex symmetrize() const;
223  ex symmetrize(const lst & l) const;
224  ex antisymmetrize() const;
225  ex antisymmetrize(const lst & l) const;
226  ex symmetrize_cyclic() const;
227  ex symmetrize_cyclic(const lst & l) const;
228 
229  // noncommutativity
230  unsigned return_type() const { return bp->return_type(); }
231  return_type_t return_type_tinfo() const { return bp->return_type_tinfo(); }
232 
233  unsigned gethash() const { return bp->gethash(); }
234 
235 private:
236  static ptr<basic> construct_from_basic(const basic & other);
237  static basic & construct_from_int(int i);
238  static basic & construct_from_uint(unsigned int i);
239  static basic & construct_from_long(long i);
240  static basic & construct_from_ulong(unsigned long i);
241  static basic & construct_from_longlong(long long i);
242  static basic & construct_from_ulonglong(unsigned long long i);
243  static basic & construct_from_double(double d);
244  static ptr<basic> construct_from_string_and_lst(const std::string &s, const ex &l);
245  void makewriteable();
246  void share(const ex & other) const;
247 
248 // member variables
249 
250 private:
251  mutable ptr<basic> bp;
252 };
253 
254 
255 // performance-critical inlined method implementations
256 
257 // This needs to be a basic* because we don't know that numeric is derived
258 // from basic and we need a basic& for the ex default constructor
259 extern const basic *_num0_bp;
260 
261 inline
262 ex::ex() noexcept : bp(*const_cast<basic *>(_num0_bp))
263 {
265 }
266 
267 inline
268 ex::ex(const basic & other) : bp(construct_from_basic(other))
269 {
271 }
272 
273 inline
274 ex::ex(int i) : bp(construct_from_int(i))
275 {
277 }
278 
279 inline
280 ex::ex(unsigned int i) : bp(construct_from_uint(i))
281 {
283 }
284 
285 inline
286 ex::ex(long i) : bp(construct_from_long(i))
287 {
289 }
290 
291 inline
292 ex::ex(unsigned long i) : bp(construct_from_ulong(i))
293 {
295 }
296 
297 inline
298 ex::ex(long long i) : bp(construct_from_longlong(i))
299 {
301 }
302 
303 inline
304 ex::ex(unsigned long long i) : bp(construct_from_ulonglong(i))
305 {
307 }
308 
309 inline
310 ex::ex(double const d) : bp(construct_from_double(d))
311 {
313 }
314 
315 inline
316 ex::ex(const std::string &s, const ex &l) : bp(construct_from_string_and_lst(s, l))
317 {
319 }
320 
321 inline
322 int ex::compare(const ex & other) const
323 {
324 #ifdef GINAC_COMPARE_STATISTICS
325  compare_statistics.total_compares++;
326 #endif
327  if (bp == other.bp) // trivial case: both expressions point to same basic
328  return 0;
329 #ifdef GINAC_COMPARE_STATISTICS
330  compare_statistics.nontrivial_compares++;
331 #endif
332  const int cmpval = bp->compare(*other.bp);
333 #if 1
334  if (cmpval == 0) {
335  // Expressions point to different, but equal, trees: conserve
336  // memory and make subsequent compare() operations faster by
337  // making both expressions point to the same tree.
338  share(other);
339  }
340 #endif
341  return cmpval;
342 }
343 
344 inline
345 bool ex::is_equal(const ex & other) const
346 {
347 #ifdef GINAC_COMPARE_STATISTICS
348  compare_statistics.total_is_equals++;
349 #endif
350  if (bp == other.bp) // trivial case: both expressions point to same basic
351  return true;
352 #ifdef GINAC_COMPARE_STATISTICS
353  compare_statistics.nontrivial_is_equals++;
354 #endif
355  const bool equal = bp->is_equal(*other.bp);
356 #if 0
357  if (equal) {
358  // Expressions point to different, but equal, trees: conserve
359  // memory and make subsequent compare() operations faster by
360  // making both expressions point to the same tree.
361  share(other);
362  }
363 #endif
364  return equal;
365 }
366 
367 
368 // Iterators
369 
370 class const_iterator : public std::iterator<std::random_access_iterator_tag, ex, ptrdiff_t, const ex *, const ex &> {
371  friend class ex;
374 
375 public:
376  const_iterator() noexcept {}
377 
378 private:
379  const_iterator(const ex &e_, size_t i_) noexcept : e(e_), i(i_) {}
380 
381 public:
382  // This should return an ex&, but that would be a reference to a
383  // temporary value
384  ex operator*() const
385  {
386  return e.op(i);
387  }
388 
389  // This should return an ex*, but that would be a pointer to a
390  // temporary value
391  std::unique_ptr<ex> operator->() const
392  {
393  return std::unique_ptr<ex>(new ex(operator*()));
394  }
395 
396  ex operator[](difference_type n) const
397  {
398  return e.op(i + n);
399  }
400 
402  {
403  ++i;
404  return *this;
405  }
406 
408  {
409  const_iterator tmp = *this;
410  ++i;
411  return tmp;
412  }
413 
414  const_iterator &operator+=(difference_type n) noexcept
415  {
416  i += n;
417  return *this;
418  }
419 
420  const_iterator operator+(difference_type n) const noexcept
421  {
422  return const_iterator(e, i + n);
423  }
424 
425  inline friend const_iterator operator+(difference_type n, const const_iterator &it) noexcept
426  {
427  return const_iterator(it.e, it.i + n);
428  }
429 
431  {
432  --i;
433  return *this;
434  }
435 
437  {
438  const_iterator tmp = *this;
439  --i;
440  return tmp;
441  }
442 
443  const_iterator &operator-=(difference_type n) noexcept
444  {
445  i -= n;
446  return *this;
447  }
448 
449  const_iterator operator-(difference_type n) const noexcept
450  {
451  return const_iterator(e, i - n);
452  }
453 
454  inline friend difference_type operator-(const const_iterator &lhs, const const_iterator &rhs) noexcept
455  {
456  return lhs.i - rhs.i;
457  }
458 
459  bool operator==(const const_iterator &other) const noexcept
460  {
461  return are_ex_trivially_equal(e, other.e) && i == other.i;
462  }
463 
464  bool operator!=(const const_iterator &other) const noexcept
465  {
466  return !(*this == other);
467  }
468 
469  bool operator<(const const_iterator &other) const noexcept
470  {
471  return i < other.i;
472  }
473 
474  bool operator>(const const_iterator &other) const noexcept
475  {
476  return other < *this;
477  }
478 
479  bool operator<=(const const_iterator &other) const noexcept
480  {
481  return !(other < *this);
482  }
483 
484  bool operator>=(const const_iterator &other) const noexcept
485  {
486  return !(*this < other);
487  }
488 
489 protected:
490  ex e; // this used to be a "const basic *", but in view of object fusion that wouldn't be safe
491  size_t i;
492 };
493 
494 namespace internal {
495 
496 struct _iter_rep {
497  _iter_rep(const ex &e_, size_t i_, size_t i_end_) : e(e_), i(i_), i_end(i_end_) {}
498 
499  bool operator==(const _iter_rep &other) const noexcept
500  {
501  return are_ex_trivially_equal(e, other.e) && i == other.i;
502  }
503 
504  bool operator!=(const _iter_rep &other) const noexcept
505  {
506  return !(*this == other);
507  }
508 
509  ex e;
510  size_t i;
511  size_t i_end;
512 };
513 
514 } // namespace internal
515 
516 class const_preorder_iterator : public std::iterator<std::forward_iterator_tag, ex, ptrdiff_t, const ex *, const ex &> {
517 public:
519 
520  const_preorder_iterator(const ex &e, size_t n)
521  {
522  s.push(internal::_iter_rep(e, 0, n));
523  }
524 
525 public:
526  reference operator*() const
527  {
528  return s.top().e;
529  }
530 
531  pointer operator->() const
532  {
533  return &(s.top().e);
534  }
535 
537  {
538  increment();
539  return *this;
540  }
541 
543  {
544  const_preorder_iterator tmp = *this;
545  increment();
546  return tmp;
547  }
548 
549  bool operator==(const const_preorder_iterator &other) const noexcept
550  {
551  return s == other.s;
552  }
553 
554  bool operator!=(const const_preorder_iterator &other) const noexcept
555  {
556  return !(*this == other);
557  }
558 
559 private:
560  std::stack<internal::_iter_rep, std::vector<internal::_iter_rep>> s;
561 
562  void increment()
563  {
564  while (!s.empty() && s.top().i == s.top().i_end) {
565  s.pop();
566  if (s.empty())
567  return;
568  ++s.top().i;
569  }
570 
571  internal::_iter_rep & current = s.top();
572 
573  if (current.i != current.i_end) {
574  const ex & child = current.e.op(current.i);
575  s.push(internal::_iter_rep(child, 0, child.nops()));
576  }
577  }
578 };
579 
580 class const_postorder_iterator : public std::iterator<std::forward_iterator_tag, ex, ptrdiff_t, const ex *, const ex &> {
581 public:
583 
584  const_postorder_iterator(const ex &e, size_t n)
585  {
586  s.push(internal::_iter_rep(e, 0, n));
587  descend();
588  }
589 
590 public:
591  reference operator*() const
592  {
593  return s.top().e;
594  }
595 
596  pointer operator->() const
597  {
598  return &(s.top().e);
599  }
600 
602  {
603  increment();
604  return *this;
605  }
606 
608  {
609  const_postorder_iterator tmp = *this;
610  increment();
611  return tmp;
612  }
613 
614  bool operator==(const const_postorder_iterator &other) const noexcept
615  {
616  return s == other.s;
617  }
618 
619  bool operator!=(const const_postorder_iterator &other) const noexcept
620  {
621  return !(*this == other);
622  }
623 
624 private:
625  std::stack<internal::_iter_rep, std::vector<internal::_iter_rep>> s;
626 
627  void descend()
628  {
629  while (s.top().i != s.top().i_end) {
630  internal::_iter_rep & current = s.top();
631  const ex & child = current.e.op(current.i);
632  s.push(internal::_iter_rep(child, 0, child.nops()));
633  }
634  }
635 
636  void increment()
637  {
638  if (s.top().i == s.top().i_end)
639  s.pop();
640  if (!s.empty()) {
641  ++s.top().i;
642  descend();
643  }
644  }
645 };
646 
647 inline const_iterator ex::begin() const noexcept
648 {
649  return const_iterator(*this, 0);
650 }
651 
652 inline const_iterator ex::end() const noexcept
653 {
654  return const_iterator(*this, nops());
655 }
656 
658 {
659  return const_preorder_iterator(*this, nops());
660 }
661 
663 {
664  return const_preorder_iterator();
665 }
666 
668 {
669  return const_postorder_iterator(*this, nops());
670 }
671 
673 {
674  return const_postorder_iterator();
675 }
676 
677 
678 // utility functions
679 
684 inline bool are_ex_trivially_equal(const ex &e1, const ex &e2)
685 {
686  return e1.bp == e2.bp;
687 }
688 
689 /* Function objects for STL sort() etc. */
690 struct ex_is_less {
691  bool operator() (const ex &lh, const ex &rh) const { return lh.compare(rh) < 0; }
692 };
693 
694 struct ex_is_equal {
695  bool operator() (const ex &lh, const ex &rh) const { return lh.is_equal(rh); }
696 };
697 
698 struct op0_is_equal {
699  bool operator() (const ex &lh, const ex &rh) const { return lh.op(0).is_equal(rh.op(0)); }
700 };
701 
702 struct ex_swap {
703  void operator() (ex &lh, ex &rh) const { lh.swap(rh); }
704 };
705 
706 // Make it possible to print exvectors and exmaps
707 std::ostream & operator<<(std::ostream & os, const exvector & e);
708 std::ostream & operator<<(std::ostream & os, const exset & e);
709 std::ostream & operator<<(std::ostream & os, const exmap & e);
710 
711 // wrapper functions around member functions
712 inline size_t nops(const ex & thisex)
713 { return thisex.nops(); }
714 
715 inline ex expand(const ex & thisex, unsigned options = 0)
716 { return thisex.expand(options); }
717 
718 inline ex conjugate(const ex & thisex)
719 { return thisex.conjugate(); }
720 
721 inline ex real_part(const ex & thisex)
722 { return thisex.real_part(); }
723 
724 inline ex imag_part(const ex & thisex)
725 { return thisex.imag_part(); }
726 
727 inline bool has(const ex & thisex, const ex & pattern, unsigned options = 0)
728 { return thisex.has(pattern, options); }
729 
730 inline bool find(const ex & thisex, const ex & pattern, exset& found)
731 { return thisex.find(pattern, found); }
732 
733 inline bool is_polynomial(const ex & thisex, const ex & vars)
734 { return thisex.is_polynomial(vars); }
735 
736 inline int degree(const ex & thisex, const ex & s)
737 { return thisex.degree(s); }
738 
739 inline int ldegree(const ex & thisex, const ex & s)
740 { return thisex.ldegree(s); }
741 
742 inline ex coeff(const ex & thisex, const ex & s, int n=1)
743 { return thisex.coeff(s, n); }
744 
745 inline ex numer(const ex & thisex)
746 { return thisex.numer(); }
747 
748 inline ex denom(const ex & thisex)
749 { return thisex.denom(); }
750 
751 inline ex numer_denom(const ex & thisex)
752 { return thisex.numer_denom(); }
753 
754 inline ex normal(const ex & thisex)
755 { return thisex.normal(); }
756 
757 inline ex to_rational(const ex & thisex, exmap & repl)
758 { return thisex.to_rational(repl); }
759 
760 inline ex to_polynomial(const ex & thisex, exmap & repl)
761 { return thisex.to_polynomial(repl); }
762 
763 inline ex collect(const ex & thisex, const ex & s, bool distributed = false)
764 { return thisex.collect(s, distributed); }
765 
766 inline ex eval(const ex & thisex)
767 { return thisex.eval(); }
768 
769 inline ex evalf(const ex & thisex)
770 { return thisex.evalf(); }
771 
772 inline ex evalm(const ex & thisex)
773 { return thisex.evalm(); }
774 
775 inline ex eval_integ(const ex & thisex)
776 { return thisex.eval_integ(); }
777 
778 inline ex diff(const ex & thisex, const symbol & s, unsigned nth = 1)
779 { return thisex.diff(s, nth); }
780 
781 inline ex series(const ex & thisex, const ex & r, int order, unsigned options = 0)
782 { return thisex.series(r, order, options); }
783 
784 inline bool match(const ex & thisex, const ex & pattern, exmap& repl_lst)
785 { return thisex.match(pattern, repl_lst); }
786 
787 inline ex simplify_indexed(const ex & thisex, unsigned options = 0)
788 { return thisex.simplify_indexed(options); }
789 
790 inline ex simplify_indexed(const ex & thisex, const scalar_products & sp, unsigned options = 0)
791 { return thisex.simplify_indexed(sp, options); }
792 
793 inline ex symmetrize(const ex & thisex)
794 { return thisex.symmetrize(); }
795 
796 inline ex symmetrize(const ex & thisex, const lst & l)
797 { return thisex.symmetrize(l); }
798 
799 inline ex antisymmetrize(const ex & thisex)
800 { return thisex.antisymmetrize(); }
801 
802 inline ex antisymmetrize(const ex & thisex, const lst & l)
803 { return thisex.antisymmetrize(l); }
804 
805 inline ex symmetrize_cyclic(const ex & thisex)
806 { return thisex.symmetrize_cyclic(); }
807 
808 inline ex symmetrize_cyclic(const ex & thisex, const lst & l)
809 { return thisex.symmetrize_cyclic(l); }
810 
811 inline ex op(const ex & thisex, size_t i)
812 { return thisex.op(i); }
813 
814 inline ex lhs(const ex & thisex)
815 { return thisex.lhs(); }
816 
817 inline ex rhs(const ex & thisex)
818 { return thisex.rhs(); }
819 
820 inline bool is_zero(const ex & thisex)
821 { return thisex.is_zero(); }
822 
823 inline void swap(ex & e1, ex & e2)
824 { e1.swap(e2); }
825 
826 inline ex ex::subs(const exmap & m, unsigned options) const
827 {
828  return bp->subs(m, options);
829 }
830 
831 inline ex subs(const ex & thisex, const exmap & m, unsigned options = 0)
832 { return thisex.subs(m, options); }
833 
834 inline ex subs(const ex & thisex, const lst & ls, const lst & lr, unsigned options = 0)
835 { return thisex.subs(ls, lr, options); }
836 
837 inline ex subs(const ex & thisex, const ex & e, unsigned options = 0)
838 { return thisex.subs(e, options); }
839 
840 
841 /* Convert function pointer to function object suitable for map(). */
843 protected:
844  ex (*ptr)(const ex &);
845 public:
846  explicit pointer_to_map_function(ex x(const ex &)) : ptr(x) {}
847  ex operator()(const ex & e) override { return ptr(e); }
848 };
849 
850 template<class T1>
852 protected:
853  ex (*ptr)(const ex &, T1);
854  T1 arg1;
855 public:
856  explicit pointer_to_map_function_1arg(ex x(const ex &, T1), T1 a1) : ptr(x), arg1(a1) {}
857  ex operator()(const ex & e) override { return ptr(e, arg1); }
858 };
859 
860 template<class T1, class T2>
862 protected:
863  ex (*ptr)(const ex &, T1, T2);
864  T1 arg1;
865  T2 arg2;
866 public:
867  explicit pointer_to_map_function_2args(ex x(const ex &, T1, T2), T1 a1, T2 a2) : ptr(x), arg1(a1), arg2(a2) {}
868  ex operator()(const ex & e) override { return ptr(e, arg1, arg2); }
869 };
870 
871 template<class T1, class T2, class T3>
873 protected:
874  ex (*ptr)(const ex &, T1, T2, T3);
875  T1 arg1;
876  T2 arg2;
877  T3 arg3;
878 public:
879  explicit pointer_to_map_function_3args(ex x(const ex &, T1, T2, T3), T1 a1, T2 a2, T3 a3) : ptr(x), arg1(a1), arg2(a2), arg3(a3) {}
880  ex operator()(const ex & e) override { return ptr(e, arg1, arg2, arg3); }
881 };
882 
883 template<class C>
885 protected:
886  ex (C::*ptr)(const ex &);
887  C &c;
888 public:
889  explicit pointer_to_member_to_map_function(ex (C::*member)(const ex &), C &obj) : ptr(member), c(obj) {}
890  ex operator()(const ex & e) override { return (c.*ptr)(e); }
891 };
892 
893 template<class C, class T1>
895 protected:
896  ex (C::*ptr)(const ex &, T1);
897  C &c;
898  T1 arg1;
899 public:
900  explicit pointer_to_member_to_map_function_1arg(ex (C::*member)(const ex &, T1), C &obj, T1 a1) : ptr(member), c(obj), arg1(a1) {}
901  ex operator()(const ex & e) override { return (c.*ptr)(e, arg1); }
902 };
903 
904 template<class C, class T1, class T2>
906 protected:
907  ex (C::*ptr)(const ex &, T1, T2);
908  C &c;
909  T1 arg1;
910  T2 arg2;
911 public:
912  explicit pointer_to_member_to_map_function_2args(ex (C::*member)(const ex&, T1, T2), C &obj, T1 a1, T2 a2) : ptr(member), c(obj), arg1(a1), arg2(a2) {}
913  ex operator()(const ex & e) override { return (c.*ptr)(e, arg1, arg2); }
914 };
915 
916 template<class C, class T1, class T2, class T3>
918 protected:
919  ex (C::*ptr)(const ex &, T1, T2, T3);
920  C &c;
921  T1 arg1;
922  T2 arg2;
923  T3 arg3;
924 public:
925  explicit pointer_to_member_to_map_function_3args(ex (C::*member)(const ex &, T1, T2, T3), C &obj, T1 a1, T2 a2, T3 a3) : ptr(member), c(obj), arg1(a1), arg2(a2), arg3(a3) {}
926  ex operator()(const ex & e) override { return (c.*ptr)(e, arg1, arg2, arg3); }
927 };
928 
929 inline ex ex::map(ex f(const ex &)) const
930 {
931  pointer_to_map_function fcn(f);
932  return bp->map(fcn);
933 }
934 
935 // convenience type checker template functions
936 
938 template <class T>
939 inline bool is_a(const ex &obj)
940 {
941  return is_a<T>(*obj.bp);
942 }
943 
945 template <class T>
946 inline bool is_exactly_a(const ex &obj)
947 {
948  return is_exactly_a<T>(*obj.bp);
949 }
950 
961 template <class T>
962 inline const T &ex_to(const ex &e)
963 {
964  GINAC_ASSERT(is_a<T>(e));
965  return static_cast<const T &>(*e.bp);
966 }
967 
968 } // namespace GiNaC
969 
970 
971 // Specializations of Standard Library algorithms
972 namespace std {
973 
975 template <>
976 inline void swap(GiNaC::ex &a, GiNaC::ex &b)
977 {
978  a.swap(b);
979 }
980 
982 template<>
983 struct hash<GiNaC::ex>
984 {
985  std::size_t operator()(const GiNaC::ex & e) const noexcept
986  {
987  return e.gethash();
988  }
989 };
990 
992 template<>
993 struct equal_to<GiNaC::ex>
994 {
995  bool operator()(const GiNaC::ex &e1, const GiNaC::ex &e2) const noexcept
996  {
997  return e1.is_equal(e2);
998  }
999 };
1000 
1001 } // namespace std
1002 
1003 #endif // ndef GINAC_EX_H
GiNaC::const_iterator::operator-=
const_iterator & operator-=(difference_type n) noexcept
Definition: ex.h:443
GiNaC::ex::swap
void swap(ex &other) noexcept
Efficiently swap the contents of two expressions.
Definition: ex.h:104
GiNaC::ex_is_less::operator()
bool operator()(const ex &lh, const ex &rh) const
Definition: ex.h:691
GiNaC::is_a
bool is_a(const basic &obj)
Check if obj is a T, including base classes.
Definition: basic.h:313
GiNaC::pointer_to_map_function::pointer_to_map_function
pointer_to_map_function(ex x(const ex &))
Definition: ex.h:846
GiNaC::pointer_to_member_to_map_function_3args::pointer_to_member_to_map_function_3args
pointer_to_member_to_map_function_3args(ex(C::*member)(const ex &, T1, T2, T3), C &obj, T1 a1, T2 a2, T3 a3)
Definition: ex.h:925
GiNaC::ex::expand
ex expand(unsigned options=0) const
Definition: ex.cpp:73
GiNaC::const_iterator
Definition: ex.h:370
GiNaC::const_postorder_iterator::const_postorder_iterator
const_postorder_iterator(const ex &e, size_t n)
Definition: ex.h:584
GiNaC::ex::postorder_end
const_postorder_iterator postorder_end() const noexcept
Definition: ex.h:672
GiNaC::real_part
ex real_part(const ex &thisex)
Definition: ex.h:721
GiNaC::rhs
ex rhs(const ex &thisex)
Definition: ex.h:817
GiNaC::ex::end
const_iterator end() const noexcept
Definition: ex.h:652
GiNaC::ex::evalf
ex evalf() const
Definition: ex.h:121
GiNaC::const_iterator::i
size_t i
Definition: ex.h:491
GiNaC::const_postorder_iterator::operator!=
bool operator!=(const const_postorder_iterator &other) const noexcept
Definition: ex.h:619
GiNaC::pointer_to_map_function_2args::operator()
ex operator()(const ex &e) override
Definition: ex.h:868
GiNaC::ex::are_ex_trivially_equal
friend bool are_ex_trivially_equal(const ex &, const ex &)
Compare two objects of class quickly without doing a deep tree traversal.
Definition: ex.h:684
r
size_t r
Definition: factor.cpp:770
GiNaC::library_init
Helper class to initialize the library.
Definition: ex.h:50
GiNaC::const_iterator::operator--
const_iterator & operator--() noexcept
Definition: ex.h:430
std::hash< GiNaC::ex >::operator()
std::size_t operator()(const GiNaC::ex &e) const noexcept
Definition: ex.h:985
GiNaC::ex::dbgprint
void dbgprint() const
Little wrapper arount print to be called within a debugger.
Definition: ex.cpp:62
GiNaC::ex::ex_to
friend const T & ex_to(const ex &)
Return a reference to the basic-derived class T object embedded in an expression.
Definition: ex.h:962
GiNaC::ex::to_rational
ex to_rational(exmap &repl) const
Rationalization of non-rational functions.
Definition: normal.cpp:2597
GiNaC::ex::normal
ex normal() const
Normalization of rational functions.
Definition: normal.cpp:2489
GiNaC::pointer_to_map_function_1arg::arg1
T1 arg1
Definition: ex.h:854
GiNaC::ex_is_equal
Definition: ex.h:694
GiNaC::const_preorder_iterator::s
std::stack< internal::_iter_rep, std::vector< internal::_iter_rep > > s
Definition: ex.h:560
GiNaC::symmetrize
ex symmetrize(const ex &thisex)
Definition: ex.h:793
GiNaC::pointer_to_member_to_map_function_2args
Definition: ex.h:905
GiNaC::ex::coeff
ex coeff(const ex &s, int n=1) const
Definition: ex.h:175
GiNaC::pointer_to_member_to_map_function::operator()
ex operator()(const ex &e) override
Definition: ex.h:890
GiNaC::library_init::~library_init
~library_init()
Dtor of static initialization helpers.
Definition: utils.cpp:401
GiNaC::pointer_to_member_to_map_function
Definition: ex.h:884
GiNaC::const_postorder_iterator::operator->
pointer operator->() const
Definition: ex.h:596
GiNaC::_ex0
const ex _ex0
Definition: utils.cpp:177
GiNaC::ex::map
ex map(ex(*f)(const ex &e)) const
GiNaC::ex::get_free_indices
exvector get_free_indices() const
Definition: ex.h:206
GiNaC::ex::has
bool has(const ex &pattern, unsigned options=0) const
Definition: ex.h:151
GiNaC::ex::construct_from_basic
static ptr< basic > construct_from_basic(const basic &other)
Helper function for the ex-from-basic constructor.
Definition: ex.cpp:292
GiNaC::swap
void swap(ex &e1, ex &e2)
Definition: ex.h:823
GiNaC::map_function
Function object for map().
Definition: basic.h:85
GiNaC::const_preorder_iterator::operator->
pointer operator->() const
Definition: ex.h:531
GiNaC::ex::compare
int compare(const ex &other) const
Definition: ex.h:322
GiNaC::pointer_to_member_to_map_function_2args::pointer_to_member_to_map_function_2args
pointer_to_member_to_map_function_2args(ex(C::*member)(const ex &, T1, T2), C &obj, T1 a1, T2 a2)
Definition: ex.h:912
GiNaC::ex::subs
ex subs(const exmap &m, unsigned options=0) const
Definition: ex.h:826
GiNaC::print_context
Base class for print_contexts.
Definition: print.h:103
GiNaC::ex::gethash
unsigned gethash() const
Definition: ex.h:233
GiNaC::const_postorder_iterator::operator++
const_postorder_iterator & operator++()
Definition: ex.h:601
GiNaC::ex::is_exactly_a
friend bool is_exactly_a(const ex &)
Check if ex is a handle to a T, not including base classes.
Definition: ex.h:946
GiNaC::pointer_to_member_to_map_function_3args::arg1
T1 arg1
Definition: ex.h:921
GiNaC::status_flags::dynallocated
@ dynallocated
heap-allocated (i.e. created by new if we want to be clever and bypass the stack,
Definition: flags.h:202
GiNaC::evalf
ex evalf(const ex &thisex)
Definition: ex.h:769
GiNaC::const_iterator::operator<
bool operator<(const const_iterator &other) const noexcept
Definition: ex.h:469
GiNaC::ex::denom
ex denom() const
Get denominator of an expression.
Definition: normal.cpp:2539
GiNaC::const_iterator::operator>
bool operator>(const const_iterator &other) const noexcept
Definition: ex.h:474
GiNaC::pointer_to_map_function
Definition: ex.h:842
GiNaC::ex::traverse_preorder
void traverse_preorder(visitor &v) const
Traverse expression tree with given visitor, preorder traversal.
Definition: ex.cpp:186
GiNaC::ex::conjugate
ex conjugate() const
Definition: ex.h:146
GiNaC::ex::is_a
friend bool is_a(const ex &)
Check if ex is a handle to a T, including base classes.
Definition: ex.h:939
GiNaC::ex::collect
ex collect(const ex &s, bool distributed=false) const
Definition: ex.h:181
GiNaC::exvector
std::vector< ex > exvector
Definition: basic.h:46
GiNaC::ex::nops
size_t nops() const
Definition: ex.h:135
GiNaC::series
ex series(const ex &thisex, const ex &r, int order, unsigned options=0)
Definition: ex.h:781
GiNaC::visitor
Degenerate base class for visitors.
Definition: basic.h:97
GiNaC::pointer_to_member_to_map_function_3args::arg3
T3 arg3
Definition: ex.h:923
GiNaC::diff
ex diff(const ex &thisex, const symbol &s, unsigned nth=1)
Definition: ex.h:778
GiNaC::pointer_to_map_function_3args::ptr
ex(* ptr)(const ex &, T1, T2, T3)
Definition: ex.h:874
GiNaC::const_iterator::operator--
const_iterator operator--(int) noexcept
Definition: ex.h:436
GiNaC::ex::eval
ex eval() const
Definition: ex.h:120
GiNaC::const_iterator::const_iterator
const_iterator(const ex &e_, size_t i_) noexcept
Definition: ex.h:379
GiNaC::ex::degree
int degree(const ex &s) const
Definition: ex.h:173
GiNaC::pointer_to_member_to_map_function_2args::arg2
T2 arg2
Definition: ex.h:910
GiNaC::archive_node
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:49
GiNaC::ex::construct_from_uint
static basic & construct_from_uint(unsigned int i)
Definition: ex.cpp:408
GiNaC::const_iterator::operator+=
const_iterator & operator+=(difference_type n) noexcept
Definition: ex.h:414
GiNaC::ex::construct_from_int
static basic & construct_from_int(int i)
Definition: ex.cpp:350
GiNaC::pointer_to_map_function_3args::arg2
T2 arg2
Definition: ex.h:876
GiNaC::has
bool has(const ex &thisex, const ex &pattern, unsigned options=0)
Definition: ex.h:727
options
unsigned options
Definition: factor.cpp:2480
GiNaC::ex::is_equal
bool is_equal(const ex &other) const
Definition: ex.h:345
GiNaC::pointer_to_member_to_map_function_3args::c
C & c
Definition: ex.h:920
GiNaC::pointer_to_member_to_map_function_1arg::c
C & c
Definition: ex.h:897
GiNaC::ex::dbgprinttree
void dbgprinttree() const
Little wrapper arount printtree to be called within a debugger.
Definition: ex.cpp:68
m
mvec m
Definition: factor.cpp:771
GiNaC::ex::unit
ex unit(const ex &x) const
Compute unit part (= sign of leading coefficient) of a multivariate polynomial in Q[x].
Definition: normal.cpp:923
GiNaC::op0_is_equal
Definition: ex.h:698
GiNaC::ex::primpart
ex primpart(const ex &x) const
Compute primitive part of a multivariate polynomial in Q[x].
Definition: normal.cpp:981
GiNaC::const_iterator::operator++
const_iterator operator++(int) noexcept
Definition: ex.h:407
GiNaC
Definition: add.cpp:38
GiNaC::ex::traverse_postorder
void traverse_postorder(visitor &v) const
Traverse expression tree with given visitor, postorder traversal.
Definition: ex.cpp:196
GiNaC::conjugate
ex conjugate(const ex &thisex)
Definition: ex.h:718
GiNaC::library_init::init_unarchivers
static void init_unarchivers()
Definition: utils.cpp:460
GiNaC::operator<<
std::ostream & operator<<(std::ostream &os, const archive_node &n)
Write archive_node to binary data stream.
Definition: archive.cpp:200
GiNaC::ex::eval_ncmul
ex eval_ncmul(const exvector &v) const
Definition: ex.h:123
GiNaC::const_postorder_iterator::const_postorder_iterator
const_postorder_iterator() noexcept
Definition: ex.h:582
GiNaC::pointer_to_member_to_map_function::pointer_to_member_to_map_function
pointer_to_member_to_map_function(ex(C::*member)(const ex &), C &obj)
Definition: ex.h:889
GiNaC::ex::numer_denom
ex numer_denom() const
Get numerator and denominator of an expression.
Definition: normal.cpp:2564
GiNaC::ex::operator[]
ex operator[](const ex &index) const
Definition: ex.h:137
GiNaC::collect
ex collect(const ex &thisex, const ex &s, bool distributed=false)
Definition: ex.h:763
GiNaC::are_ex_trivially_equal
bool are_ex_trivially_equal(const ex &e1, const ex &e2)
Compare two objects of class quickly without doing a deep tree traversal.
Definition: ex.h:684
GiNaC::ex::symmetrize_cyclic
ex symmetrize_cyclic() const
Symmetrize expression by cyclic permutation over its free indices.
Definition: indexed.cpp:1290
GiNaC::const_iterator::const_iterator
const_iterator() noexcept
Definition: ex.h:376
GiNaC::ex::makewriteable
void makewriteable()
Make this ex writable (if more than one ex handle the same basic) by unlinking the object and creatin...
Definition: ex.cpp:269
x
ex x
Definition: factor.cpp:1641
lr
umodpoly lr[2]
Definition: factor.cpp:1459
GiNaC::ex::smod
ex smod(const numeric &xi) const
Definition: ex.h:202
GiNaC::ex::op
ex op(size_t i) const
Definition: ex.h:136
GiNaC::internal::_iter_rep::e
ex e
Definition: ex.h:509
GiNaC::to_polynomial
ex to_polynomial(const ex &thisex, exmap &repl)
Definition: ex.h:760
GiNaC::ex::construct_from_string_and_lst
static ptr< basic > construct_from_string_and_lst(const std::string &s, const ex &l)
GiNaC::ex::info
bool info(unsigned inf) const
Definition: ex.h:132
GiNaC::library_init::count
static int count
How many static objects were created? Only the first one must create the static flyweights on the hea...
Definition: ex.h:56
GiNaC::internal::_iter_rep
Definition: ex.h:496
GiNaC::ex::match
bool match(const ex &pattern) const
Check whether expression matches a specified pattern.
Definition: ex.cpp:95
GiNaC::ex::construct_from_ulonglong
static basic & construct_from_ulonglong(unsigned long long i)
Definition: ex.cpp:543
GiNaC::ex_swap
Definition: ex.h:702
GiNaC::pointer_to_map_function_3args
Definition: ex.h:872
GiNaC::const_preorder_iterator::operator++
const_preorder_iterator & operator++()
Definition: ex.h:536
GiNaC::find
bool find(const ex &thisex, const ex &pattern, exset &found)
Definition: ex.h:730
GiNaC::ex
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
GiNaC::internal::_iter_rep::operator!=
bool operator!=(const _iter_rep &other) const noexcept
Definition: ex.h:504
GiNaC::ex::accept
void accept(visitor &v) const
Definition: ex.h:166
GiNaC::ex::begin
const_iterator begin() const noexcept
Definition: ex.h:647
GiNaC::normal
ex normal(const ex &thisex)
Definition: ex.h:754
GiNaC::pointer_to_map_function_1arg::ptr
ex(* ptr)(const ex &, T1)
Definition: ex.h:853
GiNaC::const_postorder_iterator::descend
void descend()
Definition: ex.h:627
GiNaC::ex::construct_from_ulong
static basic & construct_from_ulong(unsigned long i)
Definition: ex.cpp:500
GiNaC::pointer_to_map_function_1arg
Definition: ex.h:851
GiNaC::ex::imag_part
ex imag_part() const
Definition: ex.h:148
GiNaC::ex::eval_integ
ex eval_integ() const
Definition: ex.h:124
GiNaC::ex::max_coefficient
numeric max_coefficient() const
Return maximum (absolute value) coefficient of a polynomial.
Definition: normal.cpp:1154
GiNaC::numer
ex numer(const ex &thisex)
Definition: ex.h:745
GiNaC::ex::find
bool find(const ex &pattern, exset &found) const
Find all occurrences of a pattern.
Definition: ex.cpp:105
GiNaC::ex::tcoeff
ex tcoeff(const ex &s) const
Definition: ex.h:177
GiNaC::ex::map
ex map(map_function &f) const
Definition: ex.h:162
GiNaC::ex::diff
ex diff(const symbol &s, unsigned nth=1) const
Compute partial derivative of an expression.
Definition: ex.cpp:86
GiNaC::const_postorder_iterator::operator==
bool operator==(const const_postorder_iterator &other) const noexcept
Definition: ex.h:614
GiNaC::pointer_to_map_function_3args::pointer_to_map_function_3args
pointer_to_map_function_3args(ex x(const ex &, T1, T2, T3), T1 a1, T2 a2, T3 a3)
Definition: ex.h:879
GiNaC::ex::operator[]
ex operator[](size_t i) const
Definition: ex.h:138
GiNaC::pointer_to_member_to_map_function_1arg
Definition: ex.h:894
GiNaC::ex::ldegree
int ldegree(const ex &s) const
Definition: ex.h:174
GiNaC::ex::to_polynomial
ex to_polynomial(exmap &repl) const
Definition: normal.cpp:2602
GiNaC::expand
ex expand(const ex &thisex, unsigned options=0)
Definition: ex.h:715
GiNaC::pointer_to_map_function::operator()
ex operator()(const ex &e) override
Definition: ex.h:847
GiNaC::ex::construct_from_longlong
static basic & construct_from_longlong(long long i)
Definition: ex.cpp:534
GiNaC::ex::construct_from_double
static basic & construct_from_double(double d)
Definition: ex.cpp:552
GiNaC::ex::preorder_end
const_preorder_iterator preorder_end() const noexcept
Definition: ex.h:662
GiNaC::ex::evalm
ex evalm() const
Definition: ex.h:122
GiNaC::ex_is_equal::operator()
bool operator()(const ex &lh, const ex &rh) const
Definition: ex.h:695
GiNaC::const_iterator::operator+
friend const_iterator operator+(difference_type n, const const_iterator &it) noexcept
Definition: ex.h:425
GiNaC::op0_is_equal::operator()
bool operator()(const ex &lh, const ex &rh) const
Definition: ex.h:699
GiNaC::pointer_to_member_to_map_function_1arg::arg1
T1 arg1
Definition: ex.h:898
GiNaC::const_postorder_iterator::s
std::stack< internal::_iter_rep, std::vector< internal::_iter_rep > > s
Definition: ex.h:625
GiNaC::scalar_products
Helper class for storing information about known scalar products which are to be automatically replac...
Definition: indexed.h:227
GiNaC::ex::match
bool match(const ex &pattern, exmap &repls) const
Definition: ex.h:154
GiNaC::ex::print
void print(const print_context &c, unsigned level=0) const
Print expression to stream.
Definition: ex.cpp:56
GiNaC::eval
ex eval(const ex &thisex)
Definition: ex.h:766
GiNaC::const_postorder_iterator::operator*
reference operator*() const
Definition: ex.h:591
GiNaC::ex_to
const T & ex_to(const ex &e)
Return a reference to the basic-derived class T object embedded in an expression.
Definition: ex.h:962
GiNaC::ex::real_part
ex real_part() const
Definition: ex.h:147
GiNaC::ex::unitcontprim
void unitcontprim(const ex &x, ex &u, ex &c, ex &p) const
Compute unit part, content part, and primitive part of a multivariate polynomial in Q[x].
Definition: normal.cpp:1022
GiNaC::const_preorder_iterator
Definition: ex.h:516
GiNaC::ex::return_type_tinfo
return_type_t return_type_tinfo() const
Definition: ex.h:231
GiNaC::return_type_t
To distinguish between different kinds of non-commutative objects.
Definition: registrar.h:44
GiNaC::const_preorder_iterator::increment
void increment()
Definition: ex.h:562
GiNaC::denom
ex denom(const ex &thisex)
Definition: ex.h:748
GiNaC::ldegree
int ldegree(const ex &thisex, const ex &s)
Definition: ex.h:739
GiNaC::const_preorder_iterator::operator!=
bool operator!=(const const_preorder_iterator &other) const noexcept
Definition: ex.h:554
GiNaC::is_exactly_a
bool is_exactly_a(const basic &obj)
Check if obj is a T, not including base classes.
Definition: basic.h:320
GiNaC::ex::rhs
ex rhs() const
Right hand side of relational expression.
Definition: ex.cpp:233
GiNaC::match
bool match(const ex &thisex, const ex &pattern, exmap &repl_lst)
Definition: ex.h:784
GiNaC::exset
std::set< ex, ex_is_less > exset
Definition: basic.h:49
GiNaC::to_rational
ex to_rational(const ex &thisex, exmap &repl)
Definition: ex.h:757
GiNaC::library_init::library_init
library_init()
Ctor of static initialization helpers.
Definition: utils.cpp:277
GiNaC::const_preorder_iterator::operator++
const_preorder_iterator operator++(int)
Definition: ex.h:542
GiNaC::op
ex op(const ex &thisex, size_t i)
Definition: ex.h:811
GiNaC::pointer_to_map_function_3args::arg3
T3 arg3
Definition: ex.h:877
GiNaC::ex::preorder_begin
const_preorder_iterator preorder_begin() const
Definition: ex.h:657
GiNaC::container
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
GiNaC::pointer_to_map_function_1arg::pointer_to_map_function_1arg
pointer_to_map_function_1arg(ex x(const ex &, T1), T1 a1)
Definition: ex.h:856
GiNaC::ex::antisymmetrize
ex antisymmetrize() const
Antisymmetrize expression over its free indices.
Definition: indexed.cpp:1284
GiNaC::const_iterator::operator>=
bool operator>=(const const_iterator &other) const noexcept
Definition: ex.h:484
std::equal_to< GiNaC::ex >::operator()
bool operator()(const GiNaC::ex &e1, const GiNaC::ex &e2) const noexcept
Definition: ex.h:995
GiNaC::ex::is_zero_matrix
bool is_zero_matrix() const
Check whether expression is zero or zero matrix.
Definition: ex.cpp:255
GiNaC::pointer_to_member_to_map_function_2args::arg1
T1 arg1
Definition: ex.h:909
c
size_t c
Definition: factor.cpp:770
GiNaC::exmap
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
GiNaC::pointer_to_member_to_map_function_2args::operator()
ex operator()(const ex &e) override
Definition: ex.h:913
GiNaC::pointer_to_map_function::ptr
ex(* ptr)(const ex &)
Definition: ex.h:844
GiNaC::ex::series
ex series(const ex &r, int order, unsigned options=0) const
Compute the truncated series expansion of an expression.
Definition: pseries.cpp:1259
GiNaC::imag_part
ex imag_part(const ex &thisex)
Definition: ex.h:724
GiNaC::pointer_to_member_to_map_function_3args
Definition: ex.h:917
GiNaC::ex::lcoeff
ex lcoeff(const ex &s) const
Definition: ex.h:176
GiNaC::const_iterator::operator->
std::unique_ptr< ex > operator->() const
Definition: ex.h:391
GiNaC::coeff
ex coeff(const ex &thisex, const ex &s, int n=1)
Definition: ex.h:742
GiNaC::pointer_to_map_function_2args::ptr
ex(* ptr)(const ex &, T1, T2)
Definition: ex.h:863
GiNaC::pointer_to_member_to_map_function::c
C & c
Definition: ex.h:887
GiNaC::const_iterator::operator+
const_iterator operator+(difference_type n) const noexcept
Definition: ex.h:420
GiNaC::degree
int degree(const ex &thisex, const ex &s)
Definition: ex.h:736
GiNaC::eval_integ
ex eval_integ(const ex &thisex)
Definition: ex.h:775
GiNaC::pointer_to_map_function_1arg::operator()
ex operator()(const ex &e) override
Definition: ex.h:857
GiNaC::numer_denom
ex numer_denom(const ex &thisex)
Definition: ex.h:751
GiNaC::pointer_to_map_function_3args::arg1
T1 arg1
Definition: ex.h:875
GiNaC::internal::_iter_rep::_iter_rep
_iter_rep(const ex &e_, size_t i_, size_t i_end_)
Definition: ex.h:497
basic.h
Interface to GiNaC's ABC.
GiNaC::const_iterator::e
ex e
Definition: ex.h:490
std
Definition: ex.h:972
GiNaC::ex::postorder_begin
const_postorder_iterator postorder_begin() const
Definition: ex.h:667
GiNaC::symbol
Basic CAS symbol.
Definition: symbol.h:39
GiNaC::const_preorder_iterator::operator*
reference operator*() const
Definition: ex.h:526
GiNaC::const_iterator::operator-
friend difference_type operator-(const const_iterator &lhs, const const_iterator &rhs) noexcept
Definition: ex.h:454
GiNaC::subs
ex subs(const ex &thisex, const exmap &m, unsigned options=0)
Definition: ex.h:831
GiNaC::lhs
ex lhs(const ex &thisex)
Definition: ex.h:814
n
size_t n
Definition: factor.cpp:1463
GiNaC::pointer_to_map_function_2args::arg1
T1 arg1
Definition: ex.h:864
GiNaC::ex::share
void share(const ex &other) const
Share equal objects between expressions.
Definition: ex.cpp:278
GiNaC::internal::_iter_rep::i
size_t i
Definition: ex.h:510
GiNaC::const_preorder_iterator::const_preorder_iterator
const_preorder_iterator() noexcept
Definition: ex.h:518
GiNaC::ex::is_polynomial
bool is_polynomial(const ex &vars) const
Check whether expression is a polynomial.
Definition: ex.cpp:241
GiNaC::is_zero
bool is_zero(const ex &thisex)
Definition: ex.h:820
GiNaC::is_polynomial
bool is_polynomial(const ex &thisex, const ex &vars)
Definition: ex.h:733
GiNaC::basic
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:105
GiNaC::const_postorder_iterator::increment
void increment()
Definition: ex.h:636
GiNaC::const_preorder_iterator::const_preorder_iterator
const_preorder_iterator(const ex &e, size_t n)
Definition: ex.h:520
GiNaC::pointer_to_member_to_map_function_3args::operator()
ex operator()(const ex &e) override
Definition: ex.h:926
GiNaC::ex::symmetrize
ex symmetrize() const
Symmetrize expression over its free indices.
Definition: indexed.cpp:1278
GiNaC::const_iterator::operator!=
bool operator!=(const const_iterator &other) const noexcept
Definition: ex.h:464
GiNaC::ex::is_zero
bool is_zero() const
Definition: ex.h:213
GiNaC::ex::ex
ex() noexcept
Definition: ex.h:262
GiNaC::symmetrize_cyclic
ex symmetrize_cyclic(const ex &thisex)
Definition: ex.h:805
GiNaC::const_iterator::operator-
const_iterator operator-(difference_type n) const noexcept
Definition: ex.h:449
GiNaC::evalm
ex evalm(const ex &thisex)
Definition: ex.h:772
GiNaC::antisymmetrize
ex antisymmetrize(const ex &thisex)
Definition: ex.h:799
std::swap
void swap(GiNaC::ex &a, GiNaC::ex &b)
Specialization of std::swap() for ex objects.
Definition: ex.h:976
GiNaC::pointer_to_map_function_2args
Definition: ex.h:861
GiNaC::ex_swap::operator()
void operator()(ex &lh, ex &rh) const
Definition: ex.h:703
GiNaC::const_iterator::operator<=
bool operator<=(const const_iterator &other) const noexcept
Definition: ex.h:479
GiNaC::ex::simplify_indexed
ex simplify_indexed(unsigned options=0) const
Simplify/canonicalize expression containing indexed objects.
Definition: indexed.cpp:1256
GiNaC::const_postorder_iterator::operator++
const_postorder_iterator operator++(int)
Definition: ex.h:607
GiNaC::const_iterator::operator++
const_iterator & operator++() noexcept
Definition: ex.h:401
GiNaC::ex::return_type
unsigned return_type() const
Definition: ex.h:230
GiNaC::ex::numer
ex numer() const
Get numerator of an expression.
Definition: normal.cpp:2514
GiNaC::nops
size_t nops(const ex &thisex)
Definition: ex.h:712
GiNaC::ptr
Class of (intrusively) reference-counted pointers that support copy-on-write semantics.
Definition: ptr.h:56
GiNaC::const_postorder_iterator
Definition: ex.h:580
GiNaC::const_iterator::operator==
bool operator==(const const_iterator &other) const noexcept
Definition: ex.h:459
ptr.h
Reference-counted pointer template.
GiNaC::pointer_to_member_to_map_function_1arg::operator()
ex operator()(const ex &e) override
Definition: ex.h:901
GiNaC::internal::_iter_rep::operator==
bool operator==(const _iter_rep &other) const noexcept
Definition: ex.h:499
GiNaC::const_iterator::operator[]
ex operator[](difference_type n) const
Definition: ex.h:396
GiNaC::library_initializer
static library_init library_initializer
For construction of flyweights, etc.
Definition: ex.h:59
GiNaC::ex::bp
ptr< basic > bp
pointer to basic object managed by this
Definition: ex.h:251
GiNaC::internal::_iter_rep::i_end
size_t i_end
Definition: ex.h:511
order
int order
Definition: integration_kernel.cpp:248
GiNaC::pointer_to_member_to_map_function_1arg::pointer_to_member_to_map_function_1arg
pointer_to_member_to_map_function_1arg(ex(C::*member)(const ex &, T1), C &obj, T1 a1)
Definition: ex.h:900
GiNaC::ex::integer_content
numeric integer_content() const
Compute the integer content (= GCD of all numeric coefficients) of an expanded polynomial.
Definition: normal.cpp:318
GiNaC::ex::let_op
ex & let_op(size_t i)
Return modifiable operand/member at position i.
Definition: ex.cpp:206
GiNaC::simplify_indexed
ex simplify_indexed(const ex &thisex, unsigned options=0)
Definition: ex.h:787
GiNaC::ex::content
ex content(const ex &x) const
Compute content part (= unit normal GCD of all coefficients) of a multivariate polynomial in Q[x].
Definition: normal.cpp:945
GiNaC::const_iterator::operator*
ex operator*() const
Definition: ex.h:384
GiNaC::numeric
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Definition: numeric.h:82
GINAC_ASSERT
#define GINAC_ASSERT(X)
Assertion macro for checking invariances.
Definition: assertion.h:33
GiNaC::_num0_bp
const basic * _num0_bp
Definition: utils.cpp:176
GiNaC::const_iterator::ex
friend class ex
Definition: ex.h:371
GiNaC::ex_is_less
Definition: ex.h:690
GiNaC::ex::lhs
ex lhs() const
Left hand side of relational expression.
Definition: ex.cpp:225
GiNaC::ex::construct_from_long
static basic & construct_from_long(long i)
Definition: ex.cpp:442
GiNaC::pointer_to_map_function_3args::operator()
ex operator()(const ex &e) override
Definition: ex.h:880
GiNaC::pointer_to_member_to_map_function_2args::c
C & c
Definition: ex.h:908
GiNaC::pointer_to_member_to_map_function_3args::arg2
T2 arg2
Definition: ex.h:922
GiNaC::const_preorder_iterator::operator==
bool operator==(const const_preorder_iterator &other) const noexcept
Definition: ex.h:549
GiNaC::ex::traverse
void traverse(visitor &v) const
Definition: ex.h:169
GiNaC::pointer_to_map_function_2args::pointer_to_map_function_2args
pointer_to_map_function_2args(ex x(const ex &, T1, T2), T1 a1, T2 a2)
Definition: ex.h:867
GiNaC::pointer_to_map_function_2args::arg2
T2 arg2
Definition: ex.h:865

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.