Extcalc - Scientific Calculator
Version 0.9.0
Inhalt
1. Introduction
2. Source Files
3. Mathematical Classes
3.1 Important Basic Functions
3.2 Class Description
3.3 Usage of the Mathematical Classes
4. Internal Interfaces
4.1 Basic Structures
4.2 Variables
4.3 Config file and Preferences
5. Mathematical Algorithms
6. Installation Files
1. Introduction
This is the internal documentation of Calc and Extcalc. It is mainly for develops. Users don't need to read that.
It describes the source files and the internal structure of Calc and Extcalc and the Installer.
A description of the mathematical methods and algorithms is also be found here.
2. Source Files
File List:
All the files listed here, belong to the Extcalc program and they were coded by hand.
The files, which were generated by QT, are not mentioned here.
Source Files:
extcalc.cpp
buttons.cpp
calcwidget.cpp
global.cpp
graph.cpp
graphout.cpp
graphpref.cpp
graphsolve.cpp
calctable.cpp
calcinput.cpp
calcpref.cpp
functiontable.cpp
table.cpp
tablepref.cpp
scriptedit.cpp
scriptpref.cpp
scriptio.cpp
matrixwidget.cpp
statistics.cpp
catalog.cpp
Header Files:
extcalc.h
buttons.h
calcwidget.h
global.h
graph.h
graphout.h
graphpref.h
graphsolve.h
calctable.h
calcinput.h
calcpref.h
functiontable.h
table.h
tablepref.h
scriptedit.h
scriptpref.h
matrixwidget.h
statistics.h
catalog.h
scriptio.h
Extra Header Files:
list.h
calclocale.h
Source Tree
Here you can see the debpendencies beteween all header files.
calclocale.h list.h
| / | \________________________
________________________________|________________/ | _________ \ ________________ catalog.h
/ global.h _________|________________/ calctable.h___________ \______________________________________________________________________
/ _______________________________|__________/_________|_______________/_____________|________________\______\________________\________________\____________________\_______________\_____________________________________________________________
/ / / / \ | / \ | \ | \ \ \ \ \ \ \ \ \
calcinput.h buttons.h / graphout.h / graphsolve.h functiontable.h | | | | | | | | |
\____ _____/ __\_____________/ \______ / ______/ / \ | | | | | | | | |
\ / / \_________________________________ \ | /______________________/ \ | | | | | | | | |
calcwidget.h________/ graph.h table.h scriptedit.h scriptio.h matrixwidget.h statistics.h graphpref.h calcpref.h tablepref.h scriptpref.h
\________________________ ___________________/ / / / / / / / / /
\ /_______________________________________________________________/________________/________________/___________________/_______________/_______________/_____________/_____________/________________/
extcalc.h
File Description
extcalc:
Main Object of GUI, includes menus, tab initialisation, loading and saving config files and management of preferences.
calcwidget:
Complete calculator window (calculator tab), which includes and connects all calculator components.
calcinput:
This is the text field of the calculator. It does the calculation itself and controls user input and output.
calcpref:
Preferences dialog for calculator preferences.
graph:
Graphics main window (graphics tab). It includes and connects graph solving window and graph output window and
the function table.
graphout:
This is the GL-component of the calculator. It precalculates the function graphs and shows them in an OpenGL-window.
graphsolve:
This class includes the User Interface of the graph analysis window and the special calculation alogithms for
all the analysis functions. Screenshot saving is also controlled from there .
graphpref:
Preferences dialog for graphics preferences.
table:
Table window (table tab). This is the main window for calculating result tables of functions
tablepref:
Preferences dialog for tables.
matrixwidget:
Window form matrix and vector operations. In this window, the user can show and change all variables.
statistics:
The window for statistics, approximation and interpolation. It includes operations to calculate functions from
lists data.
scriptedit:
Editor window for creating, editing and managing scripts
scriptio:
Console for the text input and output of calculator scripts
scriptpref:
Preferences dialog for scripts
buttons:
This object includes both button groups of the calculator.
calctable:
Overloaded QT-table which can show text in different colors.
functiontable:
Overloaded calctable class, which manages the functions strings for graphs and tables. It can also manage
the function preferences like color, type, ...
catalog:
Overloaded QPopupMenu which includes sorted lists of all calculator operations and functions
global:
This object includes accerelated calculator class and all needed subroutines.
It also includes the script class for running calculator scripts and functions for processing configfiles and unicode.
In it's header file, all macros and the Preferences struct are defined.
3. Mathematical Functions
Two classes were used to process a calculation. The Calculate class and the Script class.
The normal calculator and the script interpreter use the script class. The Calculate class is used for graph drawing, function
tables and function analysis. The console calculator calc only uses the Script class. All mathematical functions and classes
are located in the global.h and global.cpp source files.
3.1 Important Basic Functions
There are several extra functions, that don't belong to any of the calculator classes, which were needed for the parsers.
This chapter describes them.
String Operations: strcut
The string operations were used to simplify string modifications in the parser and preprocessor algorithms.
Prototype:
char*strcut(char*src,int index,int len=1);
Description:
This function cuts out some characters from the given string and returns a pointer to the new string.
Parameters are the source string, the start index and the number of characters to cut out.
The returned char pointer represents a newly allocated string, allocated with new.
String Operations: strins
Prototype:
char*strins(char*dest,const char*src,int index);
Description:
This function inserts the string src into the string dest at position index. It returns a pointer on the result string.
The memory for the result string is allocated with the new operator inside the function.
String Operations: strcopy
Prototype:
int strcopy(char*dest,char*src,int len);
Description:
This function copies a part of the length len from src to dest. The dest string must be allocated before calling this function.
It must be large enough for inserting. If you don't want to copy the string to the start of dest, use for example
dest[start_index]
instead of dest.
String Operations: strreplace
Prototype:
char* strreplace(char*st,int index,int len,char*rep);
Description:
This function replaces the part of the string str with the lenght len from position index through the string rep.
When the replacement is longer than len, the string will be resized. Return value is the new string, resized by
realloc.
String Operations: strinsert
Prototype:
char* strinsert(char*st,int index,char*ins);
Description:
This function inserts the string ins into the string st at positon index. The string is resized by realloc. The return value
is the new string.
Search Functions: bracketFind
The search functions are an important part of the parser algorithms, to find the relevant parts of a string.
Prototype:
int bracketFind(char* string,char* searchString, int start=0);
Description:
This functions searches the string string for the expression searchString. But it searches only outside of brackets.
It counts the following as brackets: ( [ { " Only if all found open brackets were closed, it continues
searching. It is possible to search for one of the brackets. You can also set the search start index.
Search Functions: bracketFindRev
Prototype:
int bracketFindRev(char* string,char* searchString, int start=-1);
Description:
This function does the same as the function above, but it searches from the end to the start of the string.
The search start index can also be set. -1 means always start at the end.
Preprocessor Functions: preprocessor
Prototype:
char* preprocessor(char*,Preferences*,bool);
Prototype:
char* preprocessor(QString*,Preferences*,bool);
Description:
This is the main function which should be used to preprocess the input string ofototype:Table Preferences
If you want to calculate a table of function values, you can set the start value, end value and number of values, here.
The function type, for which the table is calculated, can be set here or in the table preferences menu.
Scripting Preferences
Here you can set the path to the script root directory. This directory contains two subdirectories, one for the code
files and one for the data files. Their names can also be set in this dialog.
4. Other
Version
Extcalc version 0.9.1
This is a beta-version of Extcalc.
This means, that there may be some bugs in this program, because the new features from the earlier version have to be tested.
Further information to the beta version can be found on the projekt homepage.
Precision
The maximum precision of Extcalc on a 32-bit PC-Processor is 18 decimal digits
because it uses double-variables for calculation. Because of the architecture of a normal
PC-Processor, the last digit is often calculated wrong.
The precision of the integration-operation is about 9 digits and the precision of the
differentiation-operation is about 8 digits depending on the formula to calculate.
The precision of trigonometric functions and logarithms is about 17 digits.
enabled features
User Interface for calculator
User Interface for graphics
parser for calculations
drawing graphs
working with graphs
integration, differentiation
base-n calculations
logic functions
3D-Graphs
dynamic graphs
most scripting functions
script debugging
zooming and moving graphics
saving screen shots
drawing into graphics window
complex numbers
matrix calculation
vector calculation
scripting functions for graph drawing and file usage
sperate window for matrix and vector operations
statistic functions
To-do-list
beta testing
Tested Distributions:
| Suse Linux 8.2: | OK |
| Suse Linux 9.2: | OK |
| Suse Linux 10.2: | OK |
| Debian 3.1 Sarge: | Update needed |
| Debian 4.0 Etch: | OK |
| Debian Testing Lenny: | OK |
| Ubuntu 7.04 | OK |
| Mepis Linux 6.0: | OK |
| Mandriva 2007: | OK |
| Fedora Core 6: | OK |
| FreeBSD 6.2: | read comment |
Debian 3.1 Sarge
The installer works and the program can be started, but the graphics window doesn't work.
If this problem exists, you will have to install the updates for your X and OpenGL packets.
FreeBSD 6.2
The source can be built under FreeBSD, when the development packages of QT and OpenGL were installed.
You may need to set the QTDIR environment variable to installation path of the QT development package.
Needed software:
Linux
GCC 3 or GCC 4 (doesn't work with GCC 2.xx)
QT3.1 or higher (no QT 4)
OpenGL
libXT
Needed hardware:
CPU at about 1GHz (32Bit or 64Bit)
enough RAM to run X
For 3D-graphics, a 3D-graphics card is recommended
A mouse with mouse wheel is needed for zooming, moving and rotating graphs