Previous Next


                                                 167
SECTION 3.9                                                                 Functions



Functions in PDF represent static, self-contained numerical transformations. A
function to add two numbers has two input values and one output value:
f ( x0 , x1 ) = x0 + x1

Similarly, a function that computes the arithmetic and geometric mean of two
numbers could be viewed as a function of two input values and two output
values:
                  x0 + x1
                                 -
f ( x 0 , x 1 ) = ---------------- ,   x0 × x1
                         2

In general, a function can take any number (m) of input values and produce any
number (n) of output values:
f ( x0 , … , xm – 1 ) = y0 , … , yn – 1

In PDF functions, all the input values and all the output values are numbers, and
functions have no side effects.

Each function definition includes a domain, the set of legal values for the input.
Some types of functions also define a range, the set of legal values for the output.
Input values passed to the function are clipped to the domain, and output values
produced by the function are clipped to the range. For example, suppose the
function
f (x) = x + 2

is defined with a domain of [−1 1 ]. If the function is called with the input value 6,
that value is replaced with the nearest value in the defined domain, 1, before the
function is evaluated; the resulting output value is therefore 3. Similarly, if the
function
f ( x0 , x1 ) = 3 × x0 + x1

is defined with a range of [ 0 100 ], and if the input values −6 and 4 are passed to
the function (and are within its domain), then the output value produced by the
function, −14, is replaced with 0, the nearest value in the defined range.

A function object may be a dictionary or a stream, depending on the type of
function. The term function dictionary is used generically in this section to refer
to either a dictionary object or the dictionary portion of a stream object. A

Previous Next