有了CPython我会用numpy.linalg公司用于线性代数(svd)计算,但numpy不适用于IronPython(我在multiarray模块中遇到导入错误)。 IronPython是必需的,因为我使用的是带有嵌入式IronPython的软件。你知道吗
我在网上找不到IronPython的函数库。。。有人知道一个很好的库,它对IronPython的依赖性很小,最适合Windows和Linux??你知道吗
实际上,我的目标是从一组点中找到一个中间平面。我在网上找到了这个代码:
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]
目前没有回答
相关问题 更多 >
编程相关推荐