]> www.ginac.de Git - ginac.git/commitdiff
New directory for GiNaC examples.
authorJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Tue, 6 Dec 2005 14:41:13 +0000 (14:41 +0000)
committerJens Vollinga <vollinga@thep.physik.uni-mainz.de>
Tue, 6 Dec 2005 14:41:13 +0000 (14:41 +0000)
configure.ac
doc/Makefile.am
doc/examples/Makefile.am [new file with mode: 0644]
doc/examples/archive1.cpp [new file with mode: 0644]
doc/examples/ginac-examples.texi [new file with mode: 0644]

index 1ca64109cda0aa7b2c5f22d4976e654c8929b363..7005c94691ba02289bcc49abaabc35596a582558 100644 (file)
@@ -155,6 +155,7 @@ ginsh/ginsh.1
 tools/Makefile
 tools/viewgar.1
 doc/Makefile
 tools/Makefile
 tools/viewgar.1
 doc/Makefile
+doc/examples/Makefile
 doc/tutorial/Makefile
 doc/reference/Makefile
 doc/reference/DoxyfileHTML
 doc/tutorial/Makefile
 doc/reference/Makefile
 doc/reference/DoxyfileHTML
index e5de20e3b40cf3ba4fa6f991c29a6f4928ec1378..e6b93210f82c7e6fe2d1afc661c5e983847f61bb 100644 (file)
@@ -1,2 +1,2 @@
 ## Process this file with automake to produce Makefile.in
 ## Process this file with automake to produce Makefile.in
-SUBDIRS = tutorial reference
+SUBDIRS = tutorial reference examples
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
new file mode 100644 (file)
index 0000000..c88a821
--- /dev/null
@@ -0,0 +1,13 @@
+## 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)
diff --git a/doc/examples/archive1.cpp b/doc/examples/archive1.cpp
new file mode 100644 (file)
index 0000000..c20db62
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ *  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"
+}
+
diff --git a/doc/examples/ginac-examples.texi b/doc/examples/ginac-examples.texi
new file mode 100644 (file)
index 0000000..200c81e
--- /dev/null
@@ -0,0 +1,33 @@
+\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