简体   繁体   English

swift 加速:vDSP 枚举

[英]swift Accelerate: the vDSP enum

I've been going through the new Accelerate framework for swift as I am looking to optimise all of my vector calculations.我一直在研究 swift 的新 Accelerate 框架,因为我希望优化我的所有矢量计算。

I found the following enum called vDSp which avoids me re-writing the entire set of vector maths: https://developer.apple.com/documentation/accelerate/vdsp-snv?changes=_2我发现了以下名为 vDSp 的枚举,它避免了我重写整个向量数学集: https://developer.apple.com/documentation/accelerate/vdsp-snv?changes=_2

However, the enum is not recognised (no such found error).但是,无法识别枚举(未发现此类错误)。 One of the enum cases is mean which takes a vector and returns the mean as a double.枚举情况之一是均值,它采用向量并将均值作为双精度值返回。 The signature is:签名是:

static func mean <U>(U) -> Double

Has anyone come across this, and know how to implement it?有没有人遇到过这个,并且知道如何实现它? I'm looking to do something like我想做类似的事情

func getMean(_ u: [Double])->Double{
    return vDSP.mean<Double>(u)
}

This would be terribly useful for what I do这对我所做的非常有用

Ok, sorry guys, I realised I hadn't downloaded Xcode 11.x.好的,对不起,我意识到我没有下载 Xcode 11.x。 Works like a charm.奇迹般有效。

Really recommend this one for anyone who can do Unsafe programming.真的向任何可以进行不安全编程的人推荐这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM