numpy中的等效函数

时间:2014-01-21 08:52:19

标签: python c numpy

我正在使用numpy进行c代码转换为python。

什么是以下matlab函数的numpy等价物?

1. mxGetNumberOfDimensions

2. mxIsDouble

3. mxGetM

4. mxCreateDoubleMatrix

5. mxGetPr

6. lookupspline

1 个答案:

答案 0 :(得分:2)

假设a是一个ndarray对象:

a = np.array([1.0, 2.0, 3.0])
  1. mxGetNumberOfDimensions:a.ndim

  2. mxIsDouble:a.dtype == float

  3. mxGetM:a.shape[0]

  4. mxCreateDoubleMatrix:np.zeros(...)

  5. mxGetPr:a.dataa.ctypes.data

  6. lookupspline:抱歉,我不知道这是什么,scipy.interpolate中有一些样条关联函数。

相关问题