Re: [Numpy-discussion] simple vector->matrix question

2011-10-06 Thread Warren Weckesser
On Thu, Oct 6, 2011 at 7:29 AM, Samuel John wrote: > I just learned two things: > > 1. np.newaxis > 2. Array dimension broadcasting rocks more than you think. > > Yup. :) > > The x[:, np.newaxis] might not be the most intuitive solution but it's > great and powerful. > Intuitive would be to h

Re: [Numpy-discussion] simple vector->matrix question

2011-10-06 Thread Samuel John
I just learned two things: 1. np.newaxis 2. Array dimension broadcasting rocks more than you think. The x[:, np.newaxis] might not be the most intuitive solution but it's great and powerful. Intuitive would be to have x.T to transform [0,1,2,4] into [[0],[1],[2],[4]]. Thanks Warren :-) Samuel

Re: [Numpy-discussion] simple vector->matrix question

2011-10-06 Thread Samuel John
import numpy # Say y is y = numpy.array([1,2,3]) Y = numpy.vstack([y,y,y,y]) # Y is array([[1, 2, 3], # [1, 2, 3], # [1, 2, 3], # [1, 2, 3]]) x = numpy.array([[0],[2],[4],[6]]) # a column-vector of your scalars x0, x1... Y - x Hope this is what you meant. cheers, Sa

Re: [Numpy-discussion] simple vector->matrix question

2011-10-06 Thread Warren Weckesser
On Thu, Oct 6, 2011 at 7:08 AM, Neal Becker wrote: > Given a vector y, I want a matrix H whose rows are > > y - x0 > y - x1 > y - x2 > ... > > > where x_i are scalars > > Suggestion? > > In [15]: import numpy as np In [16]: y = np.array([10.0, 20.0, 30.0]) In [17]: x = np.array([0, 1, 2, 4])

[Numpy-discussion] simple vector->matrix question

2011-10-06 Thread Neal Becker
Given a vector y, I want a matrix H whose rows are y - x0 y - x1 y - x2 ... where x_i are scalars Suggestion? ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion