We present SClib, a simple hack that allows easy and straightforward evaluation of C functions within Python code, boosting flexibility for better trade-off between computation power and feature availability, such as visualization and existing computation routines in SciPy. We also present two cases were SClib has been used. In the first set of applications we use SClib to write a port to Python of a Schr\"odinger equation solver that has been extensively used the literature, the resulting script presents a speed-up of about 150x with respect to the original one. A review of the situations where the speeded-up script has been used is presented. We also describe the solution to the related problem of solving a set of coupled Schr\"odinger-like equations where SClib is used to implement the speed-critical parts of the code. We argue that when using SClib within IPython we can use NumPy and Matplotlib for the manipulation and visualization of the solutions in an interactive environment with no performance compromise. The second case is an engineering application. We use SClib to evaluate the control and system derivatives in a feedback control loop for electrical motors. With this and the integration routines available in SciPy, we can run simulations of the control loop a la Simulink. The use of C code not only boosts the speed of the simulations, but also enables to test the exact same code that we use in the test rig to get experimental results. Again, integration with IPython gives us the flexibility to analyze and visualize the data.


翻译:我们展示了 Slib, 这是一种简单的黑客, 便于在 Python 代码中简单和直截了当地评估 C 函数, 提高了在 SciPy 中计算能力和功能可用性之间进行更佳权衡的灵活性, 例如 SciPy 的视觉化和现有计算程序。 我们还展示了两个案例 。 在第一个应用程序中, 我们使用 Slib 将一个 Schr\\" 调味方程式解析器的端口写到 Python 的 Python 端口, 并广泛使用文献, 由此产生的脚本比原始版本快150x 。 第二个是工程应用程序, 已经使用加速脚本, 并展示了使用加速脚本的状态。 我们还用 Slib SClib 来评估一套连接的 Schr\" odg- 类似方程式, 用于执行该代码的速检部分。 我们说, 当使用 SClip 和 Matplotlibliblip 来操作和 快速化系统, 我们用 Sral 的精度控制, 我们用 S tral 的缩缩化码 和S 。

0
下载
关闭预览

相关内容

Python计算导论,560页pdf,Introduction to Computing Using Python
专知会员服务
74+阅读 · 2020年5月5日
【新书】Python数据科学食谱(Python Data Science Cookbook)
专知会员服务
117+阅读 · 2020年1月1日
强化学习最新教程,17页pdf
专知会员服务
180+阅读 · 2019年10月11日
【新书】Python编程基础,669页pdf
专知会员服务
195+阅读 · 2019年10月10日
LibRec 精选:AutoML for Contextual Bandits
LibRec智能推荐
7+阅读 · 2019年9月19日
LibRec 精选:近期15篇推荐系统论文
LibRec智能推荐
5+阅读 · 2019年3月5日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
17+阅读 · 2018年12月24日
机器学习线性代数速查
机器学习研究会
19+阅读 · 2018年2月25日
Python机器学习教程资料/代码
机器学习研究会
8+阅读 · 2018年2月22日
LibRec 每周精选:近期推荐系统论文及进展
机器学习研究会
4+阅读 · 2018年2月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
15+阅读 · 2017年11月16日
【推荐】Python机器学习生态圈(Scikit-Learn相关项目)
机器学习研究会
6+阅读 · 2017年8月23日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
The Measure of Intelligence
Arxiv
7+阅读 · 2019年11月5日
Learning to Importance Sample in Primary Sample Space
Arxiv
3+阅读 · 2018年2月24日
VIP会员
相关资讯
LibRec 精选:AutoML for Contextual Bandits
LibRec智能推荐
7+阅读 · 2019年9月19日
LibRec 精选:近期15篇推荐系统论文
LibRec智能推荐
5+阅读 · 2019年3月5日
A Technical Overview of AI & ML in 2018 & Trends for 2019
待字闺中
17+阅读 · 2018年12月24日
机器学习线性代数速查
机器学习研究会
19+阅读 · 2018年2月25日
Python机器学习教程资料/代码
机器学习研究会
8+阅读 · 2018年2月22日
LibRec 每周精选:近期推荐系统论文及进展
机器学习研究会
4+阅读 · 2018年2月5日
【推荐】用Python/OpenCV实现增强现实
机器学习研究会
15+阅读 · 2017年11月16日
【推荐】Python机器学习生态圈(Scikit-Learn相关项目)
机器学习研究会
6+阅读 · 2017年8月23日
Auto-Encoding GAN
CreateAMind
7+阅读 · 2017年8月4日
Top
微信扫码咨询专知VIP会员