试着用IronPython做线性代数

试着用IronPython做线性代数,python,linear-algebra,ironpython,mathematical-optimization,Python,Linear Algebra,Ironpython,Mathematical Optimization,对于CPython,我会使用numpy.linalg进行线性代数(svd)计算,但numpy不能与IronPython一起工作(我在使用multiarray模块时遇到导入错误)。 IronPython是强制性的,因为我使用的软件带有嵌入式IronPython 我在网上找不到IronPython的函数库。。。有人知道一个很好的库,它对IronPython几乎没有依赖关系,最适合Windows和Linux 实际上,我的目标是从一组点中找到一个中间平面。我在internet上找到了以下代码: def

对于CPython,我会使用numpy.linalg进行线性代数(svd)计算,但numpy不能与IronPython一起工作(我在使用multiarray模块时遇到导入错误)。 IronPython是强制性的,因为我使用的软件带有嵌入式IronPython

我在网上找不到IronPython的函数库。。。有人知道一个很好的库,它对IronPython几乎没有依赖关系,最适合Windows和Linux

实际上,我的目标是从一组点中找到一个中间平面。我在internet上找到了以下代码:

def planeFit(points):
    """
    p, n = planeFit(points)

    Given an array, points, of shape (d,...)
    representing points in d-dimensional space,
    fit an d-dimensional plane to the points.

    Return a point, p, on the plane (the point-cloud centroid),
    and the normal, n.
    """
    import numpy as np
    from numpy.linalg import svd
    points = np.reshape(points, (np.shape(points)[0], -1))  # Collapse trialing dimensions
    assert points.shape[0] <= points.shape[1], "There are only %s points in %s dimensions." % (points.shape[1], points.shape[0])
    ctr = points.mean(axis=1)
    x = points - ctr[:, np.newaxis]
    M = np.dot(x, x.T)  # Could also use np.cov(x) here.
    return ctr, svd(M)[0][:,1]
def平面拟合(点):
"""
p、 n=平面配合(点)
给定形状为(d,…)的数组、点
表示d维空间中的点,
将d维平面拟合到点。
返回平面上的点p(点云质心),
和正常的,n。
"""
将numpy作为np导入
从numpy.linalg导入svd
点=np.重塑(点,(np.形状(点)[0],-1))#折叠试验尺寸
断言点。形状[0]