MATLAB 比 Python 快吗? [英] Is MATLAB faster than Python?

查看:26
本文介绍了MATLAB 比 Python 快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Biot–Savart 定律计算某些导体的磁场 并且我想使用 1000x1000x1000 矩阵.之前用MATLAB,现在想用Python.Python 比 MATLAB 慢吗?如何让 Python 运行得更快?

I want to compute magnetic fields of some conductors using the Biot–Savart law and I want to use a 1000x1000x1000 matrix. Before I use MATLAB, but now I want to use Python. Is Python slower than MATLAB ? How can I make Python faster?

也许最好的方法是用 C/C++ 计算大数组,然后将它们传输到 Python.我想用 VPython 进行可视化.

Maybe the best way is to compute the big array with C/C++ and then transfering them to Python. I want to visualise then with VPython.

在我的情况下哪个更好:C 还是 C++?

Which is better in my case: C or C++?

推荐答案

您可能会在此链接底部找到一些有用的结果

You might find some useful results at the bottom of this link

http://wiki.scipy.org/PerformancePython

来自介绍,

weave 与 NumPy、Pyrex、Psyco、Fortran(77 和 90)和 C++ 在求解拉普拉斯方程方面的比较.

A comparison of weave with NumPy, Pyrex, Psyco, Fortran (77 and 90) and C++ for solving Laplace's equation.

它还比较了 MATLAB,似乎显示出与使用 Python 和 NumPy 时相似的速度.

It also compares MATLAB and seems to show similar speeds to when using Python and NumPy.

当然这只是一个特定的例子,您的应用程序可能允许更好或更差的性能.对两者运行相同的测试并进行比较没有坏处.

Of course this is only a specific example, your application might be allow better or worse performance. There is no harm in running the same test on both and comparing.

您还可以使用优化的库编译 NumPy,例如 ATLAS,它提供了一些BLAS/LAPACK 例程.这些应该具有与 MATLAB 相当的速度.

You can also compile NumPy with optimized libraries such as ATLAS which provides some BLAS/LAPACK routines. These should be of comparable speed to MATLAB.

我不确定 NumPy 下载是否已经针对它构建,但我认为如果您编译 NumPy,ATLAS 会将库调整到您的系统,

I'm not sure if the NumPy downloads are already built against it, but I think ATLAS will tune libraries to your system if you compile NumPy,

http://www.scipy.org/Installing_SciPy/Windows

该链接包含有关 Windows 平台下所需内容的更多详细信息.

The link has more details on what is required under the Windows platform.

如果您想找出性能更好的 C 或 C++,可能值得提出一个新问题.虽然从上面的链接 C++ 具有最佳性能.其他解决方案也非常接近,即 Pyrex、Python/Fortran(使用 f2py)和内联 C++.

If you want to find out what performs better, C or C++, it might be worth asking a new question. Although from the link above C++ has best performance. Other solutions are quite close too i.e. Pyrex, Python/Fortran (using f2py) and inline C++.

我在 C++ 下做过的唯一矩阵代数是使用 MTL 并实现扩展卡尔曼滤波器.不过,我想,本质上这取决于您使用 LAPACK/BLAS 的库以及它的优化程度.

The only matrix algebra under C++ I have ever done was using MTL and implementing an Extended Kalman Filter. I guess, though, in essence it depends on the libraries you are using LAPACK/BLAS and how well optimised it is.

此链接包含多种语言的面向对象的数值包列表.

This link has a list of object-oriented numerical packages for many languages.

http://www.oonumerics.org/oon/

这篇关于MATLAB 比 Python 快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆