源代码位置和向量化数组操作的说明 [英] Source code location and explanation of vectorized array operations

查看:75
本文介绍了源代码位置和向量化数组操作的说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找包含基本矢量化数组操作的NumPy .c文件.例如,当您对诸如a + 5的数组进行标量加法或执行诸如a.sum()的聚合之类的简单操作时,我想知道运行什么代码段.我相信ndarray对象在这里声明.

I am trying to locate the NumPy .c file that contains basic vectorized array operations. For instance, I'd like to know what piece of code runs when you do something simple like a scalar addition to an array like a + 5 or perform an aggregation like a.sum(). I believe the ndarray object gets declared here.

我还想知道是否有任何线性代数库(例如BLAS或LAPACK)与这些基本算术运算有关?代码是否像在C数组上进行for循环一样简单,还是计算机以某种神奇的方式对连续数组进行基本操作而没有for循环?

I'd also like to know if any of the linear algebra libraries like BLAS or LAPACK are involved with these basic arithmetic operations? Is the code as simple as a for-loop iterating over a C array or is there some magical way that computers do basic operations on contiguous arrays without for-loops?

推荐答案

大多数内容都在 numpy/core/src/umath/loops.c.src .这是NumPy用来生成很多非常相似的C函数的模板文件.不涉及BLAS或LAPACK调用.

Most of that stuff is in numpy/core/src/umath/loops.c.src. This is a template file NumPy uses to generate lots and lots of very similar C functions. No BLAS or LAPACK calls are involved.

这篇关于源代码位置和向量化数组操作的说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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