From: Travis O. <oli...@ee...> - 2006-06-23 17:11:50
|
Alan G Isaac wrote: >On Fri, 23 Jun 2006, Keith Goodman apparently wrote: > > >>my x is a Nx1 matrix. I can't get it to work with matrices. >> >> > >Hmm. One would think that diag() would accept a flatiter >object, but it does not. Shouldn't it?? > > It doesn't? try: a = rand(3,4) diag(a.flat).shape which prints (12,12) for me. Also: >>> a = ones((2,3)) >>> diag(a.flat) array([[1, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 1]]) |