PRO generate_polynomial_basis_2d, x, y, fx, fy, x0, y0, polyterms, polybasis, status
; Description: For the input parameters "x" and "y", the module first transforms "x" and "y"
; into the new variables "X" and "Y" defined by:
;
; X = fx*(x - x0)
; Y = fy*(y - y0)
;
; 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 parameters "x" and "y" may be scalars, vectors
; or arrays, and they must have the same number of elements.
;
; Input Parameters:
;
; x - FLOAT/DOUBLE SCALAR/VECTOR/ARRAY - The value of the first independent variable.
; y - FLOAT/DOUBLE SCALAR/VECTOR/ARRAY - The value of the second independent variable. This
; parameter must have the same number of elements as
; the input parameter "x".
; fx - FLOAT/DOUBLE - The scale factor for the first independent variable "x" as defined above.
; fy - FLOAT/DOUBLE - The scale factor for the second independent variable "y" as defined above.
; x0 - FLOAT/DOUBLE - The offset for the first independent variable "x" as defined above.
; y0 - FLOAT/DOUBLE - The offset for the second independent variable "y" as defined above.
; polyterms - INTEGER/LONG ARRAY - A 2 by "nterms" array of values where each pair of numbers
; represents the exponents of the first and second independent
; variables "x" and "y" for each polynomial term. All values
; in this array must be non-negative. Note that since IDL
; treats a 2 by 1 array as a two-element one-dimensional
; vector, this module accepts such a two-element one-dimensional
; vector to represent the case when "nterms" is equal to "1".
;
; 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:
;
; 09/12/2010 - Module created (dmb).
;Set the default output parameter values
;Check that "x" is of the correct number type
;Check that "y" is of the correct number type and that it has the same number of elements as "x"
;Check that "fx", "fy", "x0" and "y0" are numbers of the correct type
;Check that "polyterms" is a number array of the correct number type, dimensions and size, and
;that it has no negative elements
;Extract the list of powers of "x" and the list of powers of "y" from the parameter "polyterms"
;Determine the unique set of polynomial terms
;If the only unique polynomial term is a constant term
;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
;Transform the independent variable "y" into the new variable "Y" as defined above
;Set up the output polynomial basis function array
;For each unique polynomial term
;Extract the current unique polynomial term, and the current powers of "x" and "y"
;Determine the set of like polynomial terms
;If the current powers of "x" and "y" are both "0"
;Generate and store the polynomial basis function corresponding to the current unique polynomial term
;If the current power of "x" is not "0" and the current power of "y" is "0"
;If the scale factor for the first independent variable is zero
;Generate and store the null polynomial basis function
;Generate and store the polynomial basis function corresponding to the current unique polynomial term
;If the current power of "x" is "0" and the current power of "y" is not "0"
;If the scale factor for the second independent variable is zero
;Generate and store the null polynomial basis function
;Generate and store the polynomial basis function corresponding to the current unique polynomial term
;If both of the current powers of "x" and "y" are not "0"
;If either of the scale factors for the first or second independent variables is zero
;Generate and store the null polynomial basis function
;Generate and store the polynomial basis function corresponding to the current unique polynomial term
;Set "status" to "1"