~neon/analitza/master

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
/*
Main page of docs for analitza library.
Copyright (C) 2013 by Percy Camilo Triveño Aucahuasi <percy.camilo.ta@gmail.com>
Distributed under the LGPL.
*/

/** \mainpage Analitza - KDE Mathematical Library

<p><b>
Overview |
\ref getting_started "Getting Started" |
\ref tutorials "Tutorials" |
\ref examples_showcases "Examples and Showcases"
</b></p>

Analitza is a library that work with mathematical objects. Analitza add 
mathematical features to your program, such as symbolic 
computations and some numerical methods; for instance the library
can parse mathematical expressions and let you evaluate and draw them. 

Development of Analitza take place in 
<a href="https://commits.kde.org/analitza">this</a> 
repository.

\section modules Modules

The library consists of the following modules:

\li \ref AnalitzaModule "Analitza" is the core module, it is the parser of 
mathematical expressions.
\li \ref AnalitzaPlotModule "AnalitzaPlot" let you draw mathematical objects 
like functions, equations, etc.
\li \ref AnalitzaGUIModule "AnalitzaGUI" several UI components based on 
QWidget and QML.

\ref AnalitzaGUIModule "AnalitzaGUI" depends of 
\ref AnalitzaPlotModule "AnalitzaPlot" and \ref AnalitzaPlotModule "AnalitzaPlot" 
depends of \ref AnalitzaModule "Analitza".

\section design Design Aspects

\ref AnalitzaModule "Analitza" is based on a subset of 
<a href="http://www.w3.org/TR/MathML2/">Mathematical Markup Language (MathML) Version 2.0</a> 
so for instance the \ref AnalitzaModule "parser" maintains structures that are 
mapped with a MathML content tag and thus can generate a MathML presentation 
for the current expression. This means also that all modules of the library 
are based implicitly on MathML.

Some important classes from each module are:
\li \ref Analitza::Expression "Expression" abstracts a valid expression from 
user input (a 
<a href="http://qt-project.org/doc/qt-4.8/qstring.html">QString</a>) and then 
\ref Analitza::Analyzer "Analyzer" can evaluate the expression.
\li \ref Analitza::PlotsModel "PlotsModel" manage the mathematical objects that can be 
drawn by \ref Analitza::Plotter2D "Plotter2D" or 
\ref Analitza::Plotter3DES "Plotter3D" (both plotters are agnostic of technologies 
like QtWidgets or QtQuick).
\li \ref Analitza::ExpressionEdit "ExpressionEdit" is a widget that allows inline 
editing of mathematical expressions. \ref Analitza::PlotsView2D "PlotsView2D" is 
a widget that uses \ref Analitza::Plotter2D "Plotter2D" to show plots (same with 
\ref Analitza::PlotsView3D "PlotsView3D": it uses 
\ref Analitza::Plotter3DES "Plotter3D").

\section features Features

\li Parser can work with lambdas, matrices, vectors, polynomials, custom variables, etc.
\li Parser suport some symbolic computations like derivatives, solving equations, etc.
\li MathML built-in, so (for instance) is easy to export formulas to 
<a href="http://www.latex-project.org/">Latex</a>.
\li Extensible framework for plotting mathematical objects such implicit surfaces, 
parametrical curves, etc. in many coordinate systems.
\li GUI components for input and manage mathematical expressions.


@authors
Aleix Pol \<aleixpol@kde.org\>
Percy Camilo Triveño Aucahuasi \<percy.camilo.ta@gmail.com\>

@maintainers
Aleix Pol \<aleixpol@kde.org\>

@licenses
@lgpl

*/


/** \page getting_started Getting Started

<p><b>
\ref index "Overview" |
Getting Started |
\ref tutorials "Tutorials" |
\ref examples_showcases "Examples and Showcases"
</b></p>

\section intall_analitza Install Analitza

In Linux, if your distribution have already the package then installing is 
easy, for example in Debian type as root user:

\code
aptitude install libanalitza-dev
\endcode

In Windows the task is very simple thanks to 
<a href="http://techbase.kde.org/Projects/KDE_on_Windows/Installation">KDE Installer</a> 
you just need to follow the wizard and check to install the Analitza package. For 
more information about KDE on windows read 
<a href="http://techbase.kde.org/Projects/KDE_on_Windows">this</a>.

Just remeber that Analitza version depends of KDE version, and your 
distribution (in case of Linux) or KDE Installer (in case of windows) 
can have and old version of KDE.

\section build Build and Install Analitza

In case the repositories doesn't have the library package or you want the 
last version of Analitza, then you can build and then install the library from 
sources. 

First, check this prerequisites:

\li Make sure you have 
<a href="http://techbase.kde.org/Development/Git">Git</a> installed.
\li Make sure you have 
<a href="http://techbase.kde.org/Development/Tutorials/CMake">CMake</a> installed.
\li Analitza needs a successful installation of 
<a href="http://api.kde.org/4.x-api/kdelibs-apidocs/">KDELibs</a>, 
however since doesn't use the most heavy/exotics components from KDELibs, 
then you can build Analitza using an older version of KDELibs, you 
just need to install the kdelibs-dev package from your repository 
(from distibution in case of Linux , and from KDE Installer 
in case of windows) If you still want to build KDELibs then read 
<a href="http://techbase.kde.org/Getting_Started/Build">here</a> the details.
\li If you want to use 3D features of Analitza (like drawing implicit surfaces 
for instance), then you need to make sure that 
<a href="http://www.opengl.org/">OpenGL</a> 
development libraries are correctly installed in your system.
\li If you want to build a command line calculator called calgebra, then you need the 
<a href="http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html">readline</a> 
development libraries.

Next, let's follow these steps in your terminal:

\li \code git clone git://anongit.kde.org/analitza\endcode
\li For Linux type: \code cd analitza && mkdir build && cd build\endcode For 
Windows create a folder called build inside analitza and then you need to 
go there (inside build folder).
\li \code cmake .. -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` -DCMAKE_BUILD_TYPE=debugfull\endcode
\li \code make install\endcode

For more information about building KDE Software you can read 
<a href="http://techbase.kde.org/Getting_Started/Build/KDE_Applications">here</a> 
and 
<a href="http://techbase.kde.org/Getting_Started">here</a>.

\section setup_cmake Setup a CMake Project

Once the Analitza is installed, then you have headers and sublibraries binaries 
for each \ref modules. The installation process ensures that cmake will find 
the library by using find_package macro, this because an AnalitzaConfig.cmake 
was installed. <a href="http://techbase.kde.org/Development/Tutorials/CMake#Using_CMake_for_a_KDE_Project">Here</a> 
you have more information about CMake macros.

Now, let see this basic template for a CMake project:

\code
project(mycalculator)

find_package(KDE4 REQUIRED)
find_package(Qt4 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Analitza REQUIRED)

include_directories(
  ${KDE4_INCLUDES}
  ${CMAKE_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR} 
  ${ANALITZA_INCLUDE_DIR} 
  ${OPENGL_INCLUDE_DIR}
)

set(mycalculator_SRCS main.cpp)

kde4_add_executable(mycalculator ${mycalculator_SRCS})

target_link_libraries(mycalculator 
  ${KDE4_KDECORE_LIBS} 
  ${QT_QTGUI_LIBRARY} 
  ${ANALITZA_LIBRARY} 
  ${ANALITZAPLOT_LIBRARY}
  ${ANALITZAGUI_LIBRARY}
  ${OPENGL_gl_LIBRARY}
  ${OPENGL_glu_LIBRARY}
  ${QT_QTOPENGL_LIBRARY}
)
\endcode

*/


/** \page tutorials Tutorials

<p><b>
\ref index "Overview" |
\ref getting_started "Getting Started" |
Tutorials |
\ref examples_showcases "Examples and Showcases"
</b></p>

\section simple_parser A simple parser demo

If you want to evaluate a simple math expression like sin(pi/6)+3, first you need to 
create the \ref Analitza::Expression "Expression" that encapsules the string value 
and then you can use \ref Analitza::Analyzer "Analyzer" to get the result:

\code
#include <iostream>
#include <analitza/analyzer.h>
#include <analitza/value.h>

using namespace std;
using namespace Analitza;

int main(int argc, char *argv[]) {
	QString input("sin(pi/6)+3");
	Expression exp(input); // create a math expression
	Analyzer a; // setup the Analyzer instance with its own Variables module

	a.setExpression(exp); // Analyzer needs to know about expression
	double result = a.calculate().toReal().value(); // get the numeric result

	cout << result << endl;

	return 0;
}
\endcode

You can also use \ref Analitza::Expression "Expression" to make some queries, 
for example, in regards to the data type of the expression, the next code prints 
0 (false):

\code
	bool eq = exp.isEquation(); // or a.expression().isEquation()
	cout << eq << endl;
\endcode

\section advanced_parser Some advanced parsing features
Lets create a variable k = 2.1 and a function f(x) = sin(x) + k. We will 
calculate values for a lambda expression (our f(x) function) and get the 
derivative of f(x) (wich is a lambda expression too: d(f(x))=f'(x)):

\code
#include <iostream>
#include <analitza/analyzer.h>
#include <analitza/variables.h>
#include <analitza/value.h>

using namespace std;
using namespace Analitza;

int main(int argc, char *argv[]) {
	Variables *vars = new Variables(); // create a variables container 
	vars->modify("k", 2.1); // add a new variable called k with initial value 2.1

	Expression func("x->sin(x) + k"); // create our lambda f(x)=sin(x) + k

	Cn *x = new Cn(); // create a bound variable to manipulate x in f(x)
	x->setValue(3.14); // set a initial value for x

	Analyzer a(vars); // when calculating, Analyzer will access to variables in vars
	QStack<Object*> runStack; // Analyzer use this stack to calculate f(x)
	runStack.push(x); // add our bound variable to the stack

	Expression result; // an expression instance to save computations and result 

	// play with f(x)
	a.setExpression(func);
	a.setStack(runStack); // this is important to calculate lambda expressions
	result = a.calculateLambda();

	cout << func.toString().toStdString() << endl;
	cout << result.isReal() << endl; // simple query
	cout << result.toReal().value() << endl; // get f(3.14)

	// get the derivative of f(x) and play with it
	Expression dfunc = a.derivative("x");
	a.setExpression(dfunc); // update the expression
	a.setStack(runStack); // this is important, update the stack too
	result = a.calculateLambda();

	cout << dfunc.toString().toStdString() << endl; // get the derivative string
	cout << result.toReal().value() << endl; // derivative of f(x) at x = 3.14

	delete vars; // free the memory

	return 0;
}
\endcode

*/


/** \page examples_showcases Examples and Showcases

<p><b>
\ref index "Overview" |
\ref getting_started "Getting Started" |
\ref tutorials "Tutorials" |
Examples and Showcases
</b></p>

You can find 
<a href="http://lxr.kde.org/source/kde/kdeedu/analitza/analitzaplot/examples/">examples</a> 
of \ref AnalitzaPlotModule "AnalitzaPlot" and also check the tests folders of each 
modules 
<a href="http://lxr.kde.org/source/kde/kdeedu/analitza/analitza/tests/">here</a>, 
<a href="http://lxr.kde.org/source/kde/kdeedu/analitza/analitzaplot/tests/">here</a>, 
and
<a href="http://lxr.kde.org/source/kde/kdeedu/analitza/analitzagui/tests/">here</a>.

Also, remember that Analitza is used by applications like:
\li <a href="http://edu.kde.org/kalgebra/">KAlgebra</a> (see the 
<a href="http://lxr.kde.org/source/kde/kdeedu/kalgebra/">sources</a>).
\li A backend of <a href="http://edu.kde.org/cantor/">Cantor</a> (see the 
<a href="http://lxr.kde.org/source/kde/kdeedu/cantor/src/backends/kalgebra/">sources</a>).
\li <a href="http://lxr.kde.org/source/kde/kdeedu/analitza/calgebra/">calgebra</a>.

*/


/** \defgroup AnalitzaModule Analitza
This is the main module of Analitza, it provides a parser for mathematical expressions.
*/


/** \defgroup AnalitzaPlotModule AnalitzaPlot
This is module is a plotting framework for mathemathical objects.
*/


/** \defgroup AnalitzaGUIModule AnalitzaGUI
This is module contains UI controls for Analitza.
*/


// DOXYGEN_SET_PROJECT_NAME = Analitza
// DOXYGEN_SET_RECURSIVE = YES
// DOXYGEN_SET_FILE_PATTERNS = *.h *.dox
// DOXYGEN_SET_EXCLUDE += @topdir@/analitza/abstractlexer.h
// DOXYGEN_SET_EXCLUDE += @topdir@/analitza/explexer.h
// DOXYGEN_SET_EXCLUDE += @topdir@/analitza/mathmlpresentationlexer.h
// DOXYGEN_SET_EXCLUDE += @topdir@/analitza/expressionparser.h
// DOXYGEN_SET_EXCLUDE += @topdir@/analitza/pushvalue.h
// DOXYGEN_EXCLUDE_PATTERNS = *_p.h */private/* */tests/* */examples/* 
// vim:ts=4:sw=4:expandtab:filetype=doxygen