
In the course of developing our commercial titles, a
number of Delphi components have been written. These include:
Error term expression evaluator - TAlgErrExpression
In their current state the addons will run under Delphi 4. Most can be made to run under
older Delphi compilers with little or no modification. Some however, such as TMatrix make
use of overridden methods which is only available under Delphi 4.
TVector encapsulates a dynamic array type of double
(TVectori for integer).
Supported methods:
| 1. Create vector of length n | 2. size - read-only, returns the size of vector |
| 3. EnlargeBy - Enlarge vector by n elements | 4. ReduceBy - Reduce vector by n elements |
| 5. Enlarge/Reduce - change by one element | 6. Zero/Clear - set all elements to zero |
| 7. Copy - copy vector | 8. Dot - compute dot product |
| 9. Cross/CrossU - compute cross product | 10. Mean - compute mean of elements |
| 11. Sum - compute sum of elements | 12. SumOfSquares - compute sum x^2 |
| 13. StdDev - compute standard deviation | 14. Scale - multiply vector by factor |
| 15. Norm - return Euclidean norm |
TLsoda is a translation of the LSODA stiff differential equation solver (Livermore Solver of Ordinary Differential Equations). The original FORTRAN version was written by
Linda R. Petzold and Alan C. Hindmarsh, Computing and
Mathematics Research Division, Lawrence Livermore National Laboratory, Livermore, CA
94550, U.S.A.
LSODA can dynamically switch integration methods according to how stiff the problem is. The two methods employed include:
non-stiff regions: Adams method with variable step size and variable order up to 12th order. stiff regions: Gear (or BDF) method with variable step size and variable order up to 5th order.
References:
Alan C. Hindmarsh (1983), ODEPACK, A Systematised Collection of ODE Solvers, in Scientific Computing, R. S. Stepleman et al. (eds.), North-Holland, Amsterdam, pp. 55-64. Linda R. Petzold (1983), Automatic Selection of Methods for Solving Stiff and Nonstiff Systems of Ordinary Differential Equations SIAM J. Sci. Stat. Comput. 4 , 36-148. The original C to PASCAL translation was done by JoaoPedro Monij-Barreto (Oxford Brookes, UK) and Ronny Shuster (Germany). See comments in adamsbdf.pas files for more details.
To download Delphi LSODA, plus example and docs, click here: Download LSODA Now (175K)
This is a runtime expression parser which can evaluate expressions such as:
a=1.3; b=6.7; c=a+b/(cos(0.5)+2^5.6)
Variable names are permitted, up to 255 characters long. The component has been optimised for fast evaluation times. Using TAlgExpression is very simple; just drop a TAlgexpression on on a form and use the method, 'evalThis'. Thus to evaluate the expression, 2.3+7.8*5.6, use the statement:
d := e.evalThis ('2.3+7.8*5.6');
where e is the TAlgExpression object. If you use the same expression many times, the component does an internal compilation of the specified expression and subsequent evaluations are much faster. Changes to the values of variables during repeated evaluations does no cause recompilations to occur. You have direct access to variables through the methods: GetVar and SetVar, e.g SetVar ('velocity', 1.2); Variables are stored on a very fast binary search tree and very little time penalty is incurred during named variable access. If you want faster access there is a method, GetSymbolPtr which returns a pointer to the variable position in the symbol table and the related methods, SetSymbolValue and GetSymbolValue can use the pointer value to access the variable.
Operators: +, -, *, /, ^, not, or, and, <,
<=, >, >=, <>, =, (, )
Functions: sin, cos, tan, exp, Log, Ln, sqr, sqrt, fact, arcsin, arccos, arctan, sinh,
cosh, tanh, arcsinh, arccosh, arctanh.
Constants: Pi, e, Degrees, True, False
The constant Degrees can be used to convert degrees to radians. Thus, although the trig functions accept angles in radians it is possible to supply angles in degrees simply by multiplying the degree by Degrees, e.g. sin (30*Degrees) would return 0.5.
Download TAlgExpression
The second component is very simpler to TAlgExpression but has the additional property of being able to evaluate error terms. An error term is something like a ± b, where b is usually some error placed upon the value of a. With TAlgErrExpression it is possible to form expressions such as:
1±2 + 5±0.5
TAlgErrExpression will also work happily with
simple scalar expressions in the same manner as TAlgExpression. Use of TAlgErrExpression
is exactly the same as with TAlgExpression except that the method evalThis (and related
methods) returns a special predefined error type, called TEvalType, instead of the
double/Extended type of TAlgExpression.
| Create (n, m) - create empty matrix of given size | Create (n) - create identity matrix of given size |
| Clone (m) - return a clone of the matrix m | Resize (n, m) - resize the matrix to given size |
| m[i,j] - access matrix via row/column | r and c - returns nRows and nColumns |
| IsSquare - test if matrix square | SameDimensions - dimensions of m1 = m2 ? |
| Identity - form identity matrix | Diagonal - form a diagonal matrix |
| Zero - zero a matrix (0.0 for all elements) | Transpose |
| Matrix Add, Subtract, Multiply | Multiply by scalar |
| Copy - Perform deep copy of matrix | ExtractRow and ExtractColumn |
| LUDecomp, LUSolve - LU decomposition | Det - return determinant |
| Invert - Form inverse of matrix | SolveLinear - Solve a set of linear equations |
| Plus many other methods........ |
TMatrix is unique in that is can store row and column text labels. By default these are simply R1..Rn and C1..Cm but can be set by the user to more meaningful names. This is a very useful facility particularly where some of the methods result in row and column swapping and it is therefore useful to know the resulting reordering.
It is possible with TMatrix to concatenate methods, e.g. m.add (a).add(b).add(c); forms the sum m := a + b + c;
If the component isn't available from this page contact me if you would like copies. If you're interested click here: Mail for Delphi Components
Principal H M Sauro
All trademarks used are hereby acknowledged
This page was last modified on 08 November 2000