Are numpy's basic operations vectorized, i.e. do they use SIMD operations?

后端 未结 2 1286
说谎
说谎 2020-11-30 07:36

I am doing some performance analysis, and i wonder, whether numpy vectorizes its standard array operations, when the datatype is known (double).



        
2条回答
  •  鱼传尺愫
    2020-11-30 08:24

    Take a look at basic example

    import numpy as np
    
    x = np.array([1, 2, 3], np.int32)
    print (type(x))
    y = np.array([6, 7, 8], np.int32)
    print (type(y))
    

    Now we are adding up these two arrays

    z=x+y
    print (z)
    print (type(z))
    

    As a result we have

    
    
    [ 7  9 11]
    
    

    Vectorised,yes they are.But the term vector has different meaning in mathematics and physics,and we are using arrays as mathematical abstraction.

提交回复
热议问题