<br><br><div class="gmail_quote">On Fri, Feb 18, 2011 at 12:50 PM, Neal Becker <span dir="ltr"><<a href="mailto:ndbecker2@gmail.com">ndbecker2@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im">Neal Becker wrote:<br>
<br>
> My translation is:<br>
><br>
>     x1 = rcv[n:n-N:-1]<br>
><br>
>     z = np.dot (P, x1.conj().transpose())<br>
><br>
>     g = z / (_lambda + np.dot (x1, z))<br>
><br>
>     y = np.dot (h, x1.conj().transpose())<br>
><br>
>     e = x[n-N/2] - y<br>
><br>
>     h += np.dot (e, g.conj().transpose())<br>
><br>
>     P = (P - np.dot (g, z.conj().transpose()))/_lambda<br>
><br>
> But it doesn't work.<br>
><br>
> You say z should be a column vector.  I got:<br>
> In [138]: x1.shape<br>
> Out[138]: (64,)<br>
><br>
> In [139]: z.shape<br>
> Out[139]: (64,)<br>
><br>
> Clearly, I did something wrong here.<br>
<br>
</div>I think I've got it.  In numpy, a 'vector' is a row vector.  If I want to turn a<br>
row vector into a column vector, transpose doesn't work.  I need to use newaxis<br>
for that.  So the whole translation is:<br>
<div class="im"><br>
    x1 = rcv[n:n-N:-1]<br>
<br>
</div>    z = np.dot (P, x1.conj()[:,np.newaxis])<br>
<div class="im"><br>
    g = z / (_lambda + np.dot (x1, z))<br>
<br>
</div>    y = np.dot (h, x1.conj()[:,np.newaxis])<br>
<br>
    e = x[n] - y<br>
<div class="im"><br>
    h += np.dot (e, g.conj().transpose())<br>
<br>
    P = (P - np.dot (g, z.conj().transpose()))/_lambda<br>
<br></div></blockquote><div><br><br>Sure, you can implement Matlab's row and column vectors that way.  I would probably stick with true 1D arrays (rather than Nx1 2D arrays), and implement those lines something like this:<br>

<br>x1 = rcv[n:n-N:-1]<br><br>z = np.dot(P, x1.conj())<br><br>g = z / (_lambda + np.dot(x1, z))<br><br>y = np.vdot(x1, h)<br><br>e = x[n] - y<br><br># Note: e is a scalar.<br>h += e * g.conj()<br><br>P = (P - np.outer(g, z.conj()))/_lambda<br>

<br><br>Note the use of vdot(); vdot(a,b) conjugates a and then dots with b.  Also note the use of outer() in the line that updates P.<br><br>Warren<br> <br><br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im">
<br>
</div><div><div></div><div class="h5">_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
</div></div></blockquote></div><br>