Utility Functions

Utility functions perform some common computational tasks.

gcd(A,B)

The gcd function calculates the greatest common divisor of A and B. Both A and B are assumed to be integers.

Gauss(x,xc,wx [...])

The Gauss function returns a normalized Gaussian for the specified number of dimensions.

Poly(coefsWaveName, x1)

The poly function returns the value of a polynomial function at x=x1. coefsWaveName is a wave that contains the polynomial coefficients. The number of points in the wave determines the number of terms in the polynomial.

Poly2D(coefsWaveName, x1, y1)

The poly2D function returns the value of a 2D polynomial function at x=x, y=y1. coefsWaveName is a wave that contains the polynomial coefficients. The number of points in the wave determines the number of terms in the polynomial and therefore the polynomial degree.

conj(z)

The conj function returns the complex conjugate of the complex value z.

imag(z)

The imag function returns the imaginary component of the complex number z as a real (not complex) number.

real(z)

The real function returns the real component of the complex value z.

p2rect(z)

The p2rect function returns a complex value in rectangular coordinates derived from the complex value z which is assumed to be in polar coordinates (magnitude is stored in the real part and the angle, in radians, in the imaginary part of z).

r2polar(z)

The r2polar function returns a complex value in polar coordinates derived from the complex value z which is assumed to be in rectangular coordinates. The magnitude is stored in the real part and the angle (in radians) is stored in the imaginary part of the returned complex value.

max(num1,num2)

The max function returns the more positive of num1 and num2.

min(num1,num2)

The min function returns the more negative of num1 and num2.

ceil(num)

The ceil function returns the closest integer greater than or equal to num.

floor(num)

The floor function returns the closest integer less than or equal to num.

round(num)

The round function returns the integer value closest to num . The rounding method is "away from zero".

trunc(num)

The trunc function returns the integer closest to num in the direction of zero.

mod(num,div)

The mod function returns the remainder when num is divided by div. The mod function will give unexpected results when num or div is fractional.