Re:Re: re: automatic MatrixForm
- To: mathgroup at christensen.cybernetics.net
- Subject: [mg799] Re:[mg744] Re: [mg698] re: automatic MatrixForm
- From: Allan Hayes <hay at haystack.demon.co.uk>
- Date: Wed, 19 Apr 1995 00:50:36 -0400
On Mon, 10 Apr 1995, Richard Mercer pointed out that MatrixForm
will be used automatically on matrix outputs after entering the
command
$PrePrint = If[MatrixQ[#],MatrixForm[#],#]&
It may be worthwhile to note that for MatrixQ[expr] to give True it
is necessary not only that it be a list of lists of equal length
but also that these latter lists contain no elements that are
themselves lists.
Hence the following behaviour
In[1]:=
$PrePrint = If[MatrixQ[#],MatrixForm[#],#]&;
In[2]:=
{{1,2},{3,{4}}}
Out[2]=
{{1, 2}, {3, {4}}}
But if we use
In[3]:=
$PrePrint = If[TensorRank[#]===2,MatrixForm[#],#]&;
Then
In[4]:=
mat
Out[4]=
1 2
3 {4}
Which you choose depends on what you want, and there are many variation.
It's also useful to note the options available for MatrixForm (the
same as for TableForm).
Allan Hayes
hay at haystack.demon.co.uk