MathGroup Archive 1999

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

Search the Archive

Re: Automatic Display in MatrixForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19296] Re: Automatic Display in MatrixForm
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Sat, 14 Aug 1999 01:45:19 -0400
  • References: <7p00rp$76g@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Colin Rose <colin at tri.org.au> wrote in message
news:7p00rp$76g at smc.vnet.net...
> Ted Ersek wrote:
>
> > Dave Withoff's recommended solution is given below, and I know
> > of no problems with it.
-- SNIP--
> Being a good citizen, I realise that some people may not like it,
> so I want to offer a way to switch it off ... In this regard,
>
>        Clear[MakeBoxes]
>
> works nicely, but is it too general ?
> Or is there a more specific way to switch the above off,
> without altering other MakeBoxes[] code that may have
> been introduced elsewhere by the user ??
>
> Cheers
>
>
> Colin
>
> Colin Rose
> tr(I)    -  Theoretical Research Institute
> __________________________________________
> colin at tri.org.au    http://www.tri.org.au/
>

Colin, here's a simple way. Something more secure would really be needed.

System`MakeMatrix::Usage =
    "For an expression m , with MatrixQ[m]->True; if MakeMatrix->True, m is
\
formatted as a two-dimensional matrix; otherwise it is left unchanged. The \
initial value of MakeMatrix is True.";

MakeMatrix = True;

MakeBoxes[m_?
(Function[t, MatrixQ[Unevaluated[t]] && (t =!= {{}}), HoldAll]),
StandardForm
] /; MakeMatrix :=
RowBox[{"(",
GridBox[
Map[Function[t, MakeBoxes[t, StandardForm], HoldAll],
Unevaluated[m], {2}
] ],
")"}]

a = b;

MakeMatrix = True;

HoldForm[3*{{a, 1 + 1}, {1, 1}}]

\!\(\*
  TagBox[
    RowBox[{"3", " ",
      RowBox[{"(", GridBox[{
            {"a", \(1 + 1\)},
            {"1", "1"}
            }], ")"}]}],
    HoldForm]\)

MakeMatrix = False;

HoldForm[3*{{a, 1 + 1}, {1, 1}}]

3 {{a, 1 + 1}, {1, 1}}


Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565






  • Prev by Date: Re: Simple? 3D Plotting Problems
  • Next by Date: precision of floating-point-numbers
  • Previous by thread: Re: Automatic Display in MatrixForm
  • Next by thread: Re: Automatic Display in MatrixForm