why not using something like numpy.repeat? In [18]: B = numpy.random.rand(4,3) In [19]: A = numpy.repeat(B[:,:,numpy.newaxis],2,axis=2) In [20]: B.shape Out[20]: (4, 3) In [21]: A.shape Out[21]: (4, 3, 2) In [22]: numpy.all(A[:,:,0] == A[:,:,1]) Out[22]: True
hth, L. On Fri, Apr 25, 2008 at 12:09 PM, Matthieu Brucher < [EMAIL PROTECTED]> wrote: > > > 2008/4/25, tournesol <[EMAIL PROTECTED]>: >> >> Hi All. >> >> >> I just want to conver Fortran 77 source to >> Python. >> >> Here is my F77 source. >> >> DIMENSION A(25,60,13),B(25,60,13) >> >> open(15,file='data.dat') >> DO 60 K=1,2 >> READ(15,1602) ((B(I,J),J=1,60),I=1,25) >> 60 CONTINUE >> 1602 FORMAT(15I4) >> >> DO 63 K=1,10 >> DO 62 I=1,25 >> DO 62 J=1,60 >> A(I,J,K)=B(I,J) >> 62 CONTINUE >> 63 CONTINUE >> END >> >> Q1: Fortran-contiguous is ARRAY(row,colum,depth). >> How about the Python-contiguous ? array(depth,row,colum) ? > > > > Default is C-contiguous, but you can you Fortran contiguous arrays. > > > Q2: How can I insert 1D to a 2D array and make it to >> 3D array. ex:) B:25x60 ==> A: 10X25X60 >> > > I don't understand what you want to do, but broadcasting allows copying > several instances of an array into another one. > > Matthieu > -- > French PhD student > Website : http://matthieu-brucher.developpez.com/ > Blogs : http://matt.eifelle.com and http://blog.developpez.com/?blog=92 > LinkedIn : http://www.linkedin.com/in/matthieubrucher > _______________________________________________ > Numpy-discussion mailing list > [email protected] > http://projects.scipy.org/mailman/listinfo/numpy-discussion > > -- Lorenzo Bolla [EMAIL PROTECTED] http://lorenzobolla.emurse.com/
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
