Project

General

Profile

Wiki » History » Version 11

Thomas Capricelli, 12/07/2009 11:09 AM

1 7 Thomas Capricelli
{{toc}}
2
3
h1. Description
4
5 1 Thomas Capricelli
Symia is a piece of software that helps programmers to perform "symbolic computation":http://en.wikipedia.org/wiki/Symbolic_computation, also known as *symbolic calculs*. The main characteristics are
6
* Symia is a library : the target audience is programmers.
7
* Symia is written in C++.
8
* Symia is released under the "GNU Lesser General Public License":http://en.wikipedia.org/wiki/LGPL, so that even close-source software can make use of it.
9 2 Thomas Capricelli
* Symia uses "unit tests":http://en.wikipedia.org/wiki/Unit_testing as a mean to prevent regression, to ensure robustness, and to provide working examples that the user can rely on.
10 1 Thomas Capricelli
11
The only other C++ library we are aware of is "Ginac":http://en.wikipedia.org/wiki/GiNaC, which is released under the "GNU General Public License":http://en.wikipedia.org/wiki/Gpl, which prevent it from being used in the industry.
12
13 2 Thomas Capricelli
Symia is far from being able to do as much as, say, Maple or Ginac, but if your needs are basic, you can rely on the robust and "tested":http://en.wikipedia.org/wiki/Unit_testing Symia library.
14 1 Thomas Capricelli
15 9 Thomas Capricelli
Symia is developed and released by "Sylphide Consulting":http://www.sylphide-consulting.com. If you need some more features in Symia, you can either abandon the idea of using Symia, implement the missing features by yourself (and provide the code back, as the "GNU LGPL":http://en.wikipedia.org/wiki/LGPL says), or pay someone to do the job. Of course, *Sylphide Consulting* is an obvious choice for such a task, and we would be delighted if you "contact us":http://www.sylphide-consulting.com/contact about it.
16 3 Thomas Capricelli
17
18
h1. Design
19
20 11 Thomas Capricelli
The design is the same as most software performing symbolic calculus. A "class tree":http://labs.freehackers.org/embedded/symia/inherits.html of objects implement constants, variables, basic operations and function. A generic class "Expression" is used to keep track of allocated objects and is the basic element manipulated by the user.
21 3 Thomas Capricelli
22
h1. Examples
23
24 4 Thomas Capricelli
The following code highlights the most important features of Symia.
25 3 Thomas Capricelli
26
<pre><code class="c">
27
{
28
    Expression x("x"), y("y"), a("a"), b("b"), c("c"); // create symbols
29
30
    // Operators and most classical functions are overloaded, so you can construct
31 10 Thomas Capricelli
    // complex expressions the way you expect.
32 3 Thomas Capricelli
    Expression e = a*x+b*x*x*exp(-c*(x+1)/(x*x));
33
34 1 Thomas Capricelli
    // Helpers are provided to display an expression
35 3 Thomas Capricelli
    QString e_as_text = e.toString(); 
36 6 Thomas Capricelli
    // now e_as_text is "a*x+b*x*x*exp(-c*(x+1)/(x*x))"
37 3 Thomas Capricelli
38 10 Thomas Capricelli
    // You can substitute an expression to any symbol
39 5 Thomas Capricelli
    e = e.replace(x, b+log(c))
40 3 Thomas Capricelli
    // e now is "a*(b+log(c))+b*(b+log(c))*(b+log(c))*exp(-c*(b+log(c)+1)/((b+log(c))*(b+log(c))))"
41 10 Thomas Capricelli
    // yes, this is ugly, and this is the reason what you are happy a computer handles it for you.
42 3 Thomas Capricelli
43
    // Evaluation is about using replace() as well
44
    e = e.replace(a,-3).replace(c,1).replace(b,.78);
45
    // e now is "-2.31455"
46
}
47
</code></pre>
48 1 Thomas Capricelli
49 11 Thomas Capricelli
h1. Dependencies
50 1 Thomas Capricelli
51 11 Thomas Capricelli
The library depends only on the standard c++ library. It is tested under unix/linux and windows using several compilers (gcc, icc, msvc). The library makes use of flex/bison to generate the parser, but the generated files are included for convenience.
52
53
The build system is "cmake":http://en.wikipedia.org/wiki/Cmake. 
54
55
The unit tests are based on "Nokia QtestLib":http://doc.trolltech.com/4.6/qtestlib-manual.html and will detect if Qt tests are present on your system. If found, then the tests are compiled.
56
57
h1. Compilation
58
59
This is a quick description of the steps needed to compile symia. If you know cmake already, this is the typical cmake stuff.
60
61
You need to create a 'build' directory, from which to start cmake. 'build' is often put in the main symia directory, but you dont have to
62
63
<pre>
64
symia-0.x$ mkdir build
65
symia-0.x/build$ cd build
66
symia-0.x/build$ cmake .. # you need to give cmake the path to the root of the symia source tree, here '..'
67
symia-0.x/build$ make
68
</pre>
69
70
If the QTestLib is present, the tests are built in build/tests/, you can check them by issuing:
71
72
<pre>
73
symia-0.x/build$ ./tests/tests
74
********* Start testing of Symia::TestSymia *********
75
Config: Using QTest library 4.6.0, Qt 4.6.0
76
PASS   : Symia::TestSymia::initTestCase()
77
PASS   : Symia::TestSymia::teststdstream()
78
PASS   : Symia::TestSymia::testElement()
79
PASS   : Symia::TestSymia::testBinaryOperators()
80
PASS   : Symia::TestSymia::testFunctions()
81
PASS   : Symia::TestSymia::testDebug()
82
PASS   : Symia::TestSymia::testReplace()
83
PASS   : Symia::TestSymia::testSimplify()
84
PASS   : Symia::TestSymia::testEvaluation()
85
PASS   : Symia::TestSymia::testDerivative()
86
PASS   : Symia::TestSymia::testRegression1()
87
PASS   : Symia::TestSymia::testParser()
88
PASS   : Symia::TestSymia::cleanupTestCase()
89
Totals: 13 passed, 0 failed, 0 skipped
90
********* Finished testing of Symia::TestSymia *********
91
</pre>
92
93
94 1 Thomas Capricelli
h1. Frequently Asked Questions
95
96 11 Thomas Capricelli
h2. Where does the name come from ?
97
98
This is short for *symbolia*, which has already too much hits in google.