ALGLIB FAQ

C++
What is the blank file `stdafx.h` here for?
How is the array operations organized in C++?
Why are round brackets used when addressing arrays, not square brackets?
Will the ALGLIB package work in 64-bit environment?
Delphi
Why is while cycle used instead of the for cycle?
What is the purpose of the `DynamicArrayCopy` function?
Visual Basic
What version of Visual Basic are the algorithms translated into?
Will the programs from the site work in VB.NET?
Why is the goto operator used in some programs?
General Questions on source codes
What is the AP library?
What is the ABLAS library?
Some algorithms begin numeration of array elements from 1. Nobody does it like that!
A certain programming language doesn't support arrays unless they begin with zero. What do I do in this case?
General questions
What is ALGLIB aimed at?
What is the difference between ALGLIB and other similar projects?
Who are the authors of the ALGLIB?
What relation does the website have to Russia?
What is AlgoPascal?
Where can I find the algorithms for the work with files, drawing pictures in OpenGL, etc?

# C++

## What is the blank file `stdafx.h` here for?

MSVC and some other compilers require the `#include <stdafx.h>` directive in the program code to manage precompiled headers, and create the stfafx.h file when generating a new project. However, some compilers (e.g. BCB) use other tools to manage precompiled headers. In this case the `#include <stdafx.h>` directive as such doesn't hinder their operation, however if the file with this name is absent, a compilation error occurs. The blank file called `stfafx.h` is created to avoid this error. If your development environment already created the file, leave it unchanged.

## How is the array operations organized in C++?

As there is no dynamic array support in C++ (update: I know about pointers and dynamic memory allocation, but this is not exactly the thing we need here), template classes were developed to work with one- and two-dimensional arrays. The necessary source code and description can be found in the standard AP library, which is supplied with ALGLIB sources. Please note that the array numeration in this library begins from any number the programmer chooses rather than from 0.

## Why are round brackets used when addressing arrays, not square brackets?

Imagine you are addressing the a matrix element in the common notation: `a[x][y]` instead of `a(x,y)`. Actually there are two index operators called here instead of one. The first is indexing of a matrix by `x`, that returns a reference to a temporary structure that describes the matrix row. The second is indexing that temporary structure by `y`, which returns the reference to the needed element. Addressing through overloading the round brackets is much more effective, as no temporary structures are required.

## Will the ALGLIB package work in 64-bit environment?

The ALGLIB package was not tested in 64-bit environment.

However, the package itself and the AP/C++ library it uses don't contain any code that explicitly points out the environment it should work in. Thus, in theory compiling and usage of ALGLIB package in a 64-bit environment should not cause any trouble when not using additional libraries (like ABLAS, which is at the moment intended to work only in 32-bit environments).

# Delphi

## Why is while cycle used instead of the for cycle?

The reason for that is some peculiarities of the for cycle in Delphi. If the cycle has not been executed yet, in many programming languages the control variable of the cycle contains the initial value. In Delphi, if the cycle has not been executed, the control variable of the cycle doesn't change. Once I have seen a source code, in which this difference played a major role. That's why decided to replace the for cycle in Delphi with while cycle, whose behavior is the same as in any other language.

## What is the purpose of the `DynamicArrayCopy` function?

In Delphi dynamic arrays are reference types, i.e. if the array parameter is passed by value, no copying of the array occurs. To emulate the transfer of the array parameter by value we use the `DynamicArrayCopy` function. It requires a dynamic array as an argument and returns a copy of this array. Assignment of the type `A:=DynamicArrayCopy(A)` replaces the reference to the original array with a reference to its copy.

# Visual Basic

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

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

## Will the programs from the site work in VB.NET?

Not unless they are manually ported.

## 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.

# General Questions on source codes

## 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 BSD license. The library is attached to each algorithm package available for downloading from the web-site. The latest library version is available for downloading from http://alglib.sources.ru/translator/aplib.zip

## What is the ABLAS library?

ABLAS is an optimized implementation of basic linear algebra subroutines written in assembler. To use ABLAS it is necessary to copy the DLL file to one of the system folders or in the program folder and turn on ABLAS support (as described in ABLAS manual). When launching a program that is using the ALGLIB package, the ABLAS library is automatically detected and loaded. If ABLAS is absent, the program uses the standard implementation of linear algebra operations, written in a high-level language. At http://www,alglib.net/projects/ablas/ (or http://alglib.sources.ru/projects/ablas/ in Russian) there is library description, the list of the supported platforms and programming languages as well as source code and precompiled binary files.

## Some algorithms begin numeration of array elements from 1. Nobody does it like that!

Yes, they do. For instance, netlib.org library contains megabytes of code written in Fortran, in which numeration begins with 1. Today numeration is commonly begun with 0, but many unique algorithms are very widespread in the old edition. At the moment most algorithms are aligned with the modern, 0-based numeration. However a small number of very useful algorithms still uses the old one. In future all of them will be aligned to the modern system, but for now they need to be used as is.

## A certain programming language doesn't support arrays unless they begin with zero. What do I do in this case?

In this case the elements containing zero in one of the indexes, will not be used. For instance, if a subroutine expects to get a 2x2-size array, where numeration begins with 1 (which means that the element indexes look like `[1..2,1..2]`), it is necessary to transfer an array with a numeration looking like `[0..2,0..2]`). This is not the nicest looking solution, but it works.

# General questions

## What is ALGLIB aimed at?

It is mostly 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 a collection of programs. Sometimes visitors complain that there are practically no algorithm descriptions at the site. Yes, that's true - just because ALGLIB is a collection of programs, not the used algorithm descriptions. Unfortunately we cannot do everything.
- is focused on numerical analysis. There are some other directions in the project (for instance, there are algorithms for sorting and graphics) 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 extensive and inconvenient interface to a code written in another programming language.

Now on what ALGLIB is not and is not going to be. ALGLIB doesn't:

- compete with specialized projects. This is not the goal. And, however hard I try, the project won't get as fast as MKL or have as wide a functionality as LAPACK.
- go out of the boundaries of the project. For instance, parallel calculations are very interesting, but the solution of this problem is usually tightly connected to a certain platform, programming environment or language, which doesn't align with the main idea of the project.

## Who are the authors of the ALGLIB?

The first version of ALGLIB was made by Vladimir Bystritsky. He spent a number of years on the maintenance of the website by himself. Eventually, he lost his interest in the website, so I (Sergey Bochkanov) took over the work on its maintenance, by common agreement.

## What relation does the website have to Russia?

Originally, ALGLIB was a Russian-language website. Later on, a part of the website was translated into English. At present, there are two versions of the site - Russian and English.

## What is AlgoPascal?

AlgoPascal is a programming language, designed particularly for this project. The programs, written in this language, are processed by a server-side automatic translator and translated into other programming languages by the computer. More detailed information is provided in section "About the site".

## Where can I find the algorithms for the work with files, drawing pictures in OpenGL, etc?

As we noted before, the main goal of ALGLIB is to create a multilingual library of algorithms in the area of numerical analysis. The problems, related to those enumerated in the question, do not fall into this category. Exceptions are made for a number of problems, though the project can be characterized by a clear-cut specialization.