[GiNaC-devel] [PATCH] fast check for expanded expressions: introduce info_flags::expanded.

Alexei Sheplyakov varg at theor.jinr.ru
Fri Aug 17 08:41:11 CEST 2007


Dear all,

Sometimes it would be nice to check if the expression is already expanded.
This information is cached by GiNaC, but the user code had no access to it.

---
 ginac/expairseq.cpp |    2 ++
 ginac/flags.h       |    5 ++++-
 ginac/numeric.cpp   |    1 +
 ginac/power.cpp     |    2 ++
 ginac/symbol.cpp    |    3 ++-
 5 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp
index 4dffafa..757f3c3 100644
--- a/ginac/expairseq.cpp
+++ b/ginac/expairseq.cpp
@@ -267,6 +267,8 @@ void expairseq::do_print_tree(const print_tree & c, unsigned level) const
 
 bool expairseq::info(unsigned inf) const
 {
+	if (inf == info_flags::expanded)
+		return (flags & status_flags::expanded);
 	return inherited::info(inf);
 }
 
diff --git a/ginac/flags.h b/ginac/flags.h
index a416958..86d8238 100644
--- a/ginac/flags.h
+++ b/ginac/flags.h
@@ -250,7 +250,10 @@ public:
 		has_indices,  // object has at least one index
 
 		// answered by class idx
-		idx
+		idx,
+
+		// answered by classes numeric, symbol, add, mul, power
+		expanded
 	};
 };
 
diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp
index 1858cbd..ef61ce7 100644
--- a/ginac/numeric.cpp
+++ b/ginac/numeric.cpp
@@ -576,6 +576,7 @@ bool numeric::info(unsigned inf) const
 		case info_flags::numeric:
 		case info_flags::polynomial:
 		case info_flags::rational_function:
+		case info_flags::expanded:
 			return true;
 		case info_flags::real:
 			return is_real();
diff --git a/ginac/power.cpp b/ginac/power.cpp
index 8829bba..faaef18 100644
--- a/ginac/power.cpp
+++ b/ginac/power.cpp
@@ -231,6 +231,8 @@ bool power::info(unsigned inf) const
 		case info_flags::algebraic:
 			return !exponent.info(info_flags::integer) ||
 			       basis.info(inf);
+		case info_flags::expanded:
+			return (flags & status_flags::expanded);
 	}
 	return inherited::info(inf);
 }
diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp
index a84ae4a..9f3b1c6 100644
--- a/ginac/symbol.cpp
+++ b/ginac/symbol.cpp
@@ -214,7 +214,8 @@ bool symbol::info(unsigned inf) const
 	    inf == info_flags::cinteger_polynomial ||
 	    inf == info_flags::rational_polynomial ||
 	    inf == info_flags::crational_polynomial ||
-	    inf == info_flags::rational_function)
+	    inf == info_flags::rational_function ||
+			inf == info_flags::expanded)
 		return true;
 	if (inf == info_flags::real)
 		return domain==domain::real || domain==domain::positive;
-- 
1.4.4.4

Best regards,
 Alexei

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-devel/attachments/20070817/0f359a02/attachment.pgp


More information about the GiNaC-devel mailing list