Function

vDSP_nzcros(_:_:_:_:_:_:)

Counts and finds the zero crossings in a single-precision vector.

Declaration

func vDSP_nzcros(_ __A: UnsafePointer<Float>, _ __IA: vDSP_Stride, _ __B: vDSP_Length, _ __C: UnsafeMutablePointer<vDSP_Length>, _ __D: UnsafeMutablePointer<vDSP_Length>, _ __N: vDSP_Length)

Parameters

__A

Single-precision real input vector.

__IA

Address stride for A.

__B

Maximum number of crossings to find.

__C

Index of last crossing found.

__D

Total number of zero crossings found

__N

Number of elements in A.

Discussion

This performs the following operation:

*D = *C = 0;
for(n = 1; n < N; n++)
{
    if( sign(A[n * IA]) != sign(A[(n - 1) * IA]) )
    {
        *D = *D + 1;
        if( *D == B)
        {
            *C = n * I;
            break;
        }
    }
}

The "function" sign(x) above has the value -1 if the sign bit of x is 1 (x is negative or -0), and +1 if the sign bit is 0 (x is positive or +0).

Scans vector A to locate transitions from positive to negative values and from negative to positive values. The scan terminates when the number of crossings specified by B is found, or the end of the vector is reached. The zero-based index of the last crossing is returned in C. C is the actual array index, not the pre-stride index. If the zero crossing that B specifies is not found, zero is returned in C. The total number of zero crossings found is returned in D.

Note that a transition from -0 to +0 or from +0 to -0 is counted as a zero crossing.

See Also

Single-Vector Zero Crossing Search

static func countZeroCrossings<U>(U) -> UInt

Returns the number of zero crossings in a double-precision vector.

static func countZeroCrossings<U>(U) -> UInt

Returns the number of zero crossings in a single-precision vector.