Differences between revisions 1 and 2
Revision 1 as of 2006-05-16 14:13:15
Size: 1412
Editor: ZhangYunfeng
Comment:
Revision 2 as of 2006-05-16 14:15:23
Size: 1462
Editor: ZhangYunfeng
Comment:
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
主页:http://numeric.scipy.org  * 主页:http://numeric.scipy.org
 * 相关模块:["Numeric"], ["Numarray"]

NumPy

建议导入方法

  •    1 import numpy
    

然后就可以在 numpy 名字空间内使用它自带的各个子模块

子模块总揽

NumPy包含的子模块

  • Sub-Package Purpose Comments
    core basic objects all names exported to numpy
    lib additional utilities all names exported to numpy
    linalg basic linear algebra old LinearAlgebra from Numeric
    dft discrete Fourier transforms old FFT from Numeric
    random random number generators old RandomArray from Numeric
    distutils enhanced build and distribution improvements for standard distutils
    testing unit-testing utility functions useful for testing
    f2py automatic wrapping of Fortran code a useful utility needed by SciPy

TableOfContents

基本对象

NumPy 提供了两个基本对象: N-维矩阵对象(ndarray)和通用函数对象(ufunc)。其他的对象都是建立在这两个对象之上的。

注意:矩阵元素的索引从0开始,到n-1结束,这是为了与Python中的其他对象兼容而做

定义2x3整型矩阵,每个元素占有4个字节(32-bit平台)。通过方括号进行元素索引。

  •    1 >>> a = numpy.array([[1,2,3],[4,5,6]])
       2 >>> a
       3 array([[1, 2, 3],
       4        [4, 5, 6]])
       5 >>> a.shape
       6 (2, 3)
       7 >>> a.dtype
       8 dtype('<i4')
       9 >>> a[1,1]
      10 5
    

NumPy (last edited 2009-12-25 07:14:49 by localhost)