AP Library adapted for C#

The document describes an AP library adapted for C#. The AP library for C# contains a basic set of mathematical functions and collection classes needed to run the programs from the ALGLIB website.

Compatibility

This library must be compatible with any C# compiler.

Structure and Use

The library includes the only file ap.cs

AP Library Description

Constants
Functions
Complex numbers

Constants

AP.Math.MachineEpsilon
The constant represents the accuracy of machine operations, that is the minimum number for 1+machineepsilon≠1 in the given bit grid. The constant may be taken "oversized", that is real accuracy can be even higher.

AP.Math.MaxRealNumber
The 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.

AP.Math.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.

Functions

public static double AP.Math.RandomReal()
Returns a random real number from half-interval [0,1).

public static int AP.Math.RandomInteger(int N)
Returns a random integer between 0 and maxv-1.

public static double AP.Math.Sqr(double x)
Returns x2.

Class of complex numbers

AP library includes the AP.Complex structure that supports operations with compex numbers. Access to real and imaginary parts of complex number is implemented through the public fields x and y. Arithmetical operations are supported, the same as with embedded data types, by overloading of operations: addition, subtraction, multiplication and division. Addition, subtraction and multiplication are performed by a usual way (i.e., according to their definition which can be found in any textdook in algebra), division is performed using so called "safe" algorithm that could never cause overflow when calculating intermediate results. The library also includes several functions performing elementary operations with complex numbers.

double AP.Math.AbsComplex(AP.Complex z)
Returns the modulus of complex number z. It should be noted that the modulus calculation is performed using so called "safe" algorithm, that could never cause overflow when calculating intermediate results.

AP.Complex AP.Math.Conj(AP.Complex z)
Returns complex conjugate to z.

AP.Complex AP.Math.CSqr(AP.Complex z)
Returns the square of z.