Absolute value


Get the absolute values of a vector using the vDSP.absolute function.


import Accelerate

let x = [-3.1, -0.08, 12.1, -9, 2.4]
let y = vDSP.absolute(x)

// y is [3.1, 0.08, 12.1, 9.0, 2.4]

Gavin Wiggins © 2022