[SciPy-user] Question about trick index functions.

Travis Oliphant oliphant.travis at ieee.org
Thu Jan 5 21:05:53 CST 2006

Hugo Gamboa wrote:

>So what is the difference between r_ and c_ ?
c_ is deprecated (it's there only for compatibility) :-)

For 1-d arrays there was never any difference.

For 2-d arrays c_ and r_ stacked along different dimensions.

Now, the r_ constructor can stack along any dimension by using a string 
integer as the last element, but note this has the same limitation as 
concatenate:  the arrays stacked together must actually have the 
dimension to stack along....

Compare the output of

a = arange(6).reshape(2,3)




c_[a,a]  # not recommended for use anymore...

The real use of r_[] is to quickly concatenate arrays together to build 
up complicated arrays.  It was developed when I was using SciPy to teach 
a signal processing course and the student lab-manuals had Matlab 
exercises where they used matlab to build up compilcated arrays quickly 
using bracket notation:


More information about the SciPy-user mailing list