Wie bekomme ich mit numpy (Phython) ein dyadisches Produkt hin?
Ich möchte für eine typische regelungstechnische Anwendung einen Spaltenvektor mit einem Zeilenvektor multiplizieren, ohne dabei ein Skalarprodukt zu bilden. Ich sehe bisher keine Möglichkeit dazu
1 Antwort
was du suchst ist np.outer()
import numpy as np
spaltenvec = np.array([1,2,3])
zeilenvec = np.array([4,5,6])
matrix = np.outer(zeilenvec, spaltenvec)
@Herrdings
A= np.array( ((0,1,0,0), (0, -26,-5,0.75), (0,0,0,1), (0,90,47.6854,-2.5)) ) # 4x4-Matrix
B= np.array ( ((1), (5), (-8), (2)) ) # 4x1 Spaltenvektor
produkt= np.dot(A,B)
Explowox
14.08.2019, 15:15
@Herrdings
Wenn ich deinen Code ausführe und mir produkt printe kommt bei mir [ 5. -88.5 2. 63.5168] raus. Das willst du doch?
okay danke, das funktioniert schon mal. Nun möchte ich aber noch, dass er eine 4x4-Matrix mit einem 4 Komponenten Spaltenvektor multipliziert und dabei wieder ein Spaltenvektor herauskommt.... im Moment ergibt das aber eine 4x4-Matrix