and another Re: doc patch
Ralf Stephan
ralf at ark.in-berlin.de
Thu Jun 10 19:28:53 CEST 2004
Should I subscribe to the dev-list? Here is a correction and
a suggestion in the patch, the latter just a hint what errors
are being made by newbies. If you don't like it, reformulate.
ralf
--- ginac.texi.orig Mon Mar 15 18:47:17 2004
+++ ginac.texi Thu Jun 10 19:21:26 2004
@@ -4293,7 +4293,7 @@
@example
@{
- symbol a("a"), b("b"), c("c");
+ symbol a("a"), b("b"), c("c"), x("x");
idx i(symbol("i"), 3);
ex e = pow(sin(x) - cos(x), 4);
@@ -4309,6 +4309,34 @@
@}
@end example
+This is a good place to remind you that symbols are not uniquely identified
+by their string representation but by the C++ variable they were assigned to.
+This means that the first of the following two examples will not output 6
+but 0:
+
+ at example
+@{
+ ex f(int n) @{ symbol x("x"); return pow(x+1,n); @}
+ ...
+ symbol x("x");
+ ...
+ cout << f(6).degree(x) << endl; // WRONG
+@}
+ at end example
+
+For clarity, efficiency, and modularity, it should have been coded:
+
+ at example
+@{
+ ex f(int n, symbol& x) @{ return pow(x+1,n); @}
+ ...
+ symbol x("x");
+ ...
+ cout << f(6,x).degree(x) << endl; // RIGHT
+@}
+ at end example
+
+
@subsection Polynomial division
@cindex polynomial division
More information about the GiNaC-list
mailing list