I suppose tmp was not initialised when mapped so the jmf could actually return a leading shape of 0 instead of 10 or 19.
Or you can fix the shape you wanted into the header using iad and memw as what was done by the map verb. But I guess the content would still be rubbish. On Thu, 18 Jun 2009, Matthew Brand wrote: > But because $ tmp is incorrect I have to write special code to deal > with the cells that do not contain sensible data. Many verb that run > across the array*./\"1 etc... will not execute correctly because of > the extra unwanted cells. > > It would be nice to have a function that one can enter in the intended > dimensions and type and get back the number of bytes that need to be > allocated. > > e.g. if we could write: > nbytes =. exactsize_jmf_ 10 10;JFL > createjmf_jmf_ '/tmp/tmp';nbytes > (JFL;10) map_jmf_ 'tmp';'/tmp/tmp' > $ tmp > 10 10 NB. guaranteed shape if hypothetical "exactsize_jmf_" used. > > 2009/6/18 bill lam <[email protected]>: > > On Tue, 16 Jun 2009, Matthew Brand wrote: > >> What is the formula for calculating the number of bytes to > >> createjmf_jmf_ a file for mapping for a pre-known sized array of a > >> given type? > >> > >> require 'jmf' > >> NX =. 10 > >> NY =. 10 > >> nbytes=: 7!:5 <'tmp' [ tmp=. 1p1 $~ NX,NY NB. my estimate of > >> number of bytes for 10x10 array of floats > >> createjmf_jmf_ '/tmp/tmp';nbytes > >> (JFL;NX) map_jmf_ 'tmp';'/tmp/tmp' > >> ](NX,NY) NB. the shape I want > >> 10 10 > >> ]$ tmp NB. not the shape I wanted > >> 19 10 > > > > jmf gives an over-estimate of the leading shape (19) because storage > > for array are not closely packed. But I guess that should not be a > > problem because that map file actually fit the array you wanted to > > map. > > > > -- > > regards, > > ==================================================== > > GPG key 1024D/4434BAB3 2008-08-24 > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- regards, ==================================================== GPG key 1024D/4434BAB3 2008-08-24 gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
