<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/lib/exe/css.php?s=feed" type="text/css"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Ryan Fox</title>
    <subtitle></subtitle>
    <link rel="alternate" type="text/html" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/"/>
    <id>http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/</id>
    <updated>2012-05-16T12:49:44-04:00</updated>
    <generator>FeedCreator 1.7.2-ppt DokuWiki</generator>
<link rel="self" type="application/atom+xml" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/feed.php" />
    <entry>
        <title>perltex_matrix_manipulation_macros - created</title>
        <link rel="alternate" type="text/html" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=perltex_matrix_manipulation_macros&amp;rev=1278965150&amp;do=diff"/>
        <published>2010-07-12T16:05:50-04:00</published>
        <updated>2010-07-12T16:05:50-04:00</updated>
        <id>http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=perltex_matrix_manipulation_macros&amp;rev=1278965150&amp;do=diff</id>
        <author>
            <name>Ryan Fox</name>
        </author>
        <summary>&lt;pre&gt;
@@ -1 +1,166 @@
+ ===== How to Use =====
+ In Ubuntu, PerlTeX is available in the texlive-latex-extra package.
+   sudo apt-get install texlive-latex-extra
  
+ To compile the document:  
+   perltex --latex=pdflatex matrix_test.tex
+ 
+ ===== Code =====
+ &amp;lt;code latex&amp;gt;
+ \documentclass[12pt]{article}
+ \usepackage[utf8]{inputenc}
+ \usepackage{parskip}
+ \usepackage{url}
+ \usepackage{verbatim}
+ \usepackage{graphicx}
+ \usepackage{amsmath}
+ \usepackage{perltex}
+ 
+ \title{Document Title}
+ \author{Ryan Fox}
+ \date{\today}
+ 
+ \perlnewcommand{\defmatrix}[2]
+ {
+ 	sub trim
+ 	{
+ 		my $str = shift;
+ 		$str =~ s/^\s+|\s+$//g;
+ 		return $str;
+ 	}
+ 
+ 	use Math::Matrix;
+ 	use Math::Trig;
+ 	
+ 	my ($name, $text) = @_;	
+ 	my @matrix;
+ 
+ 	for(split /\\\\/, $text)
+ 	{
+ 		if(trim($_) ne &amp;quot;&amp;quot;)
+ 		{
+ 			my @split;
+ 			for(map {trim $_} split /&amp;amp;/)
+ 			{
+ 				my $tmp = $1 if $_ =~ s/\\//g;
+ 				my $e = eval $_ or eval $tmp or $_;
+ 				push @split, $e;
+ 			}
+ 			push @matrix, \@split;
+ 		}
+ 	}
+     $global{$name} = new Math::Matrix(@matrix);
+ 	return &amp;quot;&amp;quot;;
+ }
+ 
+ \perlnewcommand{\printmatrix}[1]
+ {
+ 	my $name = $_[0];
+ 	my @matrix = @{$global{$name}};
+ 	my $text = &amp;quot;\\begin{bmatrix}&amp;quot;;
+ 	for my $r (@matrix)
+ 	{
+ 		my @row = @{$r};
+ 		for(my $i = 0; $i &amp;lt; @row-1; ++$i)
+ 		{
+ 			$text .= &amp;quot;$row[$i] &amp;amp; &amp;quot;;
+ 		}
+ 		$text .= &amp;quot;$row[$#row] \\\\&amp;quot;;
+ 	}
+ 	$text .= &amp;quot;\\end{bmatrix}&amp;quot;;
+ 	return $text;
+ }
+ 
+ \perlnewcommand{\invmatrix}[2]
+ {
+ 	my $name = $_[0];
+ 	my $newname = $_[1];
+ 	my $matrix = $global{$name};
+ 	$global{$newname} = $matrix-&amp;gt;invert;
+ 	return &amp;quot;&amp;quot;;
+ }
+ 
+ \perlnewcommand{\solvematrices}[3]
+ {
+ 	my $result = $_[2];
+ 	my $matrix1 = $global{$_[0]};
+ 	my $matrix2 = $global{$_[1]};
+ 	$global{$result} = $matrix1-&amp;gt;concat($matrix2)-&amp;gt;solve;
+ 	return &amp;quot;&amp;quot;;
+ }
+ 
+ \perlnewcommand{\multmatrices}[3]
+ {
+ 	my $result = $_[2];
+ 	my $matrix1 = $global{$_[0]};
+ 	my $matrix2 = $global{$_[1]};
+ 	if(ref $matrix2)
+ 	{
+ 		$global{$result} = $matrix1-&amp;gt;multiply($matrix2);
+ 	}
+ 	else
+ 	{
+ 		$global{$result} = $matrix1-&amp;gt;multiply_scalar($_[1]);
+ 	}
+ 	return &amp;quot;&amp;quot;;
+ }
+ 
+ \perlnewcommand{\addmatrices}[3]
+ {
+ 	my $result = $_[2];
+ 	my $matrix1 = $global{$_[0]};
+ 	my $matrix2 = $global{$_[1]};
+ 	if(ref $matrix2)
+ 	{
+ 		$global{$result} = $matrix1-&amp;gt;add($matrix2);
+ 	}
+ 	else
+ 	{
+ 		my ($m,$n) = $matrix1-&amp;gt;size;
+ 		my @vals;
+ 		for(1..$m)
+ 		{
+ 			my @v;
+ 			for(1..$n)
+ 			{
+ 				push @v, $_[1];
+ 			}
+ 			push @vals,\@v;
+ 		}
+ 		my $tmp = new Math::Matrix(@vals);
+ 		$global{$result} = $matrix1-&amp;gt;add($tmp);
+ 	}
+ 	return &amp;quot;&amp;quot;;
+ }
+ 
+ \perlnewcommand{\dumper}[1]
+ {
+ 	use Data::Dumper;
+ 	return &amp;quot;\\begin{verbatim}&amp;quot;.Dumper($global{$_[0]}).&amp;quot;\\end{verbatim}&amp;quot;;
+ }
+ 
+ \begin{document}
+ 
+ \defmatrix{test}
+ {
+ 	sin(pi/2) &amp;amp; cos(0) &amp;amp; 0 \\
+ 	2 &amp;amp; -1 &amp;amp; 0 \\
+ 	1 &amp;amp; rand &amp;amp; 1 \\
+ }
+     
+ \defmatrix{test2}
+ {
+ 	(rand()&amp;gt;0.5 ? 1 : 0) &amp;amp; 0 &amp;amp; 1 \\
+ 	0 &amp;amp; 1 &amp;amp; 0 \\
+ 	1 &amp;amp; 0 &amp;amp; 0 \\
+ }
+     
+ \invmatrix{test2}{test2}
+ \addmatrices{test2}{test}{sol}
+ 
+ \begin{eqnarray}
+   \printmatrix{test} + \printmatrix{test2} = \printmatrix{sol}  
+ \end{eqnarray}
+ 
+ \end{document}
+ &amp;lt;/code&amp;gt;

&lt;/pre&gt;</summary>
    </entry>
    <entry>
        <title>start</title>
        <link rel="alternate" type="text/html" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=start&amp;rev=1278964916&amp;do=diff"/>
        <published>2010-07-12T16:01:56-04:00</published>
        <updated>2010-07-12T16:01:56-04:00</updated>
        <id>http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=start&amp;rev=1278964916&amp;do=diff</id>
        <author>
            <name>Ryan Fox</name>
        </author>
        <summary>&lt;pre&gt;
@@ -21,5 +21,6 @@
    * Miscellaneous Experiments
      * [[Directory Annotations]]
      * [[RPG Aquarium]]
      * [[Linux Development Tools for the MSP430 LaunchPad]]
+     * [[PerlTeX Matrix Manipulation Macros]]
  

&lt;/pre&gt;</summary>
    </entry>
    <entry>
        <title>linux_development_tools_for_the_msp430_launchpad - created</title>
        <link rel="alternate" type="text/html" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=linux_development_tools_for_the_msp430_launchpad&amp;rev=1278145557&amp;do=diff"/>
        <published>2010-07-03T04:25:57-04:00</published>
        <updated>2010-07-03T04:25:57-04:00</updated>
        <id>http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=linux_development_tools_for_the_msp430_launchpad&amp;rev=1278145557&amp;do=diff</id>
        <author>
            <name>Ryan Fox</name>
        </author>
        <summary>&lt;pre&gt;
@@ -1 +1,67 @@
+ ~~NOTOC~~
+ ====== Linux Development Tools for the MSP430 LaunchPad ======
+ {{  :launchpad.png|}}
  
+ Texas Instruments has released the [[http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)|LaunchPad]],
+ a new open-source development board for the value line of the MSP430. The chips aren't very powerful, but at
+ [[http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)#Quick_Links|$4.30]], it's hard to go wrong!
+ 
+ However, they do not give any official support for Linux development. There is already a GCC toolchain for the MSP430,
+ and little-to-no effort is needed to get it working with the LaunchPad.
+ 
+ ===== Getting Started =====
+ ==== GCC ====
+ The [[http://mspgcc4.sourceforge.net|mspgcc4 project]] offers a GCC toolchain targeted at the MSP430.
+ Compared to the (somehow much more visible) [[http://mspgcc.sourceforge.net/|mspgcc project]], it boasts better optimization, and
+ better support for C++.
+ 
+ From the [[http://mspgcc4.sourceforge.net/#building|building]] section, you can get latest version of mspgcc4 with:
+   svn checkout https://mspgcc4.svn.sourceforge.net/svnroot/mspgcc4
+   cd mspgcc4 &amp;amp;&amp;amp; sh buildgcc.sh
+ (For me, the script's default options worked well.)
+ 
+ This will take a while to build...
+ 
+ ==== MSPDebug ====
+ In order to load programs to your board, you'll need [[http://mspdebug.sourceforge.net/|MSPDebug]].
+ 
+ Grab the latest version from the [[http://sourceforge.net/projects/mspdebug/files|Sourceforge download page]].
+ From the [[http://mspdebug.sourceforge.net/download.html|installation instructions]], you can build MSPDebug with:
+   sudo apt-get install libusb-dev libreadline-dev
+   make
+   sudo make install
+ (If you're not running Debian or Ubuntu, you'll need to get libusb and libreadline another way.)
+ 
+ ===== Programming the Board =====
+ ==== Temperature Demo ====
+ The code written for the TI's Windows tools needs to be modified to build with GCC.
+ 
+ For now, I've shamelessly (and without permission) stolen some modified code from
+ [[http://losinggeneration.homelinux.org/2010/07/02/msp430-launchpad-on-linux/|&amp;quot;losinggeneration&amp;quot;]].
+ 
+ You can get it here: {{:temperature-demo.tar.bz2|}}
+ 
+ To build the code, simply run:
+   make
+   
+ You should end up with a file called main.elf.
+ 
+ ==== Loading the Code ====
+ To load the code, run:
+   sudo mspdebug rf2500
+   prog main.elf
+ (If you'd like to be able to run mspdebug without sudo, check the
+ [[http://mspdebug.sourceforge.net/download.html|MSPDebug installation instructions]].)
+ 
+ As soon as you exit mspdebug, the program will start.
+ 
+ ==== Debugging ====
+ Instead of closing mspdebug, you can run the 'gdb' command. This will open a &amp;quot;remote target.&amp;quot;
+ 
+ From another terminal, run:
+   msp430-gdb main.elf
+   target remote localhost:2000
+ 
+ Do whatever you might want to do, like setting breakpoints, etc.
+ 
+ Since the program is technically already running on the board, use the 'continue' command to start debugging.

&lt;/pre&gt;</summary>
    </entry>
    <entry>
        <title>ideas</title>
        <link rel="alternate" type="text/html" href="http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=ideas&amp;rev=1272953223&amp;do=diff"/>
        <published>2010-05-04T02:07:03-04:00</published>
        <updated>2010-05-04T02:07:03-04:00</updated>
        <id>http://www.eng.uwaterloo.ca/~rcfox/dokuwiki/doku.php?id=ideas&amp;rev=1272953223&amp;do=diff</id>
        <author>
            <name>Ryan Fox</name>
        </author>
        <summary>&lt;pre&gt;
@@ -5,5 +5,5 @@
      * text editor
      * allow for custom code to be written (in C?) and then linked into the ROM. Perhaps allow for ROM expansion and replace pointers
      * final &amp;quot;compile&amp;quot; stage might have to calculate a checksum?
  
-   * Extract map data from ROMs to draw them. Why? For fun!
+   * Extract map data from ROMs to draw them. Why? For fun! [[http://www.romhacking.net/docs/dwbytes.txt]]

&lt;/pre&gt;</summary>
    </entry>
</feed>

