MathGroup Archive 2002

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

Search the Archive

RE: Re: Seemingly simple gridbox question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37562] RE: [mg37536] Re: Seemingly simple gridbox question
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Tue, 5 Nov 2002 04:59:51 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: Mike [mailto:mikeh1980 at optusnet.com.au]
To: mathgroup at smc.vnet.net
>Sent: Monday, November 04, 2002 8:44 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg37562] [mg37536] Re: Seemingly simple gridbox question
>
>
>On 3/11/02 9:25 AM, "Mike" <mikeh1980 at optusnet.com.au> wrote:
>
>> I have a 3x3 gridbox and I would like to enclose a 2x2 block 
>within in
>> parenthesis to indicate to a reader that I am operating only 
>on that part of
>> the matrix (gridbox).
>> 
>> I can only seem to get parethesis added to individual 
>elements. Any ideas?
>> 
>> Thanks
>> 
>> Mike
>
>Actually it was simple:
>
>
>Cell[TextData[Cell[BoxData[
>    RowBox[{"(", GridBox[{
>          {
>            RowBox[{"(", GridBox[{
>                  {"0", "0"},
>                  {"0", "0"}
>                  }], ")"}], GridBox[{
>                {"0"},
>                {"0"}
>                }]},
>          {GridBox[{
>                {"0", "0"}
>                }], "0"}
>          }], ")"}]]]], "Text"]
>
>Mike
>
>

As you found out by yourself, it rests to note, that there are perhaps more
attractive ways to highlight a block of a matrix:

In[85]:= m = Partition[Range[9], 3]
Out[85]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

In[86]:=
s[p_, {{l1_, l2_}, {u1_, u2_}}] := And @@ Thread[{l2, l1} <= p <= {u2, u1}]

In[87]:= blockHigh = {{2, 2}, {3, 3}};

In[88]:=
DisplayForm[
  GridBox[MapIndexed[
      StyleBox[ToString[#1], 
          If[s[#2, blockHigh], FontColor -> Hue[0], 
            Unevaluated[Sequence[]]]] &, m, {2}]]]

...or if you like

In[89]:= blockHigh = {{2, 1}, {3, 2}};
In[90]:=
MatrixForm[
  MapIndexed[
    DisplayForm[
        StyleBox[ToString[#1], 
          If[s[#2, blockHigh], Unevaluated[Sequence[]], 
            FontColor -> GrayLevel[.5]], FontWeight -> "Bold"]] &, m, {2}]]

--
Hartmut Wolf



  • Prev by Date: Re: making a block diagonal matrix
  • Next by Date: AW: making a block diagonal matrix
  • Previous by thread: Re: Seemingly simple gridbox question
  • Next by thread: RE: RE: Re: Seemingly simple gridbox question