Contents

swapElements(_:_:)

Swaps the elements of two double-precision vectors.

Declaration

static func swapElements<T, U>(_ vectorA: inout T, _ vectorB: inout U) where T : AccelerateMutableBuffer, U : AccelerateMutableBuffer, T.Element == Double, U.Element == Double

Parameters

  • vectorA:

    The first vector.

  • vectorB:

    The second vector.

Discussion

The following code swaps the elements in vectorA with those in vectorB:

var vectorA: [Double] = [1, 3, 5, 7]
var vectorB: [Double] = [2, 4, 6, 8]

vDSP.swapElements(&vectorA,
                  &vectorB)

// Prints "[2.0, 4.0, 6.0, 8.0]".
print(vectorA)

// Prints "[1.0, 3.0, 5.0, 7.0]".
print(vectorB)

See Also

Vector-to-vector element swapping functions