<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>BlackBox : Math DSL Part Deux - Elementary Row Operations (EROs)</title>
    <link>http://www.warneronstine.com/blog/articles/2007/11/26/math-dsl-part-deux-elementary-row-operations-eros</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Where technology and art disappear</description>
    <item>
      <title>Math DSL Part Deux - Elementary Row Operations (EROs)</title>
      <description>&lt;p&gt;After sending out my query to the groovy user list I got back some ideas (no offense to Yann, just something I need to tackle on my own, so I didn&amp;#8217;t look at your solution). What I ended up doing was two-fold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new MetaClass using ExpandoMetaClass &lt;/li&gt;
&lt;li&gt;Define a new class that understood what row and matrix it was going to operate on (so it can have its own operator overloading)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Yes it was a little bit of extra work, but worth it. I also implemented my &lt;code&gt;or&lt;/code&gt; operator overloading so that I can specify augmented matrices in three formats:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;A|I&lt;/code&gt; for the identity matrix (only works on square matrices)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;A|0&lt;/code&gt; for the zero column, used for solving the set of linear equations&lt;/li&gt;
&lt;li&gt;&lt;code&gt;A|b&lt;/code&gt; for a vector column, also used for solving the set of linear equations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As always it helps to learn from others&amp;#8217; mistakes (and oddities) so I&amp;#8217;ll share mine along the road:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When dealing with EMC (ExpandoMetaClass) watch out for the use of the &lt;code&gt;this&lt;/code&gt; keyword&lt;/li&gt;
&lt;li&gt;Closure delegates don&amp;#8217;t always act the way you would hope when extending &lt;code&gt;GroovyObjectSupport&lt;/code&gt; (at least I couldn&amp;#8217;t get it to work right which is one reason why I switched to EMC)&lt;/li&gt;
&lt;li&gt;Overriding the &lt;code&gt;or&lt;/code&gt; operator works fine until you get to an object that has overridden the &lt;code&gt;equals&lt;/code&gt; operator. In this case Groovy kept trying to find out if my &lt;code&gt;Matrix&lt;/code&gt; was equal to my &lt;code&gt;MatrixColumn&lt;/code&gt;. Once I figured this out I just returned false if the &lt;code&gt;MatrixColumn&lt;/code&gt; was being compared against a &lt;code&gt;Matrix&lt;/code&gt; then it worked as expected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next part I want to add is the ability to track the EROs through Elementary Matrices. These are matrices that start out as 1s along the diagonal and they get the same EROs applied to them (this will be useful further down the line for other operations).&lt;/p&gt;</description>
      <pubDate>Mon, 26 Nov 2007 11:59:24 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:57fad73d-f7fd-481b-8474-f518f4e92dd9</guid>
      <author>Warner Onstine</author>
      <link>http://www.warneronstine.com/blog/articles/2007/11/26/math-dsl-part-deux-elementary-row-operations-eros</link>
      <category>programming</category>
      <category>linear_algebra</category>
      <category>math</category>
      <category>matrix</category>
      <category>groovy</category>
      <category>dsl</category>
      <trackback:ping>http://www.warneronstine.com/blog/articles/trackback/306</trackback:ping>
    </item>
  </channel>
</rss>
