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

Reply via email to