Thanx much Henry. I see your point. I notice that coercing a list (a rank 1 data object) into an Nx1 "rank 2" data object implies that J considers it rank 2 since #$ will evidently return '2' whereas the data would seem to actually be a rank 1 tensor (a column vector) and similarly a 1xN row vector is also rank 2 to J and this seems a little misaligned with how tensor algebra would view the situation. (Not that I'm really complaining as I think I am hooked on J already).
On Sun, Apr 16, 2017 at 3:15 PM, Henry Rich <[email protected]> wrote: > Focusing on the final question: > > Why does J not treat a column of numbers as a N by 1 'matrix' ie a > vector rather than a list? > > If you had asked 'Why does readtable not...' I would have answered that it > might be a bug in readtable, or that you should have some intermediate verb > that would guarantee that you get a table result: > > readrank2 =: ,.^:(2 > #@$) @ readtable NB. untested > > Following Chris's explanation of where the trouble comes from (that ". > sometimes produces a list, sometimes an atom), another way to force the > behavior you want would be to replace ". by (,@".) which would always > produce a list. > > > As for 'Why does J not...', how would J know that this list should be > treated as a one-column table, rather than a one-row table, a one-row > brick, etc.? > > Henry Rich > > > > > > On 4/16/2017 2:26 PM, Michael Goodrich wrote: > >> All, >> >> In using 'readtable' as defined in the primer I find the following >> situation: >> >> Reading in a square matrix from a file with each row of numbers on a line >> I >> always get the 'correct' answer when asking about the shape of the read in >> data, EXCEPT when the data has only one value per line ie is a vector or >> de-generate matrix if you will. In that case the shape comes back with a >> single number say N whereas I was expecting it to say 'N 1' and indeed the >> read in data is not available for linear algebra operations whereas data >> with more that one column is without further ado. >> >> Why does J not treat a column of numbers as a N by 1 'matrix' ie a vector >> rather than a list? >> >> (Pardon me if I sound like I am whining ;-) >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Dominus enim Iesus Ecclesiae Suae et, -Michael "Let your religion be less of a theory and more of a love affair." - G.K. Chesterton ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
