Commits

Volker Braun committed 1d39831

missed two files

Comments (0)

Files changed (3)

+# HG changeset patch
+# Parent 7c20443cf59b8ec0d0b58b50a5fd5a69324666d0
+Add method to ex for counting number of symbols in an expression.
+
+diff --git a/ginac/ex.cpp b/ginac/ex.cpp
+--- a/ginac/ex.cpp
++++ b/ginac/ex.cpp
+@@ -21,6 +21,7 @@
+  */
+ 
+ #include "ex.h"
++#include "symbol.h"
+ #include "add.h"
+ #include "mul.h"
+ #include "ncmul.h"
+@@ -265,6 +266,18 @@
+ 	}
+ }
+ 
++size_t ex::nsymbols() const
++{
++	int res = 0;
++	if (is_a<symbol>(*this)) {
++		res=1;
++	} else {
++		for (size_t i=0; i < nops(); i++)
++			res += op(i).nsymbols();
++	}
++	return res;
++}
++
+ // private
+ 
+ /** Make this ex writable (if more than one ex handle the same basic) by 
+diff --git a/ginac/ex.h b/ginac/ex.h
+--- a/ginac/ex.h
++++ b/ginac/ex.h
+@@ -143,6 +143,7 @@
+ 
+ 	// operand access
+ 	size_t nops() const { return bp->nops(); }
++	size_t nsymbols() const;
+ 	ex op(size_t i) const { return bp->op(i); }
+ 	ex operator[](const ex & index) const { return (*bp)[index]; }
+ 	ex operator[](size_t i) const { return (*bp)[i]; }
+# HG changeset patch
+# Parent 6425f0c03d0211d3a58a7d259045bf9ad6fdeaf3
+Add ex::sorted_op() function which indexes sequence sorted with printing order.
+
+diff --git a/ginac/ex.cpp b/ginac/ex.cpp
+--- a/ginac/ex.cpp
++++ b/ginac/ex.cpp
+@@ -278,6 +278,13 @@
+ 	return res;
+ }
+ 
++ex ex::sorted_op(size_t i) const
++{
++	if (is_a<expairseq>(*this))
++		return dynamic_cast<const expairseq&>(*bp).stable_op(i);
++	else
++		return bp->op(i);
++}
+ // private
+ 
+ /** Make this ex writable (if more than one ex handle the same basic) by 
+diff --git a/ginac/ex.h b/ginac/ex.h
+--- a/ginac/ex.h
++++ b/ginac/ex.h
+@@ -145,6 +145,7 @@
+ 	size_t nops() const { return bp->nops(); }
+ 	size_t nsymbols() const;
+ 	ex op(size_t i) const { return bp->op(i); }
++	ex sorted_op(size_t i) const;
+ 	ex operator[](const ex & index) const { return (*bp)[index]; }
+ 	ex operator[](size_t i) const { return (*bp)[i]; }
+ 	ex & let_op(size_t i);
+diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp
+--- a/ginac/expairseq.cpp
++++ b/ginac/expairseq.cpp
+@@ -308,6 +308,16 @@
+ 	return overall_coeff;
+ }
+ 
++ex expairseq::stable_op(size_t i) const
++{
++	if (i < seq.size()) {
++		const epvector* sorted_seq = get_sorted_seq();
++		return recombine_pair_to_ex((*sorted_seq)[i]);
++	}
++	GINAC_ASSERT(!overall_coeff.is_equal(default_overall_coeff()));
++	return overall_coeff;
++}
++
+ ex expairseq::map(map_function &f) const
+ {
+ 	std::auto_ptr<epvector> v(new epvector);
+diff --git a/ginac/expairseq.h b/ginac/expairseq.h
+--- a/ginac/expairseq.h
++++ b/ginac/expairseq.h
+@@ -83,6 +83,7 @@
+ 	bool info(unsigned inf) const;
+ 	size_t nops() const;
+ 	ex op(size_t i) const;
++	virtual ex stable_op(size_t i) const;
+ 	ex map(map_function & f) const;
+ 	ex eval(int level=0) const;
+ 	ex to_rational(exmap & repl) const;
+@@ -91,6 +92,7 @@
+ 	ex subs(const exmap & m, unsigned options = 0) const;
+ 	ex conjugate() const;
+ 	numeric calc_total_degree() const;
++	virtual const epvector* get_sorted_seq() const { return &seq; }
+ protected:
+ 	bool is_equal_same_type(const basic & other) const;
+ 	unsigned return_type() const;
+cc1cb9baa5690cc0d6318340289ff7525325ae87:trac9880_pynac_order_burcin_original.patch
+9f0de2356c31320bc122ffe6e95766f10bc54fff:trac_9880-pynac_order_jp_new-p2.take2.patch
+186f9cd8d33408119c5dc84f942888c5fd2634bc:trac_9880-cleanup.patch
+89911ae89f2fd310278c2753341ca32dc14dce57:num_symbol.patch
+efa0c809083471572fa6b410242777f3021c2091:stable_op.patch
+d6d015a808e1fa61073c669d422a8309891d2d26:trac_9880_ginac_infinities_rewrite.patch