From 53554b01d52e271a6f2b02098a507ccff75e7862 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Fri, 8 Dec 2000 03:41:56 +0000 Subject: [PATCH] - Eduardo Kalinowskis documentation add-on. --- doc/tutorial/ginac.texi | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index 5183e465..ce2e7b95 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -1300,6 +1300,9 @@ avoided. @subsection Checking expression types @cindex @code{is_ex_of_type()} +@cindex @code{ex_to_numeric()} +@cindex @code{ex_to_@dots{}} +@cindex @code{Converting ex to other classes} @cindex @code{info()} Sometimes it's useful to check whether a given expression is a plain number, @@ -1311,6 +1314,20 @@ bool is_ex_of_type(const ex & e, TYPENAME t); bool ex::info(unsigned flag); @end example +When the test made by @code{is_ex_of_type()} returns true, it is safe to +call one of the functions @code{ex_to_@dots{}}, where @code{@dots{}} is +one of the class names (@xref{The Class Hierarchy}, for a list of all +classes). For example, assuming @code{e} is an @code{ex}: + +@example +@{ + @dots{} + if (is_ex_of_type(e, numeric)) + numeric n = ex_to_numeric(e); + @dots{} +@} +@end example + @code{is_ex_of_type()} allows you to check whether the top-level object of an expression @samp{e} is an instance of the GiNaC class @samp{t} (@xref{The Class Hierarchy}, for a list of all classes). This is most useful, -- 2.44.0