简体   繁体   中英

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). 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. Can I connect this Python file in a Swift app?

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?

Implement the algorithm in 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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