ALGLIB 3.x held onto numerous legacy API design decisions. However, recent advances in our automatic code and wrapper generation technology allow us to capture more information about program semantics, such as constant and mutable data, in-place changes, reallocations, resizing, etc. Consequently, in ALGLIB 4 we decided to break backward compatibility with the aim of providing more concise API, free from old inconsistencies.
The breaking changes can be divided into two categories:
1 High-level changes in the API conventions
C++ API
C# API
Python API
2 Changes in function signatures
3 Migrating from ALGLIB 3.x to ALGLIB 4
Strongly typed languages: C++, C#, Delphi
Python
4 Downloads section
ALGLIB for C++ now correctly tracks the const-status of data being passed to ALGLIB. Function parameters that are modified during function execution are now marked as const. This is the only high-level change in the C++ API.
C# does not track const-status of function parameters, so const-correctness is irrelevant for C# programs. What is important is how we handle different kinds of mutable function parameters, i.e. parameters which have an input value and which are modified after return from the function.
Obviously, the only way to have a mutable parameter of a value type is to pass it by reference. However, there is more flexibility with mutable parameters of reference datatypes. A function can modify it without creating a new reference (modify an array element or an object field). Alternatively, it can create a new reference (perform an array reallocation or construction of a new class instance).
In ALGLIB 3.x all mutable parameters were passed by reference, whether of a primitive datatype or not. Starting from ALGLIB 4.0 we adopt the following conventions:
The question of parameters mutability is also relevant for Python. The language lacks ability to pass parameters by reference, so in ALGLIB 3.x all mutable parameters were included into a return tuple.
Starting from ALGLIB 4.0, Python edition adopts the following convention:
The most frequently appearing change is that we stopped using an integer info
output parameter to signal success or failure of ALGLIB solvers.
It makes the code unnecessarily cluttered because in almost all cases the same solver function has one more output parameter, rep
,
which can be used to signal success or failure.
The fix removes the info
output parameter and adds rep.terminationtype
field which has exactly the same meaning.
More than 95% of changes are covered by this case.
The fix above and several other minor tweaks are fully disclosed in a corresponding issues tracker entry.
When changing the API we adopted the following approach: either it works, or it immediately breaks. It means that in strongly typed languages you can simply recompile your program against the latest ALGLIB release. If it compiles, it definitely means that the migration was successful. If it does not compile, you know where to look.
Due to its dynamic nature, Python does not allow us to check program correctness during compilation stage. Only at runtime it will become apparent that some parameters are missing. Thus, the only way of correctly migrating Python program from ALGLIB 3.x to ALGLIB 4 is check usage of functions that changed in ALGLIB 4.
You can find a list of such functions in the issues tracker entry.
This article is licensed for personal use only.
ALGLIB Project offers you two editions of ALGLIB:
ALGLIB Free Edition:
+delivered for free
+offers full set of numerical functionality
+extensive algorithmic optimizations
-no multithreading
-non-commercial license
ALGLIB Commercial Edition:
+flexible pricing
+offers full set of numerical functionality
+extensive algorithmic optimizations
+high performance (SMP, SIMD)
+commercial license with support plan
Links to download sections for Free and Commercial editions can be found below: