MathGroup Archive 2007

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

Search the Archive

Re: Marking pivot elements in a matrix?

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

jackgold at 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
>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:


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

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

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

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?