I'm trying to use complex types for functions in Accelerate such as cblas_cgemv
. See example below. I set the preprocessor macros in Xcode to ACCELERATE_NEW_LAPACK=1
and ACCELERATE_LAPACK_ILP64=1
for the new BLAS and LAPACK headers. This fails to build because Xcode expects OpaquePointer
types. I have no idea how to work with opaque types in Swift so any suggestions would be welcome.
import Accelerate
let a = [DSPComplex(real: 1.0, imag: 2.0), DSPComplex(real: 3.0, imag: 4.0),
DSPComplex(real: 5.0, imag: 6.0), DSPComplex(real: 7.0, imag: 8.0)]
let x = [DSPComplex(real: 1.0, imag: 2.0), DSPComplex(real: 3.0, imag: 4.0)]
let m = 2 // rows in matrix A
let n = 2 // columns in matrix A
let alpha = 1 // scale factor for αAX
let beta = 1 // scale factor for βY
var y = [DSPComplex](repeating: DSPComplex(), count: m)
// Calculate Y ← αAX + βY
cblas_cgemv(CblasRowMajor, CblasNoTrans, m, n, alpha, a, m, x, 1, beta, y, 1)
print(y)