Math with LMath¶
Credit
Huge thanks to Jean Debord for the work in Dmath and also to Viatcheslav Nesterov (Glorfin) for the contributions to the LMath, both invaluable resources for Free Pascal and Lazarus users.
Info
The content of this page is adapted from the official document of LMath on Sourceforge.
Introduction¶
LMath, further development of DMath library from Jean Debord, is a general purpose mathematical library for FreePascal (FPC) and Lazarus. LMath provides routines and demo programs for numerical analysis, including mathematical functions, probabilities, matrices, optimization, linear and nonlinear equations, integration, Fast Fourier Transform, random numbers, curve fitting, statistics and graphics. It is organized as a set of lazarus packages. Such organization makes it easily extensible and helps to include only really needed features in your project.
DMath stands for Delphi Math, and is a continuation of an earlier work which was named TPMath, for Turbo Pascal Math. Continuing this tradition, this this library is called LMath: Lazarus Math.
Source: LMath 0.6 Official Doc.
Check the official document for what is new in LMath compared to DMath.
License: LGPL 3.0
What does it offer?¶
LMath has 13 relatively small packages:
lmGenMath
. This package defines several important data structures, used later in the whole library, some utility functions, basic math functions and special functions. All other packages of the library depend onlmGenMath
.lmMathUtil
. Various function for manipulations with arrays, sorting and formatting. Depends onlmGenMath
.lmLinearAlgebra
. Operations over vectors and matrices. Depends onlmMathUtil
andlmGenMath
.lmPolynoms
. Evaluation of polynomials, polynomial roots finding, polynomial critical points finding. Depends onlmGenMath
andlmLinearAlgebra
.lmIntegrals
. Numeric integrating and solving differential equations. Depends onlmGenMath
.lmRandoms
. Generation of random numbers. Depends onlmGenMath
.lmMathStat
Descriptive statistics, hypothesis testing, collection of various distributions. Depends onlmGenMath
andlmLinearAlgebra
.lmOptimum
. Algorithms of function minimization. Somewhat artificially, unituEval
for evaluation of an expression, is included into this package. Depends onlmGenMath
,lmLinearAlgebra
,lmRandoms
,lmMathStat
.lmNonLinEq
. Finding of roots of non-linear equations. Depends onlmGenMath
,lmLinearAlgebra
,lmOptimum
.lmDSP
. Functions for digital signal processing. Collection of filters and Fourier Transform procedures.lmRegression
. Functions for linear and non-linear regression, curve fitting. Collection of common models. UnituFFT
for fast Fourier Transform is located also here. Depends onlmLinearAlgebra
,lmPolynoms
,lmOptimum
,lmMathUtil
.lmSpecRegress
. Collection of field-specific models for data fitting. Depends onlmGenMath
andlmRegression
.lmPlotter
. Routines for data and functions plotting. Depends onlmGenMath
,lmMathUtil
andLCL
.
Installation, Compilation and use of the library¶
Option #1: Download, unpack and compile¶
- Download and unpack file
LMath and Components06.zip
. - Open and compile packages in this order;
lmGenMath
,lmMathUtil
,lmLinearAlgebra
,lmPolynoms
,lmIntegrals
,lmRandoms
,lmMathStat
,lmOptimum
,lmNonLinEq
,lmRegression
,lmSpecRegress
,lmDSP
,lmPlotter
. - After it you may compile
LMath.pkg
, which simply depends on all these packages. Therefore, if you add dependency on LMath to your project, it is not necessary to add every single package.
Option #2: Download, use the Project Group package¶
Alternatively, if you have Project Groups
package installed in your Lazarus IDE, you can open and compile LMath project group, select LMath target and compile it.
LMComponents¶
If you are going to use LMComponents
, open LMComponents
package, compile and install it.
LMComponents
is an object-oriented extension of LMath
. It contains TCoordSys
component which serves for graphical representation of functions or data, several dialogs and input controls, as well as DSP filters implemented as components.
Note on Compilation¶
For the sake of maximally broad compatibility, rather conservative optimization options are selected in LMath packages (optimization level 2, no options for modern processors selected). Depending on your system, you may want to increase this level and use options for modern processors.
For example, you may want to define the following to effectively use AVX2 registers.
Do not generate debug information is selected by default in the options of LMath packages. If you want to step into LMath procedures debugging your programs, change it. If you find a bug in LMath, please, report it at the official site at Sourseforge.
Examples¶
Coming soon.