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

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

问题描述

我想使用比奥–萨瓦特定律<,我想使用1000x1000x1000矩阵.在使用MATLAB之前,但现在我想使用Python. Python比MATLAB慢吗?如何使Python更快?

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

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

解决方案

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

http://wiki.scipy.org/PerformancePython

引言

使用NumPy,Pyrex,Psyco,Fortran(77和90)和C ++进行编织求解拉普拉斯方程的比较.

它还与MATLAB进行了比较,似乎显示出与使用Python和 NumPy 相似的速度. /p>

当然,这只是一个具体示例,您的应用程序可能允许更好或更差的性能.在两者上运行相同的测试并进行比较没有什么害处.

您还可以使用优化的库(例如 ATLAS )编译NumPy,该库提供了一些 BLAS / http://www.scipy.org/Installing_SciPy/Windows

该链接提供了Windows平台下所需内容的更多详细信息.

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

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

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

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

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?

EDIT: 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.

EDIT2: 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

From the introduction,

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

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.

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.

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

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

EDIT:

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++.

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天全站免登陆