compress(_:gatingVector:nonZeroGatingCount:)
Returns a compressed copy of the specified double-precision vector using the nonzero values in a gating vector.
Declaration
static func compress<T, U>(_ vector: T, gatingVector: U, nonZeroGatingCount: Int?) -> [Double] where T : AccelerateBuffer, U : AccelerateBuffer, T.Element == Double, U.Element == DoubleParameters
- vector:
The source vector that the function compresses.
- gatingVector:
The gating vector.
- nonZeroGatingCount:
The number of nonzero elements in
gatingVector. Set tonilto have the operation calculate this value for you.
Return Value
The result of the compression operation.
Discussion
The following code shows an example of compressing the values in source using the nonzero values in gatingVector:
let source: [Double] = [1, 2,
3, 4,
5, 6,
7, 8]
let gatingVector: [Double] = [-1, 0,
1, 0,
0.001, 0,
10, 0]
let destination = vDSP.compress(source,
gatingVector: gatingVector,
nonZeroGatingCount: nil)
// Prints "[1.0, 3.0, 5.0, 7.0]".
print(destination)