IBM Books

Engineering and Scientific Subroutine Library for AIX Version 3 Release 3: Guide and Reference

SIZC and DIZC--I-th Zero Crossing

These subroutines find the position of the i-th zero crossing in vector x. This is the i-th transition between positive and negative or negative and positive, where 0 is considered a positive value. It returns the position of the element in vector x where the i-th zero crossing is detected. The direction of the scan is either from the first element to the last or from the last element to the first, depending on the value you specify for the scan direction argument.

Table 144. Data Types

x Subroutine
Short-precision real SIZC
Long-precision real DIZC

Syntax

Fortran CALL SIZC | DIZC (x, idrx, n, i, ky)
C and C++ sizc | dizc (x, idrx, n, i, ky);
PL/I CALL SIZC | DIZC (x, idrx, n, i, ky);

On Entry

x
is the target vector x of length n. Specified as: a one-dimensional array of (at least) length n, containing numbers of the data type indicated in Table 144.

idrx
indicates the scan direction. If it is positive or 0, x is scanned from the first element to the last (1, n). If it is negative, x is scanned from the last element to the first (n, 1). Specified as: a fullword integer. It can have any value.

n
is the number of elements in vector x. Specified as: a fullword integer; n > 1.

i
is the number of the zero crossing to be identified. Specified as: a fullword integer; i > 0.

ky
See On Return.

On Return

ky
is the integer vector ky of length 2, containing elements ky1 and ky2, where:

If the i-th zero crossing is found:

If the i-th zero crossing is not found:

Returned as: an array of (at least) length 2, containing fullword integers.

Note

The aux and naux arguments, required in some earlier releases of ESSL, are no longer required by these subroutines. If your program still includes them, you do not have to change your program; it continues to run normally. It ignores these arguments. However, if you did any program checking for error code 2015, you may want to remove it, because this error no longer occurs. (You must not code these arguments in your C program.)

Function

The i-th zero crossing in vector x is found by scanning vector x for i occurrences of TRUE for the following logical expressions. A zero crossing is defined here as a crossing either from a positive value to a negative value or from a negative value to a positive value, where 0 is considered a positive value. If the i-th zero crossing is found, the value of j at that point is returned in ky1 as the position of the i-th zero crossing, and i is returned in ky2.

If idrx  >= 0:

TRUE = (xj-1 < 0 and xj >= 0) or (xj-1 >= 0 and xj < 0) for j = 2, n

If idrx  < 0:

TRUE = (xj+1 < 0 and xj >= 0) or (xj+1 >= 0 and xj < 0) for j = n-1, 1

If the position of the i-th zero crossing is not found, 0 is returned in y1 and the number of zero crossings encountered in the scan is returned in y2.

SIZC provides the same functions as the IBM 3838 functions NZCP and NZCN, with restrictions removed. It combines these functions into one ESSL subroutine. DIZC provides a long-precision computation that is not included in the IBM 3838 functions. See the IBM 3838 Array Processor Functional Characteristics manual.

Error Conditions

Computational Errors

None

Input-Argument Errors
  1. n <= 1
  2. i <= 0

Example 1

This example shows a scan of a vector x from the first element to the last. It is looking for the fifth zero crossing, which is encountered at position 9.

Call Statement and Input
           X  IDRX  N    I   KY
           |   |    |    |   |
CALL SIZC( X , 1  , 12 , 5 , KY )
 
X        =  (2.0, -1.0, -3.0, 3.0, 0.0, 8.0, -2.0, 0.0, -5.0, -3.0,
             2.0, -9.0)

Output
KY       =  (9, 5)

Example 2

This example shows a scan of a vector x from the last element to the first. It is looking for the seventh zero crossing, which is encountered at position 3. Because IDRX is negative, X is scanned from the last element, X(12), to the first element, X(1).

Call Statement and Input
           X  IDRX  N    I   KY
           |    |   |    |   |
CALL SIZC( X , -1 , 12 , 7 , KY )
 
X        =  (2.0, -1.0, 3.0, -3.0, 0.0, -8.0, -2.0, 0.0, -5.0, -3.0,
             2.0, -9.0)

Output
KY       =  (3, 7)

Example 3

This example shows a scan of a vector x when the i-th zero crossing is not found. It encounters seven zero crossings and returns this value in KY(2).

Call Statement and Input
           X  IDRX  N    I    KY
           |   |    |    |    |
CALL SIZC( X , 1  , 12 , 10 , KY )
 
X        =  (2.0, -1.0, -3.0, 3.0, 0.0, 8.0, -2.0, 0.0, -5.0, -3.0,
             2.0, -9.0)

Output
KY       =  (0, 7)


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]