1.2

| home | graph lib | utility lib | custom lib | auxiliary lib | tutorials |

   Array
   BIO
   HDF
   Make
   Math
   netCDF

Math Package

The Template Numerical Toolkit is used for numerical computing involving matrix. Special functions in the CEPHES linrary are used for statistical tests. Functions include cos, acos, cosh, sin, sinh, asin, tan, tanh, atan, floor, ceil, sqrt, exp, log, mod, pow, rad2deg, deg2rad, rand, linear, spline, interpo, cal2jul, jul2cal, msmooth, psmooth, perlin, corr, lfit, mfit, lu, svd, qr, eigenvalue, cholesky.

.cos(arr)

arr - a zeArray object of double floating type.

Applies basic C math functions to the array element-wise. Functions of cosh, acos, sin, sinh, asin, tan, tanh, atan, floor, ceil, sqrt, exp, and log are implemented.

.mod(arr, par)

arr - a zeArray of double floating type.

par - a number or a zeArray of double floating type.

Applies mod function to all arr elements. If the mod factor par is an array, its size must be the same as that of arr.

.pow(arr, par)

arr - a zeArray of double floating type.

par - a number or zeArray of double floating type.

Applies pow function to all arr elements. The power factor is is an array, its size must be the same as that of arr.

.rad2deg(arr)

arr - a zeArray object of double floating type.

Converts all arr elements from radius to degree.

.deg2rad(arr)

arr - a zeArray object of double floating type.

Converts all arr elements from degree to radius.

.rand(arr[, seed])

arr - a zeArray of double floating type.
seed - random number seed.

Fill array elements with random numbers between 0 and 1.

.linear(arr, n)

arr - a zeArray of double floating typ.
n - number of interpolation.

Linearly interpolates the array n times, i.e., inserts n interpolcated data bentween grids. If arr has only one vector, the interpolcaiton is one dimensional; otherwise two dimensional.

.spline(arr, n)

arr - a zeArray of double floating.
n - number of interpolation.

Cubic spline interpolation of the array for n times, i.e., inserts n interpolcated data bentween grids. If arr has only one vector, the interpolcaiton is one dimensional; otherwise two dimensional.

.interpo(arr, n, method)

arr - a zeArray of double floating type.

n - number of interpolation.
method - callback function name.

Interpolates the array n times, i.e., inserts n interpolcated data bentween grids. If arr has only one vector, the interpolcaiton is one dimensional; otherwise two dimensional. The method is a user supplied callback function that should returns interpolation weighting factors for a variable between 0 (the firt grid point) and 1 (the second grid point).

.cal2jul(cal, jul)

cal - a zeArray of double type containing year, month, and day as input.
jul - a zeArray of double type as outut of julian day.

Converts Gregorian calender date to Julian day.

.jul2cal(jul, cal)

jul - a zeArray of double type as input of julian day.
cal - a zeArray of double type as output of canlender date.

Converts Julian day to Gregorian calender date, i.e., year, month, and day in the first three vectors.

.msmooth(arr, n)

arr - a 1D-zeArray of double type.
n - a integer number.

Moving average smooth of data in arr. The number of points used for smoothing will be 2n+1.

.psmooth(arr, n, m)

arr - a 1D-zeArray of double type.
n - number of left-right points.
m - polynomial power.

Polynomial smoothing of data in arr. The number of points used for smoothing will be 2n+1.

.perlin(arr, n[, func])

arr - a zeArray of double type.
n - octave number greater than 1 and less then 17.
func - a string to specify a callback function.

Generates Perlin noise. The arrary arr must be two dimensional filled with random number. If the callback function is provided, the function will try to get persistent parameters for noises of different frequencies. The callback function should take a argument that varies from 1 to n (corresponding to low and high frequencies, respectively) and return a persistent parameter.

.corr(x, y)

x - a 1D-zeArray of double type.
y - a 1D-zeArray of double type.

Returns the correlation coefficient between x and y, the significance level at which the null hypothesis of zero correlation is disproved, and Fisher's number.

.lfit(x, y)

x - a 1D-zeArray of double type.
y - a 1D-zeArray of double type.

Fits x and y to a straight line y = a + b*x and returns a, b, the chi-square, and the probable uncertainties of a and b.

.mfit(x, y)

x - a 2D-zeArray of double type with row number larger than or equal to column number.
y - a 1D-zeArray of double type.

Multi-linear fitting of the equation y = a0 + a1*x1 + a2*x2 + ... + an * xn Returns coefficients a0 to an.

.lu(A, L, U, P)

A - a 2D-zeArray of double type as input
L - a zeArray of double type as output
U - a zeArray of double type as output
P - a zeArray of integer type as output

For an m-by-n matrix A with m >= n, the LU decomposition is an m-by-n unit lower triangular matrix L, an n-by-n upper triangular matrix U, and a permutation vector piv of length m so that A(P,:) = L*U.

.svd(A, L, U, S)

A - a 2D-zeArray of double type as input
U - a zeArray of double type as output
V - a zeArray of double type as output
S - a zeArray of double type as output

For an m-by-n matrix A with m >= n, the singular value decomposition is an m-by-n orthogonal matrix U, an n-by-n diagonal matrix S, and an n-by-n orthogonal matrix V so that A = U*S*V'. The singular values, S[k], are ordered so that S[0] >= S[1] >= ... >= S[n-1]. Returns the matrix rank.

.qr(A, L, U, S)

A - a 2D-zeArray of double type as input
Q - a zeArray of double type as output
R - a zeArray of double type as output

For an m-by-n matrix A with m >= n, the QR decomposition is an m-by-n orthogonal matrix Q and an n-by-n upper triangular matrix R so that A = Q*R. Returns 1 if matrix is full rank, 0 otherwise.

.eigenvalue(A, L, U, S)

A - a 2D-zeArray of double type as input
V - a zeArray of double type as output
D - a zeArray of double type as output

Computes eigenvalues and eigenvectors of a real (non-complex) matrix. If A is symmetric, then A = V*D*V' where the eigenvalue matrix D is diagonal and the eigenvector matrix V is orthogonal. That is, the diagonal values of D are the eigenvalues, and V*V' = I, where I is the identity matrix. The columns of V represent the eigenvectors in the sense that A*V = V*D. If A is not symmetric, then the eigenvalue matrix D is block diagonal with the real eigenvalues in 1-by-1 blocks and any complex eigenvalues, a + i*b, in 2-by-2 blocks, [a, b; -b, a].

.cholesky(A, L)

A - a 2D-zeArray of double type as input
L - a zeArray of double type as output

For a symmetric, positive definite matrix A, this function computes the Cholesky factorization, i.e. it computes a lower triangular matrix L such that A = L*L'. If the matrix is not symmetric or positive definite, the function computes only a partial decomposition. Returns 1 if original matrix to be factored was symmetric positive-definite; 0 otherwise.