Re: Marking pivot elements in a matrix?

• To: mathgroup at smc.vnet.net
• Subject: [mg74938] Re: [mg74930] Marking pivot elements in a matrix?
• From: Carl Woll <carlw at wolfram.com>
• Date: Thu, 12 Apr 2007 04:47:49 -0400 (EDT)
• References: <200704110604.CAA03005@smc.vnet.net>

jackgold at umich.edu wrote:

>Hi folks,
>
>I am writing notes for a class in which matrix manipulations
>is a necessary and frequent task. At present, when I wish to pick an
>entry of the matrix as a "pivot" I simply write "pivot
>on {2, 3}". It would be nice to enclose the {2, 3} entry in a square or
>circle to indicate it is the pivot entry. I am unable to do this. In
>this same vein, I often have need to put a single vertical (horizontal)
>line through the matrix.
>Mathematica provides the means for putting vertical (horizontal)
>lines in a matrix but it allows only the option of putting lines at
>every column (row). I want to be more selective, say one line
>just before the last column. (This is the standard way of indicating
>that the last column is an augmentation to the original coefficient
>matrix).
>
>Is there any reasonably simple way to do this?
>
>
One possibility is to use GridBox and FrameBox as follows:

matrix /: MakeBoxes[ matrix[m_?MatrixQ, gridboxoptions___], fmt_] :=
RowBox[{"(", "\[NoBreak]", GridBox[Map[MakeBoxes[#, fmt] &, m, {2}],
gridboxoptions], "\[NoBreak]", ")"}]

framed /: MakeBoxes[framed[x_, styleboxoptions___], fmt_] :=
StyleBox[FrameBox[MakeBoxes[x, fmt]], styleboxoptions]

Then you can create an augmented matrix using:

m=Array[Subscript[a,##]&,{3,4}];

matrix[m, ColumnLines->{False,False,True}]

You can highlight the {2,3} entry of the augmented matrix using MapAt:

matrix[
MapAt[framed[#,Background->GrayLevel[0.7]]&, m, {2,3}],
ColumnLines->{False,False,True}
]

There are also FrameBox options that you can play with as well as
StyleBox options.

Carl Woll
Wolfram Research

• Prev by Date: Re: Re: Can Maximize return a function
• Next by Date: Re: Beginner--Help on Listing Values
• Previous by thread: Marking pivot elements in a matrix?
• Next by thread: Re: Marking pivot elements in a matrix?