Multiplies the sum of two single-precision vectors by a single-precision scalar value.
SDKs
- iOS 4.0+
- macOS 10.4+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Framework
- Accelerate
Declaration
func vDSP_vmsa(_ __A: Unsafe Pointer<Float>, _ __IA: v DSP _Stride, _ __B: Unsafe Pointer<Float>, _ __IB: v DSP _Stride, _ __C: Unsafe Pointer<Float>, _ __D: Unsafe Mutable Pointer<Float>, _ __ID: v DSP _Stride, _ __N: v DSP _Length)
Parameters
__A
Single-precision real input vector.
__IA
Stride for
A
.__B
Single-precision real input vector.
__IB
Stride for
B
.__C
Single-precision real input scalar.
__D
Single-precision real output vector.
__ID
Stride for
D
.__N
The number of elements to process.
Discussion
This function calculates the products of the first N
elements of A
and B
, adds each product to the scalar value C
, and writes the result to D
:

The operation is:
for (n = 0; n < N; ++n)
D[n] = A[n] * B[n] + C;
The following code shows an example of using v
:
let stride = vDSP_Stride(1)
let a: [Float] = [10, 20, 30, 40, 50]
let b: [Float] = [ 1, 2, 3, 4, 5]
var c: Float = 2
let n = vDSP_Length(a.count)
var d = [Float](repeating: 0,
count: a.count)
vDSP_vmsa(a, stride,
b, stride,
&c,
&d, stride,
n)
// Prints "[12.0, 42.0, 92.0, 162.0, 252.0]"
print(d)