[Numpy-discussion] how to create a matrix based on a vector?

frank wang f.yw@hotmail....
Mon Dec 8 12:40:01 CST 2008


I got a lof of help from the experts in this forum. I resitsted to send a thank you reply for fearing spaming the forum. This time I really want to let the people know that I am really appreciate the great help I got. 
 
Please let me know if a simple thank you message is not appropriate in this forum.
 
Numpy makes Pyhton a great tools for processing signal.
 
Thank you very much.
 
Frank > Date: Mon, 8 Dec 2008 11:30:31 -0600> From: robert.kern@gmail.com> To: numpy-discussion@scipy.org> Subject: Re: [Numpy-discussion] how to create a matrix based on a vector?> > On Mon, Dec 8, 2008 at 11:27, frank wang <f.yw@hotmail.com> wrote:> > Hi,> >> > I want to create a matrix based on a vector. It is difficult to describe the> > issue for me in english. Here is an example.> >> > Suppose I have an array([3, 6, 8, 12]), I want to create a range based on> > each element. In this exampe, let us say want to create 4 number with step> > 2, so I will have> >> > [3, 6, 8, 12> > 5, 8, 10,14> > 7, 10,12,16> > 9, 12,14,18]> >> > It is a 4 by 4 maxtric in this example. My original array is quite large.> > but the range I want to create around the number is not big, it is about 30.> >> > Does anyone know how to do this efficiently?> > In [1]: from numpy import *> > In [2]: a = array([3, 6, 8, 12])> > In [4]: b = arange(0, 4*2, 2)[:,newaxis]> > In [5]: a+b> Out[5]:> array([[ 3, 6, 8, 12],> [ 5, 8, 10, 14],> [ 7, 10, 12, 16],> [ 9, 12, 14, 18]])> > -- > Robert Kern> > "I have come to believe that the whole world is an enigma, a harmless> enigma that is made terrible by our own mad attempt to interpret it as> though it had an underlying truth."> -- Umberto Eco> _______________________________________________> Numpy-discussion mailing list> Numpy-discussion@scipy.org> http://projects.scipy.org/mailman/listinfo/numpy-discussion
_________________________________________________________________
Send e-mail faster without improving your typing skills.
http://windowslive.com/Explore/hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_speed_122008
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20081208/e38b4f3e/attachment.html 


More information about the Numpy-discussion mailing list