File: h_maths.e
Created: 17th/Dec/2003
Author: Hayden McKay
E-Mail: hmck1@dodo.com.au


h_maths.e

Function Descriptions:
p_ints: Pack two integers into one integer.
u_ints: Restore packed integer to origional integers.
dec_to_hour: Convert a decimal to hour,min,sec format.
atan: Calculate the angle of a vector.
atan2: Calculate the tanget angle of vector X in respect to vector Y.
EE: Calcutate the engineering exponent.
root: Calculate the root of a digit.
f_int: Floor integer to nearest integer.
jul_to_gre: Convert a julian date to gregorian format.
gre_to_jul: Convert a gregorian date to julian format.
perfect: Test integer to see if its a perfect number.
factors: Calculate all even factors of an integer.
ratio: Calculates the compression ratio of a file.

Licence & Disclaimer


Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to not alter it and redistribute it
freely in any way, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software or remove the original
authors' names.
2. Altered source versions are not permitted as such, and must not
be misrepresented as being the original software.
3. All software distributions, without modifications, must be
distributed under this license. And any later versions, in which case,
you should replace this notice with an appropriate one.
If this software is distributed as part of a larger product,
this item does not apply to the rest of the product.
4. If you use this software in a product, an acknowledgment in the
product documentation is required. If the software for the product
is not freely distributed, you must include information on how to
freely obtain the original software.

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

If you want to distribute this software in a way not allowed by this
license, or distribute the software under different license terms, contact
the authors for permission.


Functions


integer = p_ints(integer digit, integer digit)
Pack two integers onto one integer.
Returns a single integer.



sequence = u_ints(integer digit)
Unpack packed integer into origional integers.
Returns a double integer sequence.



sequence = dec_to_hour(atom digit)
Convert a decimal to hour, min, sec format.
Returns sequence {hour, min, sec}.



atom = atan(sequence X{x,y})
Calculate the angle of vector X.
Returns the angle, -1 on fail.

NOTE: I was unable to compare this formula with results from other languages and therefor dont know if I got it correct.
IN THE MEANTIME: atan2 has proven itself to give correct results and I recommend using atan2 instead of atan.
HOWEVER: If atan proves to be incorrect and you can fix it, please do and e-mail me a copy of the function so I may update h_maths.e



atom = atan2(sequence X{x,y},sequence Y{x,y})
Calculate the angle of vector X in respect to vector Y.
Returns the angle, -1 on fail.



atom = EE(atom digit)
Calcutate the engineering exponent given a digit & factor.
Returns the engineered expoential of the digit.



atom = root(atom digit, integer factor)
Calculate the root of a digit.
Returns the desired root.



integer = f_int(atom digit)
Floor integer to nearest integer.
Returns the nearest integer.



sequence = jul_to_gre(atom julian_date)
Convert a julian date to gregorian format.
Returns date in {dd/mm/yyyy} format.



atom = gre_to_jul(sequence {dd/mm/yyyy})
Convert a gregorian date to julian format.
Returns date in julian format, -1 on fail.



integer = perfect(integer digit)
Test integer to see if its a perfect number.
Returns 1 if perfect, -1 otherwise.



sequence = factors(integer digit)
Calculate all even factors of an integer.
Returns sequence of even factors -- {{x,y},{x,y},etc...}).



sequence = ratio(atom size_before, atom size_after)
Calculates the compression ratio of a file.
Returns the compression ratio. -- {x,1}

NOTE: Both before and after sizes must be of the same format. Ex: MB & MB or kB & kB etc...