python - Calculate Euclidean Distance within points in numpy array -


मेरे पास 3D सरणी है

  A = [[x1 y1 z1] [x2 y2 मुझे प्रत्येक अंक के बीच ईक्लिडियन दूरी मिलनी है ताकि मैं  (पंक्ति 0, पंक्ति 1) के बीच केवल 3 दूरी के साथ आउटपुट पाउंगा   

, (पंक्ति 1, पंक्ति 2) और (पंक्ति 0, पंक्ति 2)

मेरे पास कुछ कोड है

    

लेकिन यह मैट्रिक्स फॉर्म में दूरी देगी

  dist = [[0 एबी] [ए 0 सी] [बीसी 0]]   

मुझे परिणाम के रूप में [abc] । चाहिए < P>

आप ऐसा कुछ कर सकते हैं:

  & gt; & gt; & gt; Np & gt; & gt; & gt; Itertools आयात संयोजन से & gt; & gt; & gt; ए = एनपी। अर्रे ([[1, 2, 3], [4, 5, 6], [10, 20, 30]]) & gt; & gt; & gt; [Np.linalg.norm (a-b) a, b में संयोजन (ए, 2)] [5.196152422706632, 33.674916480965472, 28.930952282978865]    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -