[Numpy-discussion] simple vector->matrix question
Samuel John
scipy at samueljohn.de
Thu Oct 6 08:20:32 EDT 2011
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,
Samuel
On 06.10.2011, at 14:08, 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
More information about the NumPy-Discussion
mailing list