MathGroup Archive 1999

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

Search the Archive

RE: Automatic Display in MatrixForm

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19561] RE: Automatic Display in MatrixForm
  • From: Colin Rose <colin at tri.org.au>
  • Date: Wed, 1 Sep 1999 23:06:59 -0400
  • References: <E1168E31432DD211AF990000F806EFD801FB51ED@nems04.nawcad.navy.mil>
  • Sender: owner-wri-mathgroup at wolfram.com

CR pondered:

>If MyFunc[x] returns a matrix, which we want formatted
>as a List (and not in "Fancy Matrix" form), how can we switch
>it off LOCALLY for this function's output only,
>and without converting back to InputForm ?



and Ted Ersek suggested:


>In[1]:=
>$Pre:=(HiddenSymbols`UseMatrixForm=True;#&)
>
>In[2]:=
>MakeBoxes[m_?(Function[t,MatrixQ[Unevaluated[t]] &&
> Flatten[t//.{_Rule->Sequence[],_RuleDelayed->Sequence[]}]=!={},
> HoldAll ]), StandardForm]/;HiddenSymbols`UseMatrixForm :=
>  RowBox[{"(", GridBox[Map[Function[t,MakeBoxes[t,StandardForm],HoldAll],
>          Unevaluated[m],{2}]],")"}]
>
>In[3]:=
>MyFunc[x_]:=(HiddenSymbols`UseMatrixForm=False;3 x)
>
>In[4]:=
>m={{1,2,1},{1,0,1},{0,0,1}}
>MyFunc[m]
>m.m
>
>
>Out[4]=
>  1  2  1
>  1  0  1
>  0  0  1
>
>
>Out[5]=
>  {{3,6,3},{3,0,3},{0,0,3}}
>
>
>Out[6]=
>  3  2  4
>  1  2  2
>  0  0  1




>--------------------
>
>Isn't that delicious.


Indidly :) It's very clever. But it seems a little invasive:  the $Pre
forces an extra evaluation on each and every Input that is undertaken
keeping on setting HiddenSymbols`UseMatrixForm=True.

Is there not a less invasive way, say:

      MyFunc[x] // ListForm

where the addition of ListForm produces the output as
a List, rather than a fancy MatrixForm ?

Cheers and thanks

Colin
 

Colin Rose
tr(I)    -  Theoretical Research Institute
__________________________________________
colin at tri.org.au    http://www.tri.org.au/


 






  • Prev by Date: Re: Asking you how to...
  • Next by Date: Re: Asking you how to...
  • Previous by thread: RE: Automatic Display in MatrixForm
  • Next by thread: Re: Re: Freeing memory in Mathematica