[Numpy-discussion] Matlab page on scipy wiki

Travis Oliphant oliphant at ee.byu.edu
Fri Feb 10 14:18:01 CST 2006


Alan G Isaac wrote:

>On Fri, 10 Feb 2006, Stefan van der Walt apparently wrote: 
>  
>
>>In Octave that would be 
>>[1, 0, 1:4, 0, 1] 
>>Using numpy we currently do 
>>concatenate([[1, 0], arange(1,5), [0, 1]]) or 
>>vstack(...) 
>>    
>>
>
>numpy.r_[1,0,range(1,5),0,1]
>  
>

or even faster

numpy.r_[1,0,1:5,0,1]

The whole point of r_ is to allow you to use slice notation to build 
ranges easily.  I wrote it precisely to make it easier to construct 
arrays in a simliar style that Matlab allows. 

-Travis





More information about the Numpy-discussion mailing list