PRO generate_polynomial_basis_1d, x, fx, x0, polyterms, polybasis, status
; Description: For an input parameter "x", the module first transforms "x" into a new
; variable "X" defined by:
;
; X = fx*(x - x0)
;
; The module then calculates the polynomial basis functions corresponding to
; the polynomial terms defined by "polyterms", and it stores them in the
; output array "polybasis". The input parameter "x" may be a scalar, vector
; or array.
;
; Input Parameters:
;
; x - FLOAT/DOUBLE SCALAR/VECTOR/ARRAY - The value of the independent variable.
; fx - FLOAT/DOUBLE - The scale factor for the independent variable as defined above.
; x0 - FLOAT/DOUBLE - The offset for the independent variable as defined above.
; polyterms - INTEGER/LONG VECTOR - A one-dimensional vector of length "nterms" that
; contains the exponents of the independent variable
; for each polynomial term. All values in this vector
; must be non-negative.
;
; Output Parameters:
;
; polybasis - DOUBLE ARRAY - A two-dimensional array of size "nterms" by "Nx" elements,
; where "nterms" is the number of polynomial terms in the
; input parameter "polyterms" and "Nx" is the number of
; elements in the input parameter "x". This array contains
; the "nterms" vectors of polynomial basis functions
; corresponding to each polynomial term. Hence the vector
; "polybasis[i,*]" is the polynomial basis function
; corresponding to the ith polynomial term.
; status - INTEGER - If the module successfully generated the polynomial basis function
; array, then "status" is returned with a value of "1", otherwise it
; is returned with a value of "0".
;
; Author: Dan Bramich (dan.bramich@hotmail.co.uk)
;
; History:
;
; 10/12/2010 - Module created (dmb).
;Set the default output parameter values
;Check that "x" is of the correct number type
;Check that "fx" and "x0" are numbers of the correct type
;Check that "polyterms" is a one-dimensional vector of the correct number type, and that it has no
;negative elements
;Determine the unique set of powers of "x"
;If the only unique power of "x" is "0"
;Generate the output polynomial basis function array
;Set "status" to "1" and finish
;Transform the independent variable "x" into the new variable "X" as defined above
;Set up the output polynomial basis function array
;For each unique power of "x"
;Extract the current unique power of "x"
;Determine the set of like polynomial terms
;If the current unique power of "x" is "0"
;Generate and store the polynomial basis function corresponding to the current unique power of "x"
;If the current unique power of "x" is not "0"
;If the scale factor for the independent variable is zero
;Generate and store the null polynomial basis function
;Generate and store the polynomial basis function corresponding to the current unique power of "x"
;Set "status" to "1"