Wednesday, January 25, 2012

Some take delight ...

Some take delight in the carriage a-rollin', others take delight in fishing and boating, I take delight in the order of the matrices, summation, subtraction and the describing the algorithm of production; Musha rig um du rum da.

So yes, I take delight in describing how to perform the product of two matrices to a computer. Why? Who knows. Maybe there was some method to the three-pack-a-day cigarette smoking habit my mother dutifully maintained while I quickened (and quite likely, coughed) in the womb. Perchance it was influenced by my father's dramatic discovery that he could fix the spray nozzle of the garden hose with a wedge of scrap 2x4. Perhaps it was all the time I spent, late at night with a flash light under the sheets, reading the exploits of he Hardy Boys (which I have since re-read). Perhaps it is none of these things, but the whim of chance that has provided me a natural curiosity for the nerdy. It's not as though the calculation of the product of two matrices is likely to establish me as a contender for any sort of Nobel prize, but there is a distinct pleasure in being able to think through, solve, and describe to a computer, some problem, and it happens that, of late, I have been thinking about algebra, and in particular matrices, their operations and properties.

It's just plain fun. In any case, here it is:

1. given an mxn matrix (call it A), and
2. given an nxp matrix (call it B)
3. produce a mxp matrix (call it C)

for i in 0 .. m begin
   for j in 0 .. p begin
      Ci,j = 0
      for k in 0 .. n begin
         Ci,j = Ci,j + Ai,k x Bk,j
      end
   end
end

It took me the greater part of a day to get that right. That may not sound like much, but it is, though in defense of my capabilities, I was working on it but intermittently.

It's a lot more fun than it sounds.

Next: the determinant. I understand what needs to be done ... now to do it.