我懷疑這可能不是一個很好的問題,但我已經完全打破了它的牆壁並可以使用一些幫助。將Numpy代碼翻譯成C#
我想實現這個代碼:
http://www.nathanieltroutman.net/content/calculating-minimum-volume-bounding-box
在C#,可以用Python原來的福利。
此進行得很順利,直到我打這個部分:
def calcProjections(points, *vectors):
"""Calculates the projection of points (NxD) onto the vectors
(MxD) and return the projections p which is a matrix sized (N, M)
where N is the number of points and M is the number of vectors.
p[i][j], is the projection of points[i] onto vectors[j] (which is
between 0 and 1)."""
u = np.array(vectors)
# project the points onto the vectors into on fell swoop
d = np.dot(points, u.T)
# this is the dot product of each vector with itself
v2 = np.diag(np.inner(u, u))
p = d/v2
return p
而我只是在努力破譯什麼是真正發生的事情。我不知道作者通過投影到特定的向量或輸出的格式(該死的你打字)意味着什麼。對我來說descprition也太模糊了。
有沒有人有任何建議或解釋這是做什麼?任何幫助不勝感激。
謝謝。
閱讀文檔。 [numpy.dot](http://docs.scipy.org/doc/numpy/reference/generated/numpy.dot.html),[numpy.diag](http://docs.scipy.org/doc/numpy /reference/generated/numpy.diag.html),[numpy.inner](http://docs.scipy.org/doc/numpy/reference/generated/numpy.inner.html)。 – CoryKramer 2014-09-22 15:47:18
_「......我討厭這個部分」_Fuudian滑倒? :) – 2014-09-22 15:48:42
哈哈,可能。關於文件。說實話,這有點讓我失望,尤其是它在處理兩個點陣(點生產?)在一起的數組時,它正在做什麼,但即使如此,這部分代碼的總體目標是做一點點我不清楚。 – djcmm476 2014-09-22 15:50:42