vDSP_vsmul
Multiplies a single-precision scalar value by a single-precision vector.
Declaration
void vDSP_vsmul(const float *__A, vDSP_Stride __IA, const float *__B, float *__C, vDSP_Stride __IC, vDSP_Length __N);Parameters
- __A:
The single-precision real input vector
A. - __IA:
The stride for input vector
A. - __B:
A pointer to the single-precision real input scalar.
- __C:
The single-precision real output vector.
- __IC:
The stride for output vector
C. - __N:
The number of elements to multiply.
Discussion
This function calculates the products of the first N elements of A and the scalar value B, writing the result to C:
[Image]
The operation is:
for (n = 0; n < N; ++n)
C[n] = A[n] * B;The following code shows an example of using vDSP_vsmul:
let stride = vDSP_Stride(1)
let a: [Float] = [1, 2, 4, 5]
var b: Float = 2
let n = vDSP_Length(a.count)
var c = [Float](repeating: 0,
count: a.count)
vDSP_vsmul(a, stride,
&b,
&c, stride,
n)
// Prints "[2.0, 4.0, 8.0, 10.0]".
print(c)