Download from VBForums

102 modules containing several hundred advanced mathematical functions written by Dr. Sergey Bochkanov. Some of the functions, include:

- Decision forest classifier (regression model)
- K-means++ clustering
- Linear discriminant analysis
- Linear models
- Logit models
- Basic neural network operations
- Neural network ensemble models
- Neural network training
- Principal component analysis
- Ordinary differential equation solver
- Fast real/complex convolution
- Fast real/complex cross-correlation
- Real/complex FFT
- Real Fast Hartley Transform
- Adaptive 1-dimensional integration
- Gauss-Kronrod quadrature generator
- Gaussian quadrature generator
- Inverse distance weighting: interpolation/fitting
- Linear and nonlinear least-squares solvers
- Polynomial interpolation/fitting
- Parametric spline interpolation
- Rational interpolation/fitting
- 1D spline interpolation/fitting
- 2D spline interpolation
- Level 2 and Level 3 BLAS operations
- Bidiagonal SVD
- Eigensolvers
- Sherman-Morrison update of the inverse matrix
- LDLT decomposition
- Determinant calculation
- Random matrix generation
- Matrix inverse
- Real/complex QR
- LQ
- bi(tri)diagonal
- Hessenberg decompositions
- Condition number estimate
- Schur decomposition
- Determinant of a symmetric matrix
- Symmetric inversion
- Generalized symmetric eigensolver
- Condition number estimate for symmetric matrices
- Singular value decomposition
- LU and Cholesky decompositions
- ASA bound constrained optimizer
- Conjugate gradient optimizer
- Limited memory BFGS optimizer
- Improved Levenberg-Marquardt optimizer
- Nearest neighbor search: approximate and exact
- Dense linear system solver
- Symmetric dense linear system solver
- Airy functions
- Bessel functions
- Beta function
- Chebyshev polynomials
- Dawson integral
- Elliptic integrals
- Exponential integrals
- Fresnel integrals
- Gamma function
- Hermite polynomials
- Incomplete beta function
- Incomplete gamma function
- Jacobian elliptic functions
- Laguerre polynomials
- Legendre polynomials
- Psi function
- Trigonometric integrals
- Binomial distribution
- Chi-Square distribution
- Pearson/Spearman correlation coefficients
- Hypothesis testing: correlation tests
- Descriptive statistics: mean
- variance, etc.
- F-distribution
- High quality random numbers generator
- Hypothesis testing: Jarque-Bera test
- Hypothesis testing: Mann-Whitney-U test
- Normal distribution
- Poisson distribution
- Hypothesis testing: sign test
- Student's t-distribution
- Hypothesis testing: Student's t-test
- Hypothesis testing: F-test and one-sample variance test
- Hypothesis testing: Wilcoxon signed rank test.

**Original content from Dr. Sergey Bochkanov:**

# Contents

Introduction

Getting started with ALGLIB

FAQ

AP library description

ALGLIB reference manual

# Introduction

### Sections

- ALGLIB license
- Documentation license
- Reference Manual and User Guide
- Acknowledgements

## ALGLIB license

ALGLIB is a free software which is distributed under a GPL license - version 2 or (at your option) any later version. A copy of the GNU General Public License is available at http://www.fsf.org/licensing/licenses

## Documentation license

__This reference manual is licensed under BSD-like documentation license__:

Copyright 1994-2009 Sergey Bochkanov, ALGLIB Project. All rights reserved.

Redistribution and use of this document (ALGLIB Reference Manual) with or without modification, are permitted provided that such redistributions will retain the above copyright notice, this condition and the following disclaimer as the first (or last) lines of this file.

THIS DOCUMENTATION IS PROVIDED BY THE ALGLIB PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ALGLIB PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

## Reference Manual and User Guide

ALGLIB Project provides two sources of information: ALGLIB Reference Manual (this document) and ALGLIB User Guide.

ALGLIB Reference Manual contains full description of all publicly accessible ALGLIB units accompanied with examples. Reference Manual is focused on the source code: it documents units, functions, structures and so on. If you want to know what unit

`YYY`

can do or what subroutines unit `ZZZ`

contains Reference Manual is a place to go. Free software needs free documentation - that's why ALGLIB Reference Manual is licensed under BSD-like documentation license.
Additionally to the Reference Manual we provide you User Guide. User Guide is focused on more general questions: how fast ALGLIB is? how reliable it is? what are the strong and weak sides of the algorithms used? We aim to make ALGLIB User Guide an important source of information both about ALGLIB and numerical analysis algorithms in general. We want it to be a book about algorithms, not just software documentation. And we want it to be unique - that's why ALGLIB User Guide is distributed under less-permissive personal-use-only license.

## Acknowledgements

ALGLIB was not possible without the contribution of next open source projects:

- LAPACK
- Cephes
- GNU MP
- MPFR

# Getting started with ALGLIB

### Sections

# FAQ

### Sections

- What version of Visual Basic are the algorithms translated into?
- Why is the
*goto*operator used in some programs? - What is the AP library?
- Why do some algorithms (for instance, optimization methods) use reverse communication instead of function pointers, delegates and other means of my programming language?
- What is ALGLIB aimed at?
- What is the difference between ALGLIB and other similar projects?
- What is AlgoPascal?

## What version of Visual Basic are the algorithms translated into?

The algorithms are translated into VBA, but in general are compatible with VB6.

##
Why is the *goto* operator used in some programs?

In many programming languages there is control operator

**continue**, but it is absent in VB. In AlgoPascal, this operator appears from time to time. The**goto**operator is used to replace it and go to the next iteration of the cycle.## What is the AP library?

AP library is a generic name for a set of libraries in several programming languages performing low-level tasks depending on specific programming languages. The AP library carries out tasks such as working with dynamic one- and multidimensional arrays in languages which do not support this data type, contains implementation of basic linear algebra algorithms, etc. The library is distributed as source codes under GPL 2+ license (GPL 2 or later). The library is attached to the ALGLIB package.

## Why do some algorithms (for instance, optimization methods) use reverse communication instead of function pointers, delegates and other means of my programming language?

Optimization, integration and other similar methods are united by one common trait. They need to have a way of calculating the meaning of a function defined by the

*user*at a point defined by the*method*.
The most convenient way of solving this problem is transferring a function pointer into the module. However bear in mind that ALGLIB package is written using pseudocode that is automatically translated into different programming languages. While each language has its own function pointer analog that is often different from other languages. When the ALGLIB pseudocode was developed, at some point is became clear that adding function pointers in it will be very complex as this feature is implemented differently in every language. This is why reverse communication was chosen as a different kind of solution.

## What is ALGLIB aimed at?

It is aimed at creating a convenient and efficient multilingual scientific software library.

## What is the difference between ALGLIB and other similar projects?

The ALGLIB package:

- is a multilingual project. The main feature of the project is that each algorithm is represented by programs in several languages and the language list is the same for every algorithm. This is the main advantage of the site before other similar collections - one algorithm, several languages, identical functionality in each language.
- is focused on numerical analysis. There are some other directions in the project but numerical analysis is a priority.
- is easy to use. To use the ALGLIB package you don't need to learn an unknown programming language, attach additional external libraries or work with an inconvenient interface to a code written in another programming language.

## What is AlgoPascal?

AlgoPascal is a programming language, designed particularly for this project. The programs, written in this language, are processed by an automatic translator and translated into other programming languages. Almost all ALGLIB source is produced by the AlgoPascal translator.

# AP library description

### Sections

- Introduction
- Compatibility
- Constants
- Functions
- Complex numbers operations

## Introduction

The document describes a VBA version of the AP library. The AP library for VBA contains a basic set of mathematical functions needed to compile ALGLIB package. The library includes the only module

`ap.bas`

.## Compatibility

This library is developed for VBA only.

## Constants

MachineEpsilon

The constant represents the accuracy of machine operations times some small number

The constant represents the accuracy of machine operations times some small number

*r>1*.
MaxRealNumberThe constant represents the highest value of the positive real number, which could be represented on this machine. The constant may be taken "oversized", that is real boundary can be even higher.

MinRealNumber

The constant represents the lowest value of positive real number, which could be represented on this machine. The constant may be taken "oversized", that is real boundary can be even lower.

The constant represents the lowest value of positive real number, which could be represented on this machine. The constant may be taken "oversized", that is real boundary can be even lower.

## Functions

Public Function MaxReal(ByVal M1 As Double, ByVal M2 As Double) As Double

Returns the maximum of two real numbers.

Returns the maximum of two real numbers.

Public Function MinReal(ByVal M1 As Double, ByVal M2 As Double) As Double

Returns the minimum of two real numbers.

Returns the minimum of two real numbers.

Public Function MaxInt(ByVal M1 As Long, ByVal M2 As Long) As Long

Returns the maximum of two integers.

Returns the maximum of two integers.

Public Function MinInt(ByVal M1 As Long, ByVal M2 As Long) As Long

Returns the minimum of two integers.

Returns the minimum of two integers.

Public Function ArcSin(ByVal X As Double) As Double

Returns arcsine (in radians).

Returns arcsine (in radians).

Public Function ArcCos(ByVal X As Double) As Double

Returns arccosine (in radians).

Returns arccosine (in radians).

Public Function SinH(ByVal X As Double) As Double

Returns hyperbolic sine.

Returns hyperbolic sine.

Public Function CosH(ByVal X As Double) As Double

Returns hyperbolic cosine.

Returns hyperbolic cosine.

Public Function TanH(ByVal X As Double) As Double

Returns hyperbolic tangent.

Returns hyperbolic tangent.

Public Function Pi() As Double

Returns the value of π.

Returns the value of π.

Public Function Power(ByVal Base As Double, ByVal Exponent As Double) As Double

Returns Base raised to a power of Exponent (introduced for compatibility).

Returns Base raised to a power of Exponent (introduced for compatibility).

Public Function Square(ByVal X As Double) As Double

Returns x

Returns x

^{2}.
Public Function Log10(ByVal X As Double) As Double

Returns common logarithm from X.

Returns common logarithm from X.

Public Function Ceil(ByVal X As Double) As Double

Returns the smallest integer bigger or equal to X.

Returns the smallest integer bigger or equal to X.

Public Function RandomInteger(ByVal X As Long) As Long

Returns a random integer between 0 and I-1.

Returns a random integer between 0 and I-1.

Public Function Atn2(ByVal Y As Double, ByVal X As Double) As Double

Returns an argument of complex number X + iY. From interval from -π to π.

Returns an argument of complex number X + iY. From interval from -π to π.

## Complex numbers operations

As there is no operator overloading in Visual Basic 6.0, operations with complex numbers could not be implemented as easy as with built-in data type. Therefore

`Complex`

data type is defined in a library. It is a record with two real number fields `x`

and `y`

, and all the operations are performed with the use of special functions implementing addition, multiplication, subtraction and division. An input can be complex or real, and output is complex. These functions are listed below.
Public Function C_Add(Z1 As Complex Z2 As Complex):Complex

Public Function C_AddR(Z1 As Complex R As Double):Complex

Calculate

Public Function C_AddR(Z1 As Complex R As Double):Complex

Calculate

*Z1+Z2*or*Z1+R*.
Public Function C_Sub(Z1 As Complex Z2 As Complex):Complex

Public Function C_SubR(Z1 As Complex R As Double):Complex

Public Function C_RSub(R As Double, Z1 As Complex):Complex

Calculate

Public Function C_SubR(Z1 As Complex R As Double):Complex

Public Function C_RSub(R As Double, Z1 As Complex):Complex

Calculate

*Z1-Z2*,*Z1-R*or*R-Z1*.
Public Function C_Mul(Z1 As Complex Z2 As Complex):Complex

Public Function C_MulR(Z1 As Complex R As Double):Complex

Calculate

Public Function C_MulR(Z1 As Complex R As Double):Complex

Calculate

*Z1*Z2*or*Z1*R*.
Public Function C_Div(Z1 As Complex Z2 As Complex):Complex

Public Function C_DivR(Z1 As Complex R As Double):Complex

Public Function C_RDiv(R As Double, Z2 As Complex):Complex

Calculate

Public Function C_DivR(Z1 As Complex R As Double):Complex

Public Function C_RDiv(R As Double, Z2 As Complex):Complex

Calculate

*Z1/Z2*,*Z1/R*or*R/Z2*. Modulus calculation is performed using so called "safe" algorithm, that could never cause overflow when calculating intermediate results.
Public Function C_Equal(Z1 As Complex Z2 As Complex):Boolean

Public Function C_EqualR(Z1 As Complex R As Double):Boolean

Public Function C_NotEqual(Z1 As Complex Z2 As Complex):Boolean

Public Function C_NotEqualR(Z1 As Complex R As Double):Boolean

Compare

Public Function C_EqualR(Z1 As Complex R As Double):Boolean

Public Function C_NotEqual(Z1 As Complex Z2 As Complex):Boolean

Public Function C_NotEqualR(Z1 As Complex R As Double):Boolean

Compare

*Z1*and*Z2*or*Z1*and*R*.
Public Function C_Complex(X As Double):Complex

Converts a real number into equal complex number.

Converts a real number into equal complex number.

Public Function C_Opposite(Z As Complex):Complex

Returns

Returns

*-Z*.
Public Function AbsComplex(Z As Complex):Double

Returns the modulus of complex number z. Modulus calculation is performed using so called "safe" algorithm, that could never cause overflow when calculating intermediate results.

Returns the modulus of complex number z. Modulus calculation is performed using so called "safe" algorithm, that could never cause overflow when calculating intermediate results.

Public Function Conj(Z As Complex):Complex

Returns complex conjugate to z.

Returns complex conjugate to z.

Public Function CSqr(Z As Complex):Complex

Returns the square of z.

Returns the square of z.

# ALGLIB reference manual

## Packages and units

`DataAnalysis` package | ||

dforest | Decision forest classifier (regression model) | |

kmeans | K-means++ clustering | |

lda | Linear discriminant analysis | |

linreg | Linear models | |

logit | Logit models | |

mlpbase | Basic neural network operations | |

mlpe | Neural network ensemble models | |

mlptrain | Neural network training | |

pca | Principal component analysis | |

`DiffEquations` package | ||

odesolver | Ordinary differential equation solver | |

`FastTransforms` package | ||

conv | Fast real/complex convolution | |

corr | Fast real/complex cross-correlation | |

fft | Real/complex FFT | |

fht | Real Fast Hartley Transform | |

`Integration` package | ||

autogk | Adaptive 1-dimensional integration | |

gkq | Gauss-Kronrod quadrature generator | |

gq | Gaussian quadrature generator | |

`Interpolation` package | ||

idwint | Inverse distance weighting: interpolation/fitting | |

lsfit | Linear and nonlinear least-squares solvers | |

polint | Polynomial interpolation/fitting | |

pspline | Parametric spline interpolation | |

ratint | Rational interpolation/fitting | |

spline1d | 1D spline interpolation/fitting | |

spline2d | 2D spline interpolation | |

`LinAlg` package | ||

ablas | Level 2 and Level 3 BLAS operations | |

bdsvd | Bidiagonal SVD | |

evd | Eigensolvers | |

inverseupdate | Sherman-Morrison update of the inverse matrix | |

ldlt | LDLT decomposition | |

matdet | Determinant calculation | |

matgen | Random matrix generation | |

matinv | Matrix inverse | |

ortfac | Real/complex QR, LQ, bi(tri)diagonal, Hessenberg decompositions | |

rcond | Condition number estimate | |

schur | Schur decomposition | |

sdet | Determinant of a symmetric matrix | |

sinverse | Symmetric inversion | |

spdgevd | Generalized symmetric eigensolver | |

srcond | Condition number estimate for symmetric matrices | |

svd | Singular value decomposition | |

trfac | LU and Cholesky decompositions | |

`Optimization` package | ||

minasa | ASA bound constrained optimizer | |

mincg | Conjugate gradient optimizer | |

minlbfgs | Limited memory BFGS optimizer | |

minlm | Improved Levenberg-Marquardt optimizer | |

`Other` package | ||

nearestneighbor | Nearest neighbor search: approximate and exact | |

`Solvers` package | ||

densesolver | Dense linear system solver | |

ssolve | Symmetric dense linear system solver | |

`SpecialFunctions` package | ||

airyf | Airy functions | |

bessel | Bessel functions | |

betaf | Beta function | |

chebyshev | Chebyshev polynomials | |

dawson | Dawson integral | |

elliptic | Elliptic integrals | |

expintegrals | Exponential integrals | |

fresnel | Fresnel integrals | |

gammafunc | Gamma function | |

hermite | Hermite polynomials | |

ibetaf | Incomplete beta function | |

igammaf | Incomplete gamma function | |

jacobianelliptic | Jacobian elliptic functions | |

laguerre | Laguerre polynomials | |

legendre | Legendre polynomials | |

psif | Psi function | |

trigintegrals | Trigonometric integrals | |

`Statistics` package | ||

binomialdistr | Binomial distribution | |

chisquaredistr | Chi-Square distribution | |

correlation | Pearson/Spearman correlation coefficients | |

correlationtests | Hypothesis testing: correlation tests | |

descriptivestatistics | Descriptive statistics: mean, variance, etc. | |

fdistr | F-distribution | |

hqrnd | High quality random numbers generator | |

jarquebera | Hypothesis testing: Jarque-Bera test | |

mannwhitneyu | Hypothesis testing: Mann-Whitney-U test | |

normaldistr | Normal distribution | |

poissondistr | Poisson distribution | |

stest | Hypothesis testing: sign test | |

studenttdistr | Student's t-distribution | |

studentttests | Hypothesis testing: Student's t-test | |

variancetests | Hypothesis testing: F-test and one-sample variance test | |

wsr | Hypothesis testing: Wilcoxon signed rank test Sources: 1. https://www.alglib.net/ 2. https://sites.google.com/site/chandanprogrammingdocs/platforms-frameworks/alglib 3. https://newtonexcelbach.com/2010/05/20/installing-alglib-with-excel-vba/ |

Here you can download GPL-licensed version of ALGLIB. Commercial users may use GPL-licensed code as unlimited trial version. But if you want to distribute something that includes GPL-ed code, you have to either distribute it under GPL too or buy commercial license.

3.x branch
| ||||||

Change Log | ||||||

alglib-3.1.0.cpp | zip | tgz | C++ version | |||

alglib-3.1.0.csharp | zip | tgz | C# version (100% managed code) | |||

pre-3.x releases
| ||||||

Pre-3.x releases are not compatible with 3.x branch; however, they will be there for languages which were not ported to 3.x yet | ||||||

alglib-2.6.0.mpfr.zip | Multiple precision version (MPFR) | |||||

alglib-2.6.0.freepascal.zip | FreePascal version | |||||

alglib-2.6.0.delphi.zip | Delphi version | |||||

alglib-2.6.0.vb6.zip | VBA version |