MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Re: Automatic Display in MatrixForm

Colin Rose commented on the MakeBoxes definition that would make
StandardForm display matrices with the equivalent of MatrixForm.  His
comment included:

Two interesting cases are:

(1) Output from Solve will now get displayed as a 'Matrix', which I think is
highly undesirable. For instance, if Solve returns an answer such as

  {{x -> 3}}

then it will now be presented as

  (x -> 3)

which can cause a lot of confusion. I would suggest eliminating this
possibility by adding the exclusion  rule:

   FreeQ[t, Rule] === True

to yield 
   Function[t,  MatrixQ[Unevaluated[t]] && (t =!= {{}} && 
       FreeQ[t, Rule] === True), HoldAll]

(2).  Let:

   lis = { {}, {}, {}, {} ... }

Some functions might generate output like this.  This generates a BEEP when
Mathematica tries to format it as a "Matrix". I can't think of a nice
general way to exclude such cases.


The version below takes care of both cases above.  The exclusion used here
is a little different from the one suggested above.  Here 'MatrixForm'
formatting isn't used on an empty matrix, or a matrix where *every* element
has the head Rule or RuleDelayed.  Other changes can be made as desired.

MakeBoxes[m_?(Function[t,MatrixQ[Unevaluated[t]] && 
 HoldAll ]), StandardForm] :=
  RowBox[{"(", GridBox[Map[Function[t,MakeBoxes[t,StandardForm],HoldAll],

Ted Ersek

For Mathematica tips, tricks see

  • Prev by Date: Re: Re: Numbers problem
  • Next by Date: Experimental Functions in Mathematica 4.0
  • Previous by thread: RE: Automatic Display in MatrixForm
  • Next by thread: RE: Automatic Display in MatrixForm