简体   繁体   English

如何在我的Swift软件应用程序中为我的函数计算运行Python代码?

[英]How do I run Python code for my function calculations in my Swift software App?

I am creating an app where the user inputs two values (x and y). 我正在创建一个应用程序,用户输入两个值(x和y)。 These two values are used in a function to output an answer that is displayed at the bottom of the app. 这两个值在函数中用于输出应用程序底部显示的答案。 These calculations include gaussian covariance calculations, so they must be done in my Python script, which will result in one final value to be outputted. 这些计算包括高斯协方差计算,因此必须在我的Python脚本中完成,这将导致输出一个最终值。 Can I connect this Python file in a Swift app? 我可以在Swift应用程序中连接这个Python文件吗?

I know how to create an Xcode project that is an external file that can connect with python, but how do I do this in my Swift project I have already built? 我知道如何创建一个Xcode项目,它是一个可以与python连接的外部文件,但是我如何在我已经构建的Swift项目中执行此操作?

Implement the algorithm in Swift 在Swift中实现算法

I don't think a covariance would be particularly hard to do and if you implement it in the open source Upsurge library you will get unbelievably better performance as it uses the Accelerate Framework (ie specially tuned calls to SIMD that Apple engineers have spent a lot of time on). 我不认为协方差会特别难以做到,如果你在开源Upsurge库中实现它,你将获得令人难以置信的更好的性能,因为它使用Accelerate Framework(即特别调整到Apple工程师花费了大量精力的SIMD)时间)。

I added linear regression to Upsurge and it is at least an order of magnitude faster than the Python/Numpy code running on the same machine. 我在Upsurge中添加了线性回归 ,它比在同一台机器上运行的Python / Numpy代码至少快一个数量级。

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

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