tools/Makefile
tools/viewgar.1
doc/Makefile
+doc/examples/Makefile
doc/tutorial/Makefile
doc/reference/Makefile
doc/reference/DoxyfileHTML
## Process this file with automake to produce Makefile.in
-SUBDIRS = tutorial reference
+SUBDIRS = tutorial reference examples
--- /dev/null
+## Process this file with automake to produce Makefile.in
+
+EXFILES = archive1.cpp
+
+TEXINFO_TEX = ../tutorial/texinfo.tex
+
+info_TEXINFOS = ginac-examples.texi
+
+all: $(EXFILES)
+ ${MAKEINFO} --no-split --no-headers $(srcdir)/ginac-examples.texi > ginac-examples.txt
+ ${MAKEINFO} --no-split --html $(srcdir)/ginac-examples.texi
+
+EXTRA_DIST = $(EXFILES)
--- /dev/null
+/*
+ * Archiving code example from the tutorial
+ */
+
+#include <fstream>
+using namespace std;
+#include <ginac/ginac.h>
+using namespace GiNaC;
+
+int main()
+{
+ symbol x("x"), y("y"), z("z");
+
+ // do some math
+
+ ex foo = sin(x + 2*y) + 3*z + 41;
+ ex bar = foo + 1;
+
+ // write the archive
+
+ archive a;
+ a.archive_ex(foo, "foo");
+ a.archive_ex(bar, "the second one");
+
+ ofstream out("foobar.gar");
+ out << a;
+ out.close();
+
+ // read in the archive
+
+ archive a2;
+ ifstream in("foobar.gar");
+ in >> a2;
+
+ lst syms;
+ syms = x, y;
+
+ ex ex1 = a2.unarchive_ex(syms, "foo");
+ ex ex2 = a2.unarchive_ex(syms, "the second one");
+
+ // do some math again
+
+ cout << ex1 << endl; // prints "41+sin(x+2*y)+3*z"
+ cout << ex2 << endl; // prints "42+sin(x+2*y)+3*z"
+ cout << ex1.subs(x == 2) << endl; // prints "41+sin(2+2*y)+3*z"
+}
+
--- /dev/null
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename ginac-examples.info
+@settitle GiNaC Examples
+@afourpaper
+@c For `info' only.
+@paragraphindent 0
+@c For TeX only.
+@iftex
+@c I hate putting "@noindent" in front of every paragraph.
+@parindent=0pt
+@end iftex
+@c %**end of header
+@ifnottex
+@node Top
+@end ifnottex
+
+@finalout
+@c finalout prevents ugly black rectangles on overfull hbox lines
+
+@majorheading GiNaC Examples
+
+This is a collection of code examples using GiNaC.
+
+@contents
+
+@chapter Input / Output
+
+@section Archiving expressions @uref{archive1.cpp, (source)}
+
+Two expression are stored in an archive on the disk and are restored again.
+
+@bye