Contents

gather(_:indices:)

Returns a gathered copy of the specified double-precision vector using a vector that defines the indices to keep.

Declaration

static func gather<T, U>(_ vector: T, indices: U) -> [Double] where T : AccelerateBuffer, U : AccelerateBuffer, T.Element == Double, U.Element == UInt

Parameters

  • vector:

    The source vector that the function gathers.

  • indices:

    The vector that contains the one-based indices.

Return Value

The result of the gather operation.

Discussion

The following code shows an example of gathering the values in source using the values in indices:

let source: [Double] = [10, 20,
                        30, 40,
                        50, 60,
                        70, 80]

let indices: [UInt] = [1, 3, 5, 7]

let destination = vDSP.gather(source,
                              indices: indices)

// Prints "[10.0, 30.0, 50.0, 70.0]".
print(destination)

See Also

Vector gathering functions