GXMATH class

class GXMATH(handle=0)

GXMATH class.

This is not a class. This is a collection of standard mathematical functions, including most of the common logarithmic and geometric functions.

classmethod abs_double_(z)

Calculate absolute value

Parameters:z (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod abs_int_(n)

Calculate absolute value

Parameters:n (int) – Integer
Returns:Integer
Return type:int

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod and_(pi_val1, pi_val2)

Return the unary operation result of A & B

Returns an integer number

If A or B is a dummy, returns dummy.

Parameters:
  • pi_val1 (int) – A
  • pi_val2 (int) – B
Return type:

int

New in version 6.3.

License: Geosoft Open License

classmethod arc_cos_(val)

Calculate the arccosine

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values or values < -1 or > 1 return dummy

classmethod arc_sin_(val)

Calculate the arcsin

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values or values < -1 or > 1 return dummy

classmethod arc_tan2_(y, x)

Calculate ArcTan(Y/X)

Parameters:
  • y (float) – Y
  • x (float) – X
Returns:

Real

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: If either X or Y is a dummy, returns dummy

classmethod arc_tan_(val)

Calculate the arctan

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod ceil_(z)

Calculates the ceiling of the value

Parameters:z (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod cos_(val)

Calculate the cosine

Parameters:val (float) – Angle in radians
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod cross_product_(x1, y1, z1, x2, y2, z2, x3, y3, z3)

Cross product of two vectors.

Parameters:
  • x1 (float) – X1 component
  • y1 (float) – Y1 component
  • z1 (float) – Z1 component
  • x2 (float) – X2 component
  • y2 (float) – Y2 component
  • z2 (float) – Z2 component
  • x3 (float_ref) – X3 component (output)
  • y3 (float_ref) – Y3 component (output)
  • z3 (float_ref) – Z3 component (output)

New in version 6.0.

License: Geosoft Open License

classmethod dot_product_3d_(x1, y1, z1, x2, y2, z2)

Compute Dot product of two vectors.

Parameters:
  • x1 (float) – X1 component
  • y1 (float) – Y1 component
  • z1 (float) – Z1 component
  • x2 (float) – X2 component
  • y2 (float) – Y2 component
  • z2 (float) – Z2 component
Returns:

Dot product

Return type:

float

New in version 6.0.

License: Geosoft Open License

classmethod exp_(val)

Calculate e raised to the power of X

Parameters:val (float) – X
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod floor_(z)

Calculates the floor of the value

Parameters:z (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod hypot_(x, y)

sqrt(X*X + Y*Y)

Parameters:
  • x (float) – X
  • y (float) – Y
Returns:

Real

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: If either X or Y is a dummy, the returned value is dummy

is_null()

Check if this is a null (undefined) instance

Returns:True if this is a null (undefined) instance, False otherwise.
Return type:bool
classmethod lambda_trans_(z, lda)

Performs lambda transform on a value.

Parameters:
  • z (float) – Z Value
  • lda (float) – Lambda value
Returns:

The lambda transformed value

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: Returns 0 for input Z = 0. returns log10(Z) for lambda = 0. returns (Z^lambda - 1)/lambda for Z > 0. returns dummy for Z = dummy.

classmethod lambda_trans_rev_(z, lda)

Performs a reverse lambda transform on a value.

Parameters:
  • z (float) – Lambda transformed Z Value
  • lda (float) – Lambda value
Returns:

The original non-lambda transformed value

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: See rLambdaTrans.

See also

lambda_trans_

classmethod log10_(val)

Calculate the base 10 log

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod log_(val)

Calculate the natural log

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod log_z_(z, mode, min)

Given a Z value and the Log style and Log Minimum this function will return the log value.

Parameters:
  • z (float) – Z Value
  • mode (int) – Log Mode (0 - Log, 1 - LogLinearLog)
  • min (float) – Log Minimum (must be greater than 0)
Returns:

The Log Value.

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: Mode = 0 (regular log mode) returns:

Log10(Z)  for Z > minimum
Log10(minimum) for Z <= minimum

Mode = 1 (log / linear / negative log mode) returns:

minimum * ( log10( |Z| / minimum) + 1 )   for Z > minimum
Z for |Z| <= minimum   (the linear part of the range)
-minimum * ( log10( |Z| / minimum) + 1 )   for Z < -minimum

See also

un_log_z_

classmethod mod_double_(a, b)

Calculates the modulus of two reals (A mod B)

Parameters:
  • a (float) – A
  • b (float) – B (must not be zero)
Returns:

Real

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: The modulus of A with respect to B is defined as the difference of A with the largest integral multiple of B smaller than or equal to A.

e.g. A mod B 20 mod 10 = 0 20 mod 9 = 2

f A or B is a dummy, returns dummy.

classmethod mod_int_(a, b)

Calculates the modulus of two integers

Parameters:
  • a (int) – A
  • b (int) – B (must not be zero)
Returns:

Int

Return type:

int

New in version 6.0.1.

License: Geosoft Open License

Note: If A or B is a dummy, returns dummy.

classmethod nicer_log_scale_(min, max, fine)

Finds nicer min, max values for logarithmic plot scales.

Parameters:
  • min (float_ref) – Min value (changed)
  • max (float_ref) – Max value (changed)
  • fine (int) – Fine flag

New in version 6.0.1.

License: Geosoft Open License

Note: Will fail if the input upper bound is less than the lower bound, but will work if the two values are equal. The input bounds are overwritten.

Input lower and upper bounds, returns “nicer” values. If the Fine flag is set to TRUE, the values will have the form N x 10^Y, where N is a value from 1 to 9, and 10^Y is an integral power of 10. If the Fine flag is set to FALSE, the scaling is coarse, and the bounding exact powers of 10 are returned. For example, the values (.034, 23) return (.03, 30) for fine scaling, and (0.01, 100) for coarse scaling.

classmethod nicer_scale_(min, max, inc, pow)

Compute a nicer scale for a given min and max.

Parameters:

New in version 6.0.1.

License: Geosoft Open License

classmethod normalise_3d_(x, y, z)

Scale a vector to unit length.

Parameters:

New in version 6.0.

License: Geosoft Open License

Note: Divides each component by the vector magnitude.

classmethod null()

A null (undefined) instance of GXMATH

Returns:A null GXMATH
Return type:GXMATH
classmethod or_(pi_val1, pi_val2)

Return the unary operation result of A | B

Returns an integer number

If A or B is a dummy, returns dummy.

Parameters:
  • pi_val1 (int) – A
  • pi_val2 (int) – B
Return type:

int

New in version 6.3.

License: Geosoft Open License

classmethod pow_(x, y)

Calculate X raised to the power of Y

Parameters:
  • x (float) – X
  • y (float) – Y
Returns:

Real

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: If either X or Y is a dummy, returns dummy

classmethod rand_()

Get a random number between 0 and 1

Returns:A real number
Return type:float

New in version 6.3.

License: Geosoft Open License

Note: Use s_rand_ to seed the random number generator before a series of calls to this function are made. The standard “C” function rand() is called.

classmethod rotate_vector_(x1, y1, z1, angle, x2, y2, z2, x3, y3, z3)

Rotate a vector about an axis.

Parameters:
  • x1 (float) – X1 component (vector to rotate)
  • y1 (float) – Y1 component
  • z1 (float) – Z1 component
  • angle (float) – Angle to rotate, CW in radians
  • x2 (float) – X2 component (axis of rotation)
  • y2 (float) – Y2 component
  • z2 (float) – Z2 component
  • x3 (float_ref) – X3 component (rotated vector, can
  • y3 (float_ref) – Y3 component be the same as input)
  • z3 (float_ref) – Z3 component

New in version 6.0.

License: Geosoft Open License

Note: Rotates a vector by the input angle around an arbitrary axis. Angles are measured clockwise looking along the axis (away from the origin). Assumes a right hand coordinate system.

classmethod round_double_(z, n)

Round to n significant digits

Parameters:
  • z (float) – Real
  • n (int) – Number of significant digits to round to
Returns:

Real

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: Negative values ending in 5XXX to n sig digits round down Positive values ending in 5XXX to n sig digits round up Dummy values return dummy

classmethod round_int_(z)

Round to the nearest whole number

Parameters:z (float) – Round
Returns:Integer
Return type:int

New in version 6.0.1.

License: Geosoft Open License

Note: Negative values with decimal parts larger than .5 round down (-1.5 -> 2.0) Positive values with decimal parts larger than .5 round up (1.5 -> 2.0) Dummy values return dummy

classmethod s_rand_()

Seed the random-number generator with current time

New in version 6.3.

License: Geosoft Open License

Note: Use the rand_ function to create a random number between 0 and 1. The standard “C” function srand() is called.

classmethod sign_(z_sign, z_val)

Determine return value based on value of Z1

Parameters:
  • z_sign (float) – Z1
  • z_val (float) – Z2
Returns:

|Z2| if Z1 > 0, -|Z2| if Z1 < 0, 0 if Z1 = 0, and Z2 if Z1 = Dummy

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod sin_(val)

Calculate the sin

Parameters:val (float) – Angle in radians
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod sqrt_(val)

Calculate the square root

Parameters:val (float) – Real
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod tan_(val)

Calculate the tangent

Parameters:val (float) – Angle in radians
Returns:Real
Return type:float

New in version 6.0.1.

License: Geosoft Open License

Note: Dummy values return dummy

classmethod un_log_z_(z, mode, min)

Inverse of rLogZ

Parameters:
  • z (float) – Log value
  • mode (int) – Log Mode (0 - Log, 1 - LogLinearLog)
  • min (float) – Log Minimum (must be greater than 0)
Returns:

The original value

Return type:

float

New in version 6.0.1.

License: Geosoft Open License

Note: See Notes for rLogZ.

See also

log_z_

classmethod xor_(pi_val1, pi_val2)

Return the unary operation result of A ^ B

Returns an integer number

If A or B is a dummy, returns dummy.

Parameters:
  • pi_val1 (int) – A
  • pi_val2 (int) – B
Return type:

int

New in version 6.3.

License: Geosoft Open License