Contents

multiply(_:_:result:)

Calculates the double-precision element-wise product of a vector and a scalar value.

Declaration

static func multiply<U, V>(_ scalar: Double, _ vector: U, result: inout V) where U : AccelerateBuffer, V : AccelerateMutableBuffer, U.Element == Double, V.Element == Double

Parameters

  • scalar:

    The input scalar value, B.

  • vector:

    The input vector, A.

  • result:

    The output vector, C.

Discussion

This function calculates the element-wise product of vector A and scalar value B, and writes the result to vector C.

 for (n = 0; n < N; ++n)
    C[n] = A[n] * B;

[Image]

The following code shows an example of using this function:

    let count = 5
    
    let a: [Double] = [1, 2, 3, 4, 5]
    let b: Double = 10
    
    let c = [Double](unsafeUninitializedCapacity: count) {
        buffer, initializedCount in
        
        vDSP.multiply(b, a,
                      result: &buffer)
        
        initializedCount = count
    }
    
    // Prints "[10.0, 20.0, 30.0, 40.0, 50.0]".
    print(c)

See Also

Multiplication