Floating Slash Routines

In these routines a big parameter can also be used wherever a flash is specified, but not vice versa. Further information may be gleaned from the (lightly) commented source code. An asterisk after the name indicates that the function does not take a mip parameter if MR_GENERIC_MT is defined in mirdef.h.

Uses supplied generator of regular continued fraction expansion to build up a flash number x, rounded if necessary.

Parameters:

→x The flash number created
←gen The generator function

Example:

int phi(flash w, int n)
{
// rcf generator for golden ratio //
return 1;
}
...
build(x, phi);
...
// This will calculate the golden ratio (1 + sqrt(5)) / 2 in x -- very quickly!

Converts a double to flash format.

Parameters:

←d
→w The flash equivalent of d

Extracts the denominator of a flash number.

Parameters:

←x
→y The denominator of x

Calculates arc-cosine of a flash number, using fasin().

Parameters:

←x
→y = arccos(x)

Precondition:

|x| must be less than or equal to 1.

Calculates hyperbolic arc-cosine of a flash number.

Parameters:

←x
→y = arccosh(x)

Precondition:

|x| must be greater than or equal to 1.

Adds two flash numbers.

Parameters:

←x
←y
→z = x + y

Calculates arc-sin of a flash number, using fatan().

Parameters:

←x
→y = arcsin(x)

Precondition:

|x| must be less than or equal to 1.

Calculates hyperbolic arc-sin of a flash number.

Parameters:

←x
→y = arcsinh(x)

Calculates the arc-tangent of a flash number, using an O(n2.5) method based on Newton's iteration.

Parameters:

←x
→y = arctan(x)

Calculates the hyperbolic arc-tangent of a flash number.

Parameters:

←x
→y = arctanh(x)

Precondition:

x2 must be less than 1

Compares two flash numbers.

Parameters:

←x
←y

Returns:

-1 if y > x, +1 if x > y and 0 if x = y

Converts a simple fraction to flash format.

Parameters:

←n
←d
→x = n/d

Calculates cosine of a given flash angle, using ftan().

Parameters:

←x
→y = cos(x)

Calculates hyperbolic cosine of a given flash angle.

Parameters:

←x
→y = cosh(x)

Divides two flash numbers.

Parameters:

←x
←y
→z = x/y

Converts a flash number to double format.

Parameters:

←w

Returns:

The value of the parameter x as a double

Precondition:

The value of x must be representable as a double.

Calculates the exponential of a flash number using O(n2.5) method.

Parameters:

←x
→y = ex

Add a simple fraction to a flash number.

Parameters:

←x
←n
←d
→y = x + n/d

Example:

// This subtracts two-thirds from the value of x
fincr(x, -2, 3, x);

Calculates the natural log of a flash number using O(n2.5) method.

Parameters:

←x
→y = log(x)

Performs primitive flash operation. Used internally. See source listing comments for more details.

Parameters:

←x
←y
←op
→z = Fn(x,y), where the function performed depends on the parameter op.

Finds the remainder when one flash number is divided by another.

Parameters:

←x
←y
→z = x (mod y)

Multiplies two flash numbers.

Parameters:

←x
←y
→z = xy

Forms a flash number from big numerator and denominator.

Parameters:

←n
←d
→x = n/d

Precondition:

The denominator must be non-zero. Flash variable x and big variable d must be distinct. The resulting flash variable must not be too big for the representation.

Calculates π using Gauss-Legendre O(n2 log n) method. Note that on subsequent calls to this routine, π is immediately available, as it is stored internally. (This routine is disappointingly slow. There appears to be no simple way to calculate a rational approximation to π quickly).

Parameters:

→pi =π

Internally allocated memory is freed when the current MIRACL instance is ended by a call to mirexit().

Multiplies a flash number by a simple fraction.

Parameters:

←x
←n
←d
→y = xn/d

Raises a flash number to an integer power.

Parameters:

←x
←n
→w = xn

Raises a flash number to a flash power.

Parameters:

←x
←y
→z = xy

Generates a random flash number.

Parameters:

→x A flash random number in the range 0 < x < 1

Calculates reciprocal of a flash number.

Parameters:

←x
→y = 1/x

Calculates n-th root of a flash number using Newton's O(n2) method.

Parameters:

←x
←n
→w = nx

Returns:

TRUE for exact root, otherwise FALSE.

Calculates sine of a given flash angle. Uses ftan().

Parameters:

←x
→y = sin(x)

Calculates hyperbolic sine of a given flash angle.

Parameters:

←x
→y = sinh(x)

Subtracts two flash numbers.

Parameters:

←x
←y
→z = x − y

Calculates the tan of a given flash angle, using an O(n2.5) method.

Parameters:

←x
→y = tan(x)

Calculates the hyperbolic tan of a given flash angle.

Parameters:

←x
→y = tanh(x)

Separates a flash number to a big number and a flash remainder.

Parameters:

←x
→y = int(x)
→z The fractional remainder. If y is the same as z, only int(x) is returned

Forms a rounded flash number from big numerator and denominator. If rounding takes place the instance variable EXACT is set to FALSE. EXACT Is initialised to TRUE in routine mirsys(). This routine is used internally.

Parameters:

←num
←den
→z = R(num/dem)--- the flash number num/dem is rounded if necessary to fit the representation

Precondition:

The denominator must be non-zero.

Extracts the numerator of a flash number.

Parameters:

←x
→y the numerator of x