Ted Petrou
Ted Petrou

Reputation: 62037

Source code location and explanation of vectorized array operations

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.

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?

Upvotes: 3

Views: 165

Answers (1)

user2357112
user2357112

Reputation: 282104

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.

Upvotes: 3

Related Questions