[Numpy-discussion] newbie doubt about dot()

Alan G Isaac aisaac@american....
Wed Apr 2 00:58:36 CDT 2008


On Tue, 1 Apr 2008, harryos apparently wrote:
> i need to calculate 
> wk=uk o (L-Psi)
> where 
> uk=a vector of size (1 X N^2)
> o =scalar product 
> l,Psi=vectors of (N^2 X 1)
> i have an ndarray U of shape(M X N^2)where uk is one of the rows , and 
> L of shape (M X N^2) where l.transpose() is one of the rows, 


Your explanation is not fully clear to me,
but perhaps the following will help.

#dummy values
rows = 2
cols = 3*3
U = numpy.ones((rows,cols)) + [[0],[1]]
L = numpy.random.random((rows,cols)) - 0.5
Psi = numpy.ones((cols,1))

#computation
numpy.dot(U,L.transpose() - Psi)

hth,
Alan Isaac





More information about the Numpy-discussion mailing list