numpy.dot(vector_a, vector_b, out = None) gibt das Skalarprodukt der Vektoren a und b zurück. Es kann 2D-Arrays verarbeiten, betrachtet sie jedoch als Matrix und führt eine Matrixmultiplikation durch. Für N Dimensionen ist es ein Summenprodukt über der letzten Achse von a und der vorletzten von b:
dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])>
Parameter
- vector_a: [array_like] Wenn a komplex ist, wird sein komplexes Konjugat für die Berechnung des Skalarprodukts verwendet. vector_b: [array_like] Wenn b komplex ist, wird sein komplexes Konjugat für die Berechnung des Skalarprodukts verwendet. out: [Array, optional] Ausgabeargument muss C-zusammenhängend sein und sein D-Typ muss der D-Typ sein, der für Punkt (a, b) zurückgegeben würde.
Skalarprodukt der Vektoren a und b. Wenn vector_a und vector_b 1D sind, wird ein Skalar zurückgegeben
NPM Clean Cache Force
Code 1:
Python
# Python Program illustrating> # numpy.dot() method> import> numpy as geek> # Scalars> product> => geek.dot(> 5> ,> 4> )> print> (> 'Dot Product of scalar values : '> , product)> # 1D array> vector_a> => 2> +> 3j> vector_b> => 4> +> 5j> product> => geek.dot(vector_a, vector_b)> print> (> 'Dot Product : '> , product)> |
>
c Array von Strings
>
Ausgabe:
Dot Product of scalar values : 20 Dot Product : (-7+22j)>
How Code1 works ? vector_a = 2 + 3j vector_b = 4 + 5j now dot product = 2(4 + 5j) + 3j(4 +5j) = 8 + 10j + 12j - 15 = -7 + 22j>
Code 2:
Python
Konvertieren Sie int in einen String Java
# Python Program illustrating> # numpy.dot() method> import> numpy as geek> # 1D array> vector_a> => geek.array([[> 1> ,> 4> ], [> 5> ,> 6> ]])> vector_b> => geek.array([[> 2> ,> 4> ], [> 5> ,> 2> ]])> product> => geek.dot(vector_a, vector_b)> print> (> 'Dot Product :
'> , product)> product> => geek.dot(vector_b, vector_a)> print> (> '
Dot Product :
'> , product)> '''> Code 2 : as normal matrix multiplication> '''> |
Java vs. C++
>
>
Ausgabe:
Dot Product : [[22 12] [40 32]] Dot Product : [[22 32] [15 32]]>