<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3504720297030477076</id><updated>2011-11-01T02:07:07.296-07:00</updated><category term='usb dvd writer'/><category term='summer bursary'/><category term='emacs'/><category term='packaging'/><category term='leptonica'/><category term='goodstein&apos;s theorem'/><category term='warwick'/><category term='1.43'/><category term='latex'/><category term='backup home'/><category term='ical'/><category term='copying'/><category term='subscribe'/><category term='utf'/><category term='c'/><category term='finite tree'/><category term='umlaut'/><category term='firefox'/><category term='stochastic integration'/><category term='neurons'/><category term='svg'/><category term='bookmarklet'/><category term='utf8'/><category term='journal'/><category term='book review'/><category term='xfce'/><category term='debian'/><category term='source code'/><category term='gcc'/><category term='.ics'/><category term='Orage'/><category term='libtool'/><category term='stochastic differential equations'/><category term='c++'/><title type='text'>Mathematical Musings</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-8893640912236278334</id><published>2011-11-01T02:06:00.000-07:00</published><updated>2011-11-01T02:07:07.315-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='gcc'/><category scheme='http://www.blogger.com/atom/ns#' term='c'/><category scheme='http://www.blogger.com/atom/ns#' term='libtool'/><title type='text'>When libtool's dependency_libs goes weird</title><content type='html'>&lt;p&gt;I had a strange problem last night where I couldn't build some code I was working on. The program (&lt;a href="http://gpsim.sourceforge.net/"&gt;gpsim&lt;/a&gt;) depends on the Gtk stack and the errors I got seemed to refer to a nonexistant libtool &lt;tt&gt;.la&lt;/tt&gt; file:&lt;/p&gt;&lt;code&gt;libtool: link: ar cru .libs/libgpsimgui.a  gui_break.o gui_callbacks.o gui_dialog.o gui_init.o gui_main.o gui_menu.o gui_processor.o gui_regwin.o gui_src.o gui_src_asm.o gui_src_opcode.o gui_statusbar.o gui_symbols.o gui_watch.o gui_breadboard.o gui_stack.o gui_trace.o gui_profile.o gui_stopwatch.o gui_object.o gui_scope.o settings_exdbm.o gui_hextable.o preferences.o gui_marshal.olibtool: link: ranlib .libs/libgpsimgui.a/bin/sed: can't read /usr/lib/libgio-2.0.la: No such file or directorylibtool: link: `/usr/lib/libgio-2.0.la' is not a valid libtool archive&lt;/code&gt;&lt;p&gt;Now, I'm running an up-to-date version of Debian unstable and I couldn't really believe that a problem that stopped people linking things depending on glib would survive very long. The solution came when I realised that references to &lt;tt&gt;/path/to/foo.la&lt;/tt&gt; come from other &lt;tt&gt;.la&lt;/tt&gt; files. Ahah! So, after some thought, I tried a grep command:&lt;/p&gt;&lt;pre&gt;$ locate '*.la' | xargs grep libgio-2.0.la | grep '^/opt' | cut -d : -f 1&lt;br /&gt;/opt/gnome/lib/gtk-2.0/modules/libgtkparasite.la&lt;br /&gt;/opt/gnome/lib/libgpsim.la&lt;br /&gt;/opt/gnome/lib/libgpsimcli.la&lt;br /&gt;/opt/gnome/lib/libgpsimgui.la&lt;br /&gt;/opt/gnome/lib/libgpsim_ds1307.la&lt;br /&gt;/opt/gnome/lib/libgpsim_dspic.la&lt;br /&gt;/opt/gnome/lib/libgpsim_graphicLCD.la&lt;br /&gt;/opt/gnome/lib/libgpsim_lcd.la&lt;br /&gt;/opt/gnome/lib/libgpsim_modules.la&lt;br /&gt;/opt/gnome/lib/libgtkextra-x11-2.0.la&lt;/pre&gt;&lt;p&gt;Ahah! The culprit was the last line: gpsim still links against the hideously obsolete libgtkextra and I'd forgotten to rebuild my local copy when upgrading my glib package to one that doesn't ship libgio-2.0.la. Editing the libgtkextra &lt;tt&gt;.la&lt;/tt&gt; file might have worked but I just rebuilt the lot to make sure it worked. Sorted!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-8893640912236278334?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/8893640912236278334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=8893640912236278334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/8893640912236278334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/8893640912236278334'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2011/11/when-libtools-dependencylibs-goes-weird.html' title='When libtool&apos;s dependency_libs goes weird'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-536381464108033959</id><published>2011-10-04T07:58:00.000-07:00</published><updated>2011-10-04T07:58:29.793-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='journal'/><category scheme='http://www.blogger.com/atom/ns#' term='bookmarklet'/><category scheme='http://www.blogger.com/atom/ns#' term='warwick'/><title type='text'>Bookmarklet to ease the pain from Warwick Uni Library's E-journal change</title><content type='html'>&lt;p&gt;The &lt;a href="http://webcat.warwick.ac.uk/"&gt;University of Warwick Library&lt;/a&gt; no longer allow access to E-journals except after jumping through hoops to access them through the library's web catalogue. This is painful and, although I've now got a plethora of links to various journal home-pages, I still find myself cutting and pasting parts of URLs to avoid some journals' awful navigation interfaces.&lt;/p&gt;&lt;p&gt;But all is not lost! &lt;a href="javascript:(function(){var%20str=location.href;if(str.substr(0,7)!=&amp;quot;http://&amp;quot;){alert(&amp;quot;Unrecognised%20protocol&amp;quot;);return;}var%20ffs=str.substr(7).indexOf(&amp;quot;/&amp;quot;);if(ffs==-1){fs=str.length-1;}else{ffs=ffs+7;}window.open(&amp;quot;http://0-&amp;quot;+str.substr(7,ffs-7)+&amp;quot;.pugwash.lib.warwick.ac.uk/&amp;quot;+str.substr(ffs+1));})()"&gt;Here&lt;/a&gt;'s a JavaScript bookmarklet which will open up the current page channelled through Pugwash, which appears to be the library's main server. It seems to work for me, but the "0-" prefix on the URLs looks worryingly magical and I'm not sure whether this is correct for all journals...&lt;/p&gt;&lt;p&gt;To use the bookmarklet on Firefox (or pretty much anywhere else), you can right-click on the link (the "here" above) and select something like "Bookmark this link". If you are (rightly) wary of trusting a random hunk of JavaScript, this is the code:&lt;/p&gt;&lt;p&gt;&lt;pre&gt;javascript:(function(){&lt;br /&gt;  var str=location.href;&lt;br /&gt;  if(str.substr(0,7)!="http://") {&lt;br /&gt;    alert("Unrecognised protocol");&lt;br /&gt;    return;&lt;br /&gt;  }&lt;br /&gt;  var ffs=str.substr(7).indexOf("/");&lt;br /&gt;  if(ffs==-1) {&lt;br /&gt;    fs=str.length-1;&lt;br /&gt;  }&lt;br /&gt;  else {&lt;br /&gt;    ffs=ffs+7;&lt;br /&gt;  }&lt;br /&gt;  window.open("http://0-" + str.substr(7,ffs-7) +&lt;br /&gt;              ".pugwash.lib.warwick.ac.uk/"+str.substr(ffs+1));&lt;br /&gt;})()&lt;br /&gt;&lt;/pre&gt;&lt;/p&gt;&lt;p&gt;(It has to be on one line to work, so you'll need to delete a lot of whitespace if you want to copy and paste this).&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-536381464108033959?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/536381464108033959/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=536381464108033959' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/536381464108033959'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/536381464108033959'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2011/10/bookmarklet-to-ease-pain-from-warwick.html' title='Bookmarklet to ease the pain from Warwick Uni Library&apos;s E-journal change'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-274078796346081</id><published>2010-06-24T07:47:00.000-07:00</published><updated>2010-06-24T07:49:12.534-07:00</updated><title type='text'>Gray boxes in evince</title><content type='html'>&lt;p&gt;If you're having a weird problem with evince showing gray boxes instead of text in some pdfs, the problem could well be a bug in cairo.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;After some help from "danigm" on the #evince channel on irc.gnome.org, I found that the bug disappeared on upgrading libcairo to 1.9.8 (which is currently in debian experimental).&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Anyway, hopefully the next person who searches google for grey boxes in evince or indeed gray boxes in evince should find the solution!&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-274078796346081?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/274078796346081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=274078796346081' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/274078796346081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/274078796346081'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2010/06/gray-boxes-in-evince.html' title='Gray boxes in evince'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-8014209098007458093</id><published>2009-07-31T05:15:00.000-07:00</published><updated>2009-07-31T05:17:43.800-07:00</updated><title type='text'>Huawei E1550 on Debian</title><content type='html'>If you want to get the Huawei E1550 USB modem working with linux, here's what you need to do, with specific instructions for those on Debian.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;modem-modeswitch&lt;/h4&gt;&lt;br /&gt;&lt;div class="first"&gt;This utility is part of &lt;a href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html"&gt;udev&lt;/a&gt; as of version 145. You need it because the E1550 has a clever double-identity: when you insert it at first, it masquerades as a mass storage device (usb id 12D1:1446). Upon running this magical command, it disconnects and reappears as an "E620 USB modem" (usb id 12D1:1001). Magic eh?&lt;/div&gt;&lt;br /&gt;Firstly, you need to get the program. If you have udev 145, life is good. Unfortunately, the &lt;a href="http://packages.debian.org/sid/udev"&gt;current debian unstable package&lt;/a&gt; is on version 141, which doesn't have it. Trying to manually install udev 145, I managed to break my X setup quite spectacularly, so I don't advise that. Fortunately, if you download the latest udev source (from&lt;br /&gt;&lt;a href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/"&gt;http://www.kernel.org/pub/linux/utils/kernel/hotplug/&lt;/a&gt;) and compile it, you'll find that the binary in the &lt;code&gt;extras/modem-modeswitch&lt;/code&gt; directory works fine without the rest of udev 145. Note that to compile udev, you'll need some libraries. On debian, an incantation like &lt;code&gt;apt-get build-dep udev&lt;/code&gt; should get them. To put it somewhere useful, one option is to run &lt;code&gt;checkinstall&lt;/code&gt; from inside the &lt;code&gt;extras/modem-modeswitch&lt;/code&gt;&lt;br /&gt;directory and make a fake debian package for the meantime.&lt;br /&gt;&lt;br /&gt;Now you've got modem-modeswitch installed, you want to try it!  Pull up a spare terminal window and run something like &lt;code&gt;sudo tail -f /var/log/syslog&lt;/code&gt; in it. This lets you know what's going on, since drivers tend to report stuff there when they initialise&lt;br /&gt;themselves. Now run the following command &lt;code&gt;/path/to/modem-modeswitch -v 0x12d1 -p 0x1446 -t option-zerocd&lt;/code&gt;. On my dongle (courtesy of &lt;a href="http://www.three.co.uk/"&gt;3&lt;/a&gt;), there's a green LED that flashes at first and then turns blue at this point. In any case, the syslog window should report a USB disconnect and then a new device. Running &lt;code&gt;lsusb&lt;/code&gt; should show a line something like &lt;code&gt;Bus 002 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem&lt;/code&gt; (the first two numbers will probably be different: they're&lt;br /&gt;just to say where it's connected).&lt;br /&gt;&lt;br /&gt;If you've got this far, the confusing bit's over. Unplug the device again and we'll set things up to run modem-modeswitch by default.&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;udev&lt;/h4&gt;&lt;br /&gt;&lt;div class="first"&gt;To do so, we need to create a udev rule to tell it to run when the device is plugged in. Create a file in &lt;code&gt;/etc/udev/rules.d/&lt;/code&gt; called something like &lt;code&gt;50-huawei1550.rules&lt;/code&gt; containing the following line&lt;/div&gt;&lt;br /&gt;&lt;pre class="example"&gt;SUBSYSTEM=="usb", SYSFS{idProduct}=="1446",SYSFS{idVendor}=="12d1", RUN+="/usr/libexec/modem-modeswitch --vendor 0x12d1 --product 0x1446 --type option-zerocd"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;This tells udev that when a device with USB id 12d1:1446 gets plugged in, it should run modem-modeswitch to change its mode. (This snippet came from somewhere on the web, but I've lost the reference). You probably need to restart udev here (/etc/init.d/udev restart) to enable your rule. Re-insert the device and cross your fingers... if everything works, it should change mode.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;usb-serial&lt;/h4&gt;&lt;div class="first"&gt;If you're using a distro kernel, you can probably ignore this, but I was running a home-built kernel which didn't have the usb-serial kernel module. You need it.&lt;/div&gt;&lt;br /&gt;If you've got stuff right, lines like the following should appear in your syslog:&lt;br /&gt;&lt;br /&gt;&lt;pre class="example"&gt;Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial&lt;br /&gt;Jul 31 10:49:03 hake kernel: USB Serial support registered for generic&lt;br /&gt;Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver usbserial_generic&lt;br /&gt;Jul 31 10:49:03 hake kernel: usbserial: USB Serial Driver core&lt;br /&gt;Jul 31 10:49:03 hake kernel: USB Serial support registered for GSM modem (1-port)&lt;br /&gt;Jul 31 10:49:03 hake kernel: option 2-2:1.0: GSM modem (1-port) converter detected&lt;br /&gt;Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB0&lt;br /&gt;Jul 31 10:49:03 hake kernel: option 2-2:1.1: GSM modem (1-port) converter detected&lt;br /&gt;Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB1&lt;br /&gt;Jul 31 10:49:03 hake kernel: option 2-2:1.2: GSM modem (1-port) converter detected&lt;br /&gt;Jul 31 10:49:03 hake kernel: usb 2-2: GSM modem (1-port) converter now attached to ttyUSB2&lt;br /&gt;Jul 31 10:49:03 hake kernel: usbcore: registered new interface driver option&lt;br /&gt;Jul 31 10:49:03 hake kernel: option: v0.7.2:USB Driver for GSM modems&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-8014209098007458093?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/8014209098007458093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=8014209098007458093' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/8014209098007458093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/8014209098007458093'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2009/07/if-you-want-to-get-huawei-e1550-usb.html' title='Huawei E1550 on Debian'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-2915013951412811562</id><published>2008-10-30T14:34:00.000-07:00</published><updated>2008-10-30T14:37:04.725-07:00</updated><title type='text'>Science Education Website</title><content type='html'>Well, I'm lame and not really updating this. However, my mother has a terribly nice (ahem?) website at &lt;a href="http://was-science.freehostia.com/"&gt;WAS Science&lt;/a&gt;, which she doesn't seem to be able to get web spiders to notice. It's a site full of science education resources including powerpoint presentations and worksheets.&lt;br /&gt;&lt;br /&gt;Maybe some googly goodness from blogger will go her way.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-2915013951412811562?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/2915013951412811562/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=2915013951412811562' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/2915013951412811562'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/2915013951412811562'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2008/10/science-education-website.html' title='Science Education Website'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-6814841129189300534</id><published>2007-07-26T09:46:00.000-07:00</published><updated>2007-07-27T08:43:34.014-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='stochastic differential equations'/><category scheme='http://www.blogger.com/atom/ns#' term='neurons'/><category scheme='http://www.blogger.com/atom/ns#' term='summer bursary'/><category scheme='http://www.blogger.com/atom/ns#' term='book review'/><category scheme='http://www.blogger.com/atom/ns#' term='stochastic integration'/><title type='text'>Quick book recommendation</title><content type='html'>This summer, I've got an &lt;a href="http://www2.warwick.ac.uk/services/cap/landt/rbl/urss/scheme/"&gt;undergraduate research bursary&lt;/a&gt; at our university's &lt;a href="http://www2.warwick.ac.uk/fac/sci/systemsbiology/"&gt;Systems Biology centre&lt;/a&gt;, which is wierd as I always viewed myself of more of a pure mathematician, but is absolutely fascinating.&lt;br /&gt;&lt;br /&gt;I have jumped in at the deep end, however (my supervisor seems to think I know a lot more than I really do and maybe hasn't realised I haven't done any serious integration/differentiation or ODEs stuff since the first year...).&lt;br /&gt;&lt;br /&gt;What I'm actually doing is looking at the response of Neurons to different types of presynaptic noise, which I am slowly learning more about. In particular, noise is random (well, duh) and so all of the models I end up with have &lt;a href="http://en.wikipedia.org/wiki/Stochastic_differential_equation"&gt;Stochastic Differential Equations&lt;/a&gt;, which are typically quite unpleasant. For those interested, the toy models I'm playing with end up with Brownian motion in a harmonic potential.&lt;br /&gt;&lt;br /&gt;So the book I'm recommending is:&lt;br /&gt;&lt;br /&gt;Paul and Baschnagel, "Stochastic Processes, From Physics to Finance"&lt;br /&gt;&lt;br /&gt;Don't let the reference to finance put you off - I've found it absolutely fantastic for explaining the basics of Wiener processes, brownian motion and so on. In particular, it is written for the scientist rather than the mathematician and so everything's done in the real numbers, rather than over wierd and wonderful probability spaces. I really believe that even if you want to learn stochastic integration properly as a mathematician, this is a worthwhile read, because you end up for a real feel for what's going on.&lt;br /&gt;&lt;br /&gt;The book's published by Springer and is on Amazon &lt;a href="http://www.amazon.co.uk/Stochastic-Processes-Physics-Wolfgang-Paul/dp/3540665609/ref=sr_1_1/203-5588307-4959122?ie=UTF8&amp;s=books&amp;qid=1185550943&amp;sr=8-1"&gt;here&lt;/a&gt; at the terrifying price of about £50 used, so you might want to try a university library!&lt;br /&gt;&lt;br /&gt;Now back to work!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-6814841129189300534?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/6814841129189300534/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=6814841129189300534' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/6814841129189300534'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/6814841129189300534'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/07/quick-book-recommendation.html' title='Quick book recommendation'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-6581457877606751268</id><published>2007-07-05T15:53:00.000-07:00</published><updated>2007-07-05T16:19:18.830-07:00</updated><title type='text'>Fun with xorg.conf</title><content type='html'>So I've finally got my ALPS / Synaptics touchpad working along with a compose key on debian (the ALPS touchpad comes with, among many other laptops, the Dell Inspiron 500m which I own).&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The touchpad&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;For the touchpad, I need to thank &lt;a href="http://www.debuntu.org/2006/06/18/67-how-to-setting-up-touchpad-on-a-laptop-a-complete-guide"&gt;this walkthrough&lt;/a&gt; along with &lt;a href="http://ubuntuforums.org/showthread.php?p=975421"&gt;this forum thread&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Before anything will work, you need to make sure that the evdev module is being compiled in your kernel (it wasn't) and is being loaded (that bit worked for free for me, but one comment on the above forum post suggested you needed to add it to /etc/modules). You can find the option under Device Drivers/Input Device Support/Event Interface in the kernel config (e.g. &lt;code&gt;make menuconfig&lt;/code&gt;)&lt;br /&gt;&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;br /&gt;Now you need to edit your xorg.conf (found in /etc/X11). There are three things that you need to do:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Load the synaptics module&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Add a new input device to ServerLayout&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Declare the input device&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;In order to load the synaptics module, add a line saying:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        Load  "synaptics"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;to the "Module" section. Mine now looks like:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;Section "Module"&lt;br /&gt;        Load  "glx"&lt;br /&gt;        Load  "extmod"&lt;br /&gt;        Load  "xtrap"&lt;br /&gt;        Load  "record"&lt;br /&gt;        Load  "GLcore"&lt;br /&gt;        Load  "dbe"&lt;br /&gt;        Load  "dri"&lt;br /&gt;        Load  "type1"&lt;br /&gt;        Load  "synaptics"&lt;br /&gt;EndSection&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Now adding a new input device to ServerLayout is simple - just choose a name (I called it "ALPS") and add the line&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        InputDevice "your name for it here"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;to the ServerLayout section just below the line saying&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        InputDevice "Configured Mouse"&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Finally, add the declaration for the input device. A version with no clever options set is:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;Section "InputDevice"&lt;br /&gt;        Identifier "ALPS"&lt;br /&gt;        Driver "synaptics"&lt;br /&gt;        Option "SendCoreEvents" "true"&lt;br /&gt;        Option "Device" "/dev/input/mouse1"&lt;br /&gt;        Option "Protocol" "evdev"&lt;br /&gt;        Option "SHMConfig" "on"&lt;br /&gt;EndSection&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;(note that the identifier has to agree with the name you chose earlier). For a much more thorough list of settings you might wish to see the third page of the debuntu article &lt;a href="http://www.debuntu.org/2006/06/18/67-how-to-setting-up-touchpad-on-a-laptop-a-complete-guide/3"&gt;here&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Assuming you got everything right, you should now be able to restart your X server and get exciting touchpad support. Note that to restart the X server, the best practice is to exit (gracefully) any open programs, log out of whatever desktop environment you're using and when you get to the display manager (xdm,kdm,gdm or whatever) hit Ctrl-Alt-Backspace.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight:bold;"&gt;The Compose Key&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is really simple, but it makes life much easier when writing auf Deutsch on an english keyboard. In your InputDevice section corresponding to your keyboard, add the line:&lt;br /&gt;&lt;code&gt;Option      "XkbOptions" "lv3:ralt_switch, compose:ralt"&lt;/code&gt;&lt;br /&gt;The relevant section in my xorg.conf now looks like this:&lt;br /&gt;&lt;code&gt;&lt;pre&gt;&lt;br /&gt;Section "InputDevice"&lt;br /&gt;        Identifier  "Keyboard0"&lt;br /&gt;        Driver      "kbd"&lt;br /&gt;        Option      "XkbModel"      "pc105"&lt;br /&gt;        Option      "XkbLayout"     "gb"&lt;br /&gt;        Option      "XkbOptions"    "lv3:ralt_switch, compose:ralt"&lt;br /&gt;EndSection&lt;br /&gt;&lt;/pre&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Once you've restarted the X server, Alt-Gr S, S should give ß and you can have the fun of discovering umlauts, graves, circumflexes etc. yourself. It's a bit like a more logical version of the system they used in Microsoft Word.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-6581457877606751268?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/6581457877606751268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=6581457877606751268' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/6581457877606751268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/6581457877606751268'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/07/fun-with-xorgconf.html' title='Fun with xorg.conf'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-7424561865422424061</id><published>2007-06-13T05:13:00.000-07:00</published><updated>2007-06-13T09:13:32.668-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='backup home'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='usb dvd writer'/><title type='text'>Backing up your home to DVD with debian</title><content type='html'>I've finally got a DVD writer (external - it's a laptop) and it works quite amazingly well: no setup issues at all!&lt;br /&gt;&lt;br /&gt;Now, the whole point of the exercise was that my Dell is getting a little dodgy (you have to press down hard around the power button to flex the PCB below in order to get it to boot!) and I wanted to back up my documents, sourcecode, emails etc. in case the worst should befall my poor old laptop. But I had a German exam the next day, and while I was burning the DVD I should also be revising!&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;br /&gt;In general, burning a data DVD on linux is easy. You get a copy of mkisofs and growisofs (on debian, this is easy: &lt;code&gt;apt-get install dvd+rw-tools mkisofs&lt;/code&gt;). Then you call mkisofs on a directory tree to create an iso image (put it in /tmp!) and growisofs to write the lot to your DVD (I got the instructions &lt;a href="http://www.cyberciti.biz/tips/howto-linux-write-burn-data-to-dvd-or-dvdrw.html"&gt;here&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ahah, but not so fast! I wanted to do my home directory whilst xfce, claws-mail, firefox and probably a whole load of other processes were writing tiddly little bits to all my hidden dot-files and dot-directories in ~/ (you know, the ones like ~/.gnome and ~/.mozilla etc.). In fact, I didn't twig the first time and mkisofs threw a wobbly! Moreover, I didn't want to make another copy of everything because there's quite a lot of stuff and I didn't really have space for that on the harddisk partition.&lt;br /&gt;&lt;br /&gt;So here's the solution:&lt;br /&gt;&lt;br /&gt;First I made a folder called backmeup in my home directory:&lt;br /&gt;&lt;code&gt;mkdir backmeup&lt;/code&gt;&lt;br /&gt;Then I moved all of the "normal" i.e. non-hidden files in my home directory into backmeup:&lt;br /&gt;&lt;code&gt;mv * backmeup&lt;/code&gt;&lt;br /&gt;This will actually complain because at some point you've asked it to move backmeup into backmeup, but ignore the complaint - it did what we wanted! Now for the dot-files. We don't want to &lt;span style=""&gt;move&lt;/span&gt; them into backmeup, because some of the running programs would throw a wobbly, so we will actually need to copy this lot. Now, don't run &lt;code&gt;cp -Rp .* backmeup/&lt;/code&gt; because it'll go horribly wrong and try to make two copies of backmeup via the .. directory I think (disclaimer: Yes, this did go horribly wrong. And it took me 5 minutes to notice!)&lt;br /&gt;&lt;br /&gt;Instead, call the following command:&lt;br /&gt;&lt;code&gt;cp -Rp `find -maxdepth 1 -name '.*' | sed '/^\.$/d'` backmeup&lt;/code&gt;&lt;br /&gt;which is what we really wanted.&lt;br /&gt;&lt;br /&gt;Now we're almost done! Just make the iso from the backmeup tree (no-one's going to be writing automatically to something called that!):&lt;br /&gt;&lt;code&gt;nice -n 19 mkisofs -r -o /tmp/rupert.iso /home/rupert/backmeup&lt;/code&gt;&lt;br /&gt;The &lt;code&gt;nice&lt;/code&gt; command is just to stop the job hogging the whole system.&lt;br /&gt;&lt;br /&gt;... And write the iso to the disk:&lt;br /&gt;growisofs -Z /dev/scd0=/tmp/rupert.iso&lt;br /&gt;&lt;br /&gt;(clearly the device to which you write will need to depend on what the kernel calls it - I'm trying to do something clever with udev, but haven't quite got there yet!)&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-7424561865422424061?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/7424561865422424061/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=7424561865422424061' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/7424561865422424061'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/7424561865422424061'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/06/backing-up-your-home-to-dvd-with-debian.html' title='Backing up your home to DVD with debian'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-1905311995145192126</id><published>2007-06-06T17:34:00.000-07:00</published><updated>2007-06-06T17:48:10.809-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='.ics'/><category scheme='http://www.blogger.com/atom/ns#' term='xfce'/><category scheme='http://www.blogger.com/atom/ns#' term='subscribe'/><category scheme='http://www.blogger.com/atom/ns#' term='Orage'/><category scheme='http://www.blogger.com/atom/ns#' term='ical'/><title type='text'>Ical subscriptions with orage</title><content type='html'>Orage looks to be an exciting program for my new Xfce desktop, but what good's a calendar if it can't subscribe to ical feeds from the internet?! Fortunately, I'm supposed to be revising at the moment, so have had an urge to hack code together...&lt;br /&gt;&lt;br /&gt;And so we present a simple shell script to download .ics files periodically from the internet to your filesystem. The one nifty feature is that if the internet's down, this won't blat the current copies as using wget blindly would, which should be useful with my laptop.&lt;br /&gt;&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;br /&gt;There are probably more sophisticated systems, but I was going for the 25 minute job option. Firstly, we need a list of feeds - mine looked something like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;## Lines must be either urls, blank, or start with a #.&lt;br /&gt;&lt;br /&gt;# UK holidays&lt;br /&gt;http://ical.mac.com/ical/UK32Holidays.ics&lt;br /&gt;&lt;br /&gt;# NASA Space Missions&lt;br /&gt;http://ical.mac.com/tonyfarley/SpaceMissions.ics&lt;br /&gt;&lt;br /&gt;# Astronomical Events&lt;br /&gt;http://hewgill.com/astrocal/astrocal.ics&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The lines beginning with hashes really are comments - they get stripped by the downloading script, which uses wget:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/bin/sh&lt;br /&gt;&lt;br /&gt;dir=/home/rupert/.icals/&lt;br /&gt;&lt;br /&gt;for f in `cat $dir/feeds.list | sed -e '/^$/d' -e '/^\#/d'`&lt;br /&gt;do&lt;br /&gt; fout=$dir/`echo $f | md5sum | cut -f 1 -d ' '`.ics&lt;br /&gt; tmp=`mktemp $dir/getfile.XXXXXX`&lt;br /&gt; wget -q --tries=3 -O $tmp $f&lt;br /&gt; if [ -s $tmp ]; then&lt;br /&gt;   mv $tmp $fout&lt;br /&gt; else&lt;br /&gt;   rm $tmp&lt;br /&gt; fi&lt;br /&gt;done&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;To make it work, you need to call the first file feeds.list and set dir to a directory containing feeds.list and in which you'd like your downloaded .ics files to end up. The quickest way I could think of to give the files names was the md5sum of the url, so once you've got everything in place, set the executable bit on the script (which I called get_feeds.sh) and run it.&lt;br /&gt;&lt;br /&gt;If all goes to plan, you should get some files called things like "5b7ed8afdd4a8f71525d0df0e47231e5.ics" appearing in $dir. Now we need to automate it: I used cron, so call crontab -e and add the following line to your crontab:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;*/15 * * * * /home/rupert/.icals/get_feeds.sh&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;(well clearly, you'll need to make the directory right!) This calls the get_feeds.sh script every 15 minutes. Maybe we should slow that down, but I was testing!&lt;br /&gt;&lt;br /&gt;Finally, use the new "Exchange Data" item on Orage's File menu to add a foreign file corresponding to the .ics you downloaded and you're away! Wahey!&lt;br /&gt;&lt;br /&gt;Incidentally, the SVN orage that I downloaded this evening doesn't appear to be getting multiple foreign files quite right - if I can work out what's going on, I'll file a bug tomorrow!&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-1905311995145192126?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/1905311995145192126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=1905311995145192126' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/1905311995145192126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/1905311995145192126'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/06/ical-subscriptions-with-orage.html' title='Ical subscriptions with orage'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-4930308306796310017</id><published>2007-05-13T08:27:00.000-07:00</published><updated>2007-05-13T08:31:04.627-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='svg'/><category scheme='http://www.blogger.com/atom/ns#' term='finite tree'/><category scheme='http://www.blogger.com/atom/ns#' term='source code'/><title type='text'>Tree display program (update)</title><content type='html'>Well, I handed in a rather inconclusive version of the essay I mentioned. It and the program used to generate the trees are both &lt;a href="http://rupert.uwcs.co.uk/TreeProg.html"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;I'd love it if anyone found the program useful - and anyone's more than welcome to do anything with the code, although I'd appreciate a heads-up out of interest. Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-4930308306796310017?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/4930308306796310017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=4930308306796310017' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/4930308306796310017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/4930308306796310017'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/05/tree-display-program-update.html' title='Tree display program (update)'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-643409473281270000</id><published>2007-05-13T07:28:00.000-07:00</published><updated>2007-05-13T07:35:18.595-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='utf8'/><category scheme='http://www.blogger.com/atom/ns#' term='copying'/><category scheme='http://www.blogger.com/atom/ns#' term='utf'/><category scheme='http://www.blogger.com/atom/ns#' term='emacs'/><category scheme='http://www.blogger.com/atom/ns#' term='umlaut'/><title type='text'>Copying UTF into Emacs</title><content type='html'>It's been annoying me for &lt;b&gt;ages&lt;/b&gt;, but I never really got UTF copy/paste working right in Emacs. Finally (procrastinating from German revision) I found a solution that works for copying from Firefox at least.&lt;br /&gt;&lt;br /&gt;The solution is detailed &lt;a href="http://www.emacswiki.org/cgi-bin/wiki/UnicodeEncoding#UnicodeEncoding5"&gt;here&lt;/a&gt; and I'm eternally grateful. Basically, just put the following code somewhere in your .emacs:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;(setq x-select-request-type '(UTF8_STRING COMPOUND_TEXT TEXT STRING))&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;And, voila, umlauts (like ö) and I presume strange characters from other languages will appear in all their glory!&lt;br /&gt;&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-643409473281270000?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/643409473281270000/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=643409473281270000' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/643409473281270000'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/643409473281270000'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/05/copying-utf-into-emacs.html' title='Copying UTF into Emacs'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-734709335607440268</id><published>2007-04-08T10:56:00.000-07:00</published><updated>2007-04-08T12:27:01.056-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='1.43'/><category scheme='http://www.blogger.com/atom/ns#' term='packaging'/><category scheme='http://www.blogger.com/atom/ns#' term='debian'/><category scheme='http://www.blogger.com/atom/ns#' term='leptonica'/><title type='text'>Leptonica 1.43 in debian</title><content type='html'>&lt;p&gt;What a load of effort! I've been developing a program using &lt;a href="http://www.leptonica.com/"&gt;leptonica&lt;/a&gt; recently, using the debian package without thinking. Irritatingly, however, debian is at version 1.37 and upstream is at 1.43.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The good news is that the debian diff still works - to get a quick and dirty install (which is all I'm interested in!) do the following:&lt;/p&gt;&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;ol&gt;&lt;li&gt;Download the &lt;a href="http://ftp.debian.org/debian/pool/main/l/leptonlib/leptonlib_1.37-1.diff.gz"&gt;debian diff&lt;/a&gt; from &lt;a href="http://packages.qa.debian.org/l/leptonlib.html"&gt;this page&lt;/a&gt;.&lt;/li&gt;&lt;li&gt;Patch a copy of the current source (from &lt;a href="http://www.leptonica.com/source/leptonlib-1.43.tar.gz"&gt;here&lt;/a&gt;) using the command:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;patch &lt;../leptonlib_1.37-1.diff -p1 &lt;/code&gt;&lt;br /&gt;&lt;br /&gt;from within the directory into which you extracted leptonica.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Make the "debian/rules" file executable:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;chmod 0755 debian/rules&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Edit the "debian/docs" file and remove the line with library-notes.txt (it no longer exists in the package)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;cd into the debian directory and run the command&lt;br /&gt;&lt;code&gt;&lt;br /&gt;dch -v 1.44-1&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;(The dch program is part of the devscripts package)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Finally, make sure a copy of the original 1.43 tar.gz is in the parent directory with the name &lt;pre&gt;leptonlib_1.43.orig.tar.gz&lt;/pre&gt; and call &lt;pre&gt;debuild&lt;/pre&gt; from the main source directory. Hopefully, it should compile and you'll have the relevant debfiles in the parent directory from which to install leptonica 1.43!&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-734709335607440268?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/734709335607440268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=734709335607440268' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/734709335607440268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/734709335607440268'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/04/leptonica-143-in-debian.html' title='Leptonica 1.43 in debian'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-501713154230057546</id><published>2007-03-30T13:57:00.001-07:00</published><updated>2007-03-30T16:28:23.512-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='c++'/><category scheme='http://www.blogger.com/atom/ns#' term='latex'/><category scheme='http://www.blogger.com/atom/ns#' term='finite tree'/><category scheme='http://www.blogger.com/atom/ns#' term='goodstein&apos;s theorem'/><title type='text'>Tree display program</title><content type='html'>&lt;div xmlns="http://www.w3.org/1999/xhtml"&gt;I've been writing away at a compulsory second year essay for what seems ages now. In particular, this one's about Goodstein's Theorem. When it's done (which will definitely be before the deadline in 3 weeks' time), I'll see what I can do about posting a version.&lt;br /&gt;&lt;br /&gt;However, for now, I've been working on a bit in the proof of the theorem. What you need to do is express a number in &lt;a href="http://en.wikipedia.org/wiki/Goodstein%27s_theorem"&gt;hereditary base-n notation&lt;/a&gt; which is explained on the Wikipedia article I just linked to. Now suppose you draw a rooted finite tree in the following way (let's express 93 in base 2).&lt;br /&gt;&lt;br /&gt;First note that:&lt;br /&gt;&lt;/div&gt;&lt;img src="http://www.forkosh.dreamhost.com/mimetex.cgi?93%20=%202%5E6+2%5E4+2%5E3+2%5E2+1%3Cbr%3E%0A%0A%5C%5C%5Cqquad=%202%5E%7B2%5E%7B2%5E%7B2%5E0%7D%7D+2%5E%7B2%5E0%7D%7D+2%5E%7B2%5E%7B2%5E%7B2%5E0%7D%7D%7D+2%5E%7B2%5E%7B2%5E0%7D+2%5E0%7D+2%5E%7B2%5E%7B2%5E0%7D%7D+2%5E0" align="middle" border="0" /&gt;&lt;br /&gt;&lt;br /&gt;Now build a tree one level of branches at a time. In the first level, is a branch for each term in the expansion above. Then a child of each node has children that are the terms in the exponent of that child... It'll make more sense with a picture:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_oGJy63klAL8/Rg16KVJ4f1I/AAAAAAAAAAM/1uBCgSL3XFs/s1600-h/93-2.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_oGJy63klAL8/Rg16KVJ4f1I/AAAAAAAAAAM/1uBCgSL3XFs/s320/93-2.png" alt="" id="BLOGGER_PHOTO_ID_5047825075248070482" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;I hope :)&lt;br /&gt;&lt;br /&gt;So what I wrote was a program that would generate that sort of picture because I needed some in the essay and couldn't find something on the internet to draw it. To save problems with file formats etc., the program actually exports to SVG - to generate png images for here and for PdfLatex in the essay I used the command "&lt;span style="font-family:courier new;"&gt;inkscape -f file.svg -e file.png", which I found &lt;a href="http://zkwarl.blogspot.com/2006/08/inkscape-tip-use-inkscape-on-command.html"&gt;here&lt;/a&gt;. So I'm going to try and post the code below. The command line options are:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;Options:&lt;br /&gt;&lt;br /&gt;--help                       produce help message&lt;br /&gt;-b [ --base ] arg (=2)       set base of expansion&lt;br /&gt;-s [ --stroke ] arg (=black) set colour of stroke&lt;br /&gt;-f [ --fill ] arg (=red)     set colour of fill&lt;br /&gt;-w [ --width ] arg (=800)    width of image&lt;br /&gt;-h [ --height ] arg (=600)   height of image&lt;br /&gt;-o [ --output ] arg (=-)     Output file&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And to make the picture above, use:&lt;br /&gt;&lt;pre&gt;maketree 93 -b 2&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;To compile, you just need &lt;a href="http://www.boost.org/doc/html/program_options.html"&gt;boost program options&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;code&gt;&lt;/code&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;Anyway, here are the sources:&lt;br /&gt;&lt;br /&gt;&lt;span id="fullpost"&gt;&lt;br /&gt;&lt;br /&gt;Makefile:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;maketree: maketree.o NumberTree.o SVGOut.o&lt;br /&gt;g++ -g -lboost_program_options -o $@ $^&lt;br /&gt;&lt;br /&gt;%.o: %.cc&lt;br /&gt;g++ -O0 -g -I/usr/include/my-boost -Wall -c $&amp;lt;&lt;br /&gt;&lt;br /&gt;clean:&lt;br /&gt;rm *.o&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;NumberTree.cc:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include "NumberTree.hh"&lt;br /&gt;#include &amp;lt;math.h&gt;&lt;br /&gt;#include &amp;lt;boost/foreach.hpp&gt;&lt;br /&gt;#include &amp;lt;sstream&gt;&lt;br /&gt;&lt;br /&gt;using std::ostream;&lt;br /&gt;&lt;br /&gt;NumberTree::NumberTree( long n, int b )&lt;br /&gt;: output_width(800), output_height(600), width(-1), height(-1),&lt;br /&gt;  base(b)&lt;br /&gt;{&lt;br /&gt;while( n ) {&lt;br /&gt;  int hp = find_hipow(n,b);&lt;br /&gt;&lt;br /&gt;  children.push_back( TreePtr(new NumberTree(hp,b)) );&lt;br /&gt;  n -= static_cast&amp;lt;int&gt;(pow(b,hp));&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;NumberTree::BracketPrint( ostream&amp; os ) const&lt;br /&gt;{&lt;br /&gt;os &amp;lt;&amp;lt; "(";&lt;br /&gt;for( unsigned int i=0; i&amp;lt;children.size(); i++ ) {&lt;br /&gt;  children[i]-&gt;BracketPrint(os);&lt;br /&gt;  if(i&amp;lt;children.size()-1)&lt;br /&gt;    os &amp;lt;&amp;lt; ",";&lt;br /&gt;}&lt;br /&gt;os &amp;lt;&amp;lt; ")";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;NumberTree::find_hipow( long n, int b ) const // TESTED&lt;br /&gt;{&lt;br /&gt;if(n &amp;lt; 1 || b &amp;lt; 2)&lt;br /&gt;  throw "Invalid parameters";&lt;br /&gt;return static_cast&amp;lt;int&gt;(floor(log(n)/log(b)));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;long&lt;br /&gt;NumberTree::eval( int b ) const // TESTED&lt;br /&gt;{&lt;br /&gt;long total=0;&lt;br /&gt;&lt;br /&gt;BOOST_FOREACH( const TreePtr&amp; pt, children ) {&lt;br /&gt;  total += static_cast&amp;lt;long&gt;(pow(b, pt-&gt;eval(b)));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return total;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;NumberTree::printSVG( SVGOut&amp; so )&lt;br /&gt;{&lt;br /&gt;so.start();&lt;br /&gt;&lt;br /&gt;std::ostringstream os;&lt;br /&gt;os &amp;lt;&amp;lt; eval(base);&lt;br /&gt;so.annotated_circle(0.5,0,os.str());&lt;br /&gt;printSVGBranches(so,0,1,1,0,0.5,&lt;br /&gt;                 1.0/calcHeight(),1.0/calcWidths());&lt;br /&gt;so.end();&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;NumberTree::calcWidths()&lt;br /&gt;{&lt;br /&gt;if( widths.size() ) return width;&lt;br /&gt;&lt;br /&gt;if(!children.size()) return 0;&lt;br /&gt;&lt;br /&gt;int w = 0;&lt;br /&gt;BOOST_FOREACH( TreePtr&amp; pt, children ) {&lt;br /&gt;  int t = pt-&gt;calcWidths();&lt;br /&gt;  w += t+1;&lt;br /&gt;  widths.push_back(t);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;return width = w-1; // subtract one to lose padding on RHS&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int&lt;br /&gt;NumberTree::calcHeight()&lt;br /&gt;{&lt;br /&gt;if( height != -1 ) return height;&lt;br /&gt;&lt;br /&gt;int max=-1;&lt;br /&gt;BOOST_FOREACH( TreePtr&amp; pt, children ) {&lt;br /&gt;  int th = pt-&gt;calcHeight();&lt;br /&gt;  if(max&amp;lt;th) max = th;&lt;br /&gt;}&lt;br /&gt;return height = max+1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;NumberTree::printSVGBranches( SVGOut&amp; o,&lt;br /&gt;                            float l, float t, float r, float b,&lt;br /&gt;                            float px, float lineheight, float xscale )&lt;br /&gt;{&lt;br /&gt;int lhs = 0;&lt;br /&gt;&lt;br /&gt;BOOST_FOREACH( const TreePtr&amp; pt, children ) {&lt;br /&gt;  int w = pt-&gt;calcWidths();&lt;br /&gt;&lt;br /&gt;  float newmid = lhs + w/2.0;&lt;br /&gt;  if(calcWidths() == 0)&lt;br /&gt;    newmid = 0;&lt;br /&gt;  else&lt;br /&gt;    newmid /= calcWidths();&lt;br /&gt;  newmid *= r-l;&lt;br /&gt;  newmid += l;&lt;br /&gt;&lt;br /&gt;  std::ostringstream os;&lt;br /&gt;  os &amp;lt;&amp;lt; pt-&amp;gt;eval(base);&lt;br /&gt;  o.annotated_circle(newmid, lineheight+b, os.str());&lt;br /&gt;&lt;br /&gt;  o.line(newmid,lineheight+b,px,b);&lt;br /&gt;&lt;br /&gt;  pt-&amp;gt;printSVGBranches(o, l+lhs*xscale, t, l+(lhs+w)*xscale,&lt;br /&gt;                       b+lineheight, newmid, lineheight, xscale );&lt;br /&gt;&lt;br /&gt;  lhs += w+1;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;NumberTree.hh:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#ifndef NUMBERTREE_HH&lt;br /&gt;#define NUMBERTREE_HH&lt;br /&gt;&lt;br /&gt;#include &amp;lt;iostream&gt;&lt;br /&gt;#include &amp;lt;vector&gt;&lt;br /&gt;#include &amp;lt;boost/shared_ptr.hpp&gt;&lt;br /&gt;#include "SVGOut.hh"&lt;br /&gt;&lt;br /&gt;class NumberTree&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;/* Construct tree from n with given base */&lt;br /&gt;NumberTree( long n, int b );&lt;br /&gt;&lt;br /&gt;/* Print as parentheses */&lt;br /&gt;void BracketPrint( std::ostream&amp; os ) const;&lt;br /&gt;&lt;br /&gt;/* Evaluate as powers of b */&lt;br /&gt;long eval( int b ) const;&lt;br /&gt;&lt;br /&gt;/* Output SVG to stream */&lt;br /&gt;void printSVG( SVGOut&amp; so );&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;/* Find the largest power of b that is less than n */&lt;br /&gt;int find_hipow( long n, int b ) const;&lt;br /&gt;/* Find the width in branches of the tree and populate knowledge of&lt;br /&gt; * widths of our immediate children */&lt;br /&gt;int calcWidths();&lt;br /&gt;/* Find the height of the subtree below us */&lt;br /&gt;int calcHeight();&lt;br /&gt;/* Draw our subtree to SVG */&lt;br /&gt;void printSVGBranches( SVGOut&amp; os,&lt;br /&gt;                       float l, float t, float r, float b,&lt;br /&gt;                       float px, float lineheight, float xscale );&lt;br /&gt;&lt;br /&gt;/* Output sizes for SVG */&lt;br /&gt;int output_width, output_height;&lt;br /&gt;&lt;br /&gt;/* The actual important data! */&lt;br /&gt;typedef boost::shared_ptr&amp;lt;NumberTree&gt; TreePtr;&lt;br /&gt;std::vector&amp;lt;TreePtr&gt; children;&lt;br /&gt;&lt;br /&gt;/* Widths for printing */&lt;br /&gt;std::vector&amp;lt;int&amp;gt; widths;&lt;br /&gt;/* Width - must be dirtied to -1 if we change something */&lt;br /&gt;int width;&lt;br /&gt;/* Height - must be dirtied to -1 if we change something */&lt;br /&gt;int height;&lt;br /&gt;&lt;br /&gt;/* Base of expansion */&lt;br /&gt;int base;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;SVGOut.cc:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include "SVGOut.hh"&lt;br /&gt;#include &amp;lt;cmath&gt;&lt;br /&gt;&lt;br /&gt;using std::string;&lt;br /&gt;&lt;br /&gt;SVGOut::SVGOut( std::ostream&amp; os, int width, int height, int margin )&lt;br /&gt;: o(os), top(margin), left(margin), right(width-margin),&lt;br /&gt;  bottom(height-margin), _margin(margin), fill("black"),&lt;br /&gt;  stroke("black")&lt;br /&gt;{&lt;br /&gt;set_circle_radius(0.01);&lt;br /&gt;set_font_size(0.03);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::start()&lt;br /&gt;{&lt;br /&gt;o &amp;lt;&amp;lt; "&amp;lt;?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"no\"?&gt;\n"&lt;br /&gt;  &amp;lt;&amp;lt; "&amp;lt;!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 20010904//EN\"\n"&lt;br /&gt;  &amp;lt;&amp;lt; "\"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\"&gt;\n"&lt;br /&gt;  &amp;lt;&amp;lt; "&amp;lt;svg xmlns=\"http://www.w3.org/2000/svg\"\n"&lt;br /&gt;  &amp;lt;&amp;lt; "     xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"&lt;br /&gt;  &amp;lt;&amp;lt; "     width=\""&lt;br /&gt;  &amp;lt;&amp;lt; static_cast&amp;lt;int&gt;(fabs(right-left) + 2*_margin)&lt;br /&gt;  &amp;lt;&amp;lt; "\" height=\""&lt;br /&gt;  &amp;lt;&amp;lt; static_cast&amp;lt;int&gt;(fabs(top-bottom) + 2*_margin)&lt;br /&gt;  &amp;lt;&amp;lt; "\"&gt;\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::end()&lt;br /&gt;{&lt;br /&gt;o &amp;lt;&amp;lt; "\n&amp;lt;/svg&gt;\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::circle( float x, float y )&lt;br /&gt;{&lt;br /&gt;boost::tuple&amp;lt;float,float&gt; ddpos = xyToSVG(x,y);&lt;br /&gt;&lt;br /&gt;o &amp;lt;&amp;lt; "  &amp;lt;circle cx=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos.get&amp;lt;0&gt;()&lt;br /&gt;  &amp;lt;&amp;lt; "\" cy=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos.get&amp;lt;1&gt;()&lt;br /&gt;  &amp;lt;&amp;lt; "\" r=\"" &amp;lt;&amp;lt; circle_radius &amp;lt;&amp;lt; "\" style=\"stroke: "&lt;br /&gt;  &amp;lt;&amp;lt; stroke &amp;lt;&amp;lt; "; fill: " &amp;lt;&amp;lt; fill &amp;lt;&amp;lt; ";\"/&gt;\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::line( float x1, float y1, float x2, float y2 )&lt;br /&gt;{&lt;br /&gt;boost::tuple&amp;lt;float,float&gt;&lt;br /&gt;  ddpos1 = xyToSVG(x1,y1),&lt;br /&gt;  ddpos2 = xyToSVG(x2,y2);&lt;br /&gt;&lt;br /&gt;o &amp;lt;&amp;lt; "  &amp;lt;line x1=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos1.get&amp;lt;0&gt;() &amp;lt;&amp;lt; "\" y1=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos1.get&amp;lt;1&gt;() &amp;lt;&amp;lt; "\" x2=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos2.get&amp;lt;0&gt;() &amp;lt;&amp;lt; "\" y2=\""&lt;br /&gt;  &amp;lt;&amp;lt; ddpos2.get&amp;lt;1&gt;() &amp;lt;&amp;lt; "\" style=\"stroke: "&lt;br /&gt;  &amp;lt;&amp;lt; stroke &amp;lt;&amp;lt; ";\"/&gt;\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;boost::tuple&amp;lt;float,float&gt;&lt;br /&gt;SVGOut::xyToSVG( float x, float y ) const&lt;br /&gt;{&lt;br /&gt;return&lt;br /&gt;  boost::make_tuple( float( (right-left)*x + left ),&lt;br /&gt;                     float( (top-bottom)*y + bottom ) );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::text( const string&amp; s, float x, float y )&lt;br /&gt;{&lt;br /&gt;boost::tuple&amp;lt;float,float&gt; ddpos = xyToSVG(x,y);&lt;br /&gt;&lt;br /&gt;o &amp;lt;&amp;lt; "  &amp;lt;text x=\"" &amp;lt;&amp;lt; ddpos.get&amp;lt;0&gt;() &amp;lt;&amp;lt; "\" y=\"" &amp;lt;&amp;lt; ddpos.get&amp;lt;1&gt;()&lt;br /&gt;  &amp;lt;&amp;lt; "\" font-family=\"Verdana\" font-size=\""&lt;br /&gt;  &amp;lt;&amp;lt; font_size &amp;lt;&amp;lt; "\" fill=\"black\"&gt;"&lt;br /&gt;  &amp;lt;&amp;lt; s&lt;br /&gt;  &amp;lt;&amp;lt; "&amp;lt;/text&amp;gt;\n";&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::set_fill_colour( const string&amp;amp; colour )&lt;br /&gt;{&lt;br /&gt;fill = colour;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::set_stroke_colour( const string&amp; colour )&lt;br /&gt;{&lt;br /&gt;stroke = colour;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::set_circle_radius( float rad )&lt;br /&gt;{&lt;br /&gt;circle_radius = rad*fabs(right-left);&lt;br /&gt;vanilla_circle_radius = rad;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::set_font_size( float size )&lt;br /&gt;{&lt;br /&gt;font_size = size*fabs(top-bottom);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;void&lt;br /&gt;SVGOut::annotated_circle( float x, float y, const std::string&amp; s )&lt;br /&gt;{&lt;br /&gt;circle(x,y);&lt;br /&gt;text(s, x+vanilla_circle_radius*1.1, y );&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;SVGOut.hh:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#ifndef SVGOUT_HH&lt;br /&gt;#define SVGOUT_HH&lt;br /&gt;&lt;br /&gt;#include &amp;lt;iostream&gt;&lt;br /&gt;#include &amp;lt;string&gt;&lt;br /&gt;#include &amp;lt;boost/tuple/tuple.hpp&gt;&lt;br /&gt;&lt;br /&gt;class SVGOut&lt;br /&gt;{&lt;br /&gt;public:&lt;br /&gt;SVGOut( std::ostream&amp; os, int width, int height, int margin );&lt;br /&gt;&lt;br /&gt;void set_fill_colour( const std::string&amp; colour );&lt;br /&gt;void set_stroke_colour( const std::string&amp; colour );&lt;br /&gt;// rad, size are compared to the [0,1]x[0,1] canvas!&lt;br /&gt;void set_circle_radius( float rad );&lt;br /&gt;void set_font_size( float size );&lt;br /&gt;&lt;br /&gt;void start();&lt;br /&gt;void end();&lt;br /&gt;&lt;br /&gt;/* Element creation functions */&lt;br /&gt;void circle( float x, float y );&lt;br /&gt;void line( float x1, float y1, float x2, float y2 );&lt;br /&gt;void text( const std::string&amp; s, float x, float y );&lt;br /&gt;void annotated_circle( float x, float y, const std::string&amp; s );&lt;br /&gt;&lt;br /&gt;private:&lt;br /&gt;boost::tuple&amp;lt;float,float&amp;gt; xyToSVG( float x, float y ) const;&lt;br /&gt;&lt;br /&gt;/* Output stream ref */&lt;br /&gt;std::ostream&amp;amp; o;&lt;br /&gt;/* Input sizes */&lt;br /&gt;float top,left,right,bottom;&lt;br /&gt;float _margin;&lt;br /&gt;/* Colours */&lt;br /&gt;std::string fill, stroke;&lt;br /&gt;&lt;br /&gt;/* Other settings: Only change throught set_ functions */&lt;br /&gt;float circle_radius, font_size;&lt;br /&gt;float vanilla_circle_radius;&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;#endif&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;maketree.cc:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;#include &amp;lt;iostream&gt;&lt;br /&gt;#include &amp;lt;string&gt;&lt;br /&gt;#include &amp;lt;errno.h&gt;&lt;br /&gt;#include &amp;lt;boost/program_options.hpp&gt;&lt;br /&gt;#include &amp;lt;fstream&gt;&lt;br /&gt;#include "NumberTree.hh"&lt;br /&gt;#include "SVGOut.hh"&lt;br /&gt;&lt;br /&gt;void usage()&lt;br /&gt;{&lt;br /&gt;std::cerr &amp;lt;&amp;lt; "I need exactly 1 argument, which is a number.\n";&lt;br /&gt;exit(1);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;int main( int argc, char* argv[] )&lt;br /&gt;{&lt;br /&gt;using std::string;&lt;br /&gt;&lt;br /&gt;namespace po = boost::program_options;&lt;br /&gt;po::options_description standard("Options");&lt;br /&gt;standard.add_options()&lt;br /&gt;  ("help", "produce help message")&lt;br /&gt;  ("base,b", po::value&amp;lt;unsigned int&gt;()-&gt;default_value(2), "set base of expansion")&lt;br /&gt;  ("stroke,s", po::value&amp;lt;string&gt;()-&gt;default_value("black"), "set colour of stroke")&lt;br /&gt;  ("fill,f", po::value&amp;lt;string&gt;()-&gt;default_value("red"), "set colour of fill")&lt;br /&gt;  ("width,w", po::value&amp;lt;unsigned int&gt;()-&gt;default_value(800), "width of image")&lt;br /&gt;  ("height,h", po::value&amp;lt;unsigned int&gt;()-&gt;default_value(600), "height of image")&lt;br /&gt;  ("output,o", po::value&amp;lt;string&gt;()-&gt;default_value("-"), "Output file")&lt;br /&gt;  ;&lt;br /&gt;&lt;br /&gt;po::options_description hidden("Options");&lt;br /&gt;hidden.add_options()&lt;br /&gt;  ("number", po::value&amp;lt;unsigned long int&gt;(), "number to be represented");&lt;br /&gt;&lt;br /&gt;po::options_description all("Options");&lt;br /&gt;all.add(standard).add(hidden);&lt;br /&gt;&lt;br /&gt;po::positional_options_description pos;&lt;br /&gt;pos.add("number", 1);&lt;br /&gt;&lt;br /&gt;po::variables_map vm;&lt;br /&gt;po::store(po::command_line_parser(argc, argv).&lt;br /&gt;          options(all).positional(pos).run(), vm);&lt;br /&gt;po::notify(vm);&lt;br /&gt;&lt;br /&gt;if (vm.count("help")) {&lt;br /&gt;  std::cerr &amp;lt;&amp;lt; standard &amp;lt;&amp;lt; "\n";&lt;br /&gt;  return 1;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;string output = vm["output"].as&amp;lt;string&gt;();&lt;br /&gt;&lt;br /&gt;std::ostream* os;&lt;br /&gt;if( output == "-" ) os = &amp;std::cout;&lt;br /&gt;else {&lt;br /&gt;  os = new std::ofstream(output.c_str());&lt;br /&gt;  if(!os) {&lt;br /&gt;    std::cerr &amp;lt;&amp;lt; "Could not open output file.";&lt;br /&gt;    return 1;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if (vm.count("number")) {&lt;br /&gt;  NumberTree tree(vm["number"].as&amp;lt;unsigned long int&gt;(),&lt;br /&gt;                  vm["base"].as&amp;lt;unsigned int&gt;() );&lt;br /&gt;  SVGOut sout(*os,&lt;br /&gt;              vm["width"].as&amp;lt;unsigned int&gt;(),&lt;br /&gt;              vm["height"].as&amp;lt;unsigned int&gt;(),&lt;br /&gt;              30);&lt;br /&gt;&lt;br /&gt;  sout.set_fill_colour( vm["fill"].as&amp;lt;string&gt;() );&lt;br /&gt;  sout.set_stroke_colour( vm["stroke"].as&amp;lt;string&amp;gt;() );&lt;br /&gt;&lt;br /&gt;  tree.printSVG(sout);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if( output != "-" ) delete os;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;hints id="hah_hints"&gt;&lt;/hints&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-501713154230057546?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/501713154230057546/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=501713154230057546' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/501713154230057546'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/501713154230057546'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/03/tree-display-program.html' title='Tree display program'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_oGJy63klAL8/Rg16KVJ4f1I/AAAAAAAAAAM/1uBCgSL3XFs/s72-c/93-2.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3504720297030477076.post-3233266127045039210</id><published>2007-03-30T12:42:00.000-07:00</published><updated>2007-03-30T18:52:55.465-07:00</updated><title type='text'>Latex in Posts</title><content type='html'>So the question is whether &lt;img src="http://www.forkosh.dreamhost.com/mimetex.cgi?%5CLaTeX" align="middle" border="0" /&gt; as posted &lt;a href="http://wolverinex02.googlepages.com/emoticonsforblogger2"&gt;here&lt;/a&gt; will actually work. OK. So I'm impressed :)&lt;br /&gt;&lt;br /&gt;&lt;hints id="hah_hints"&gt;&lt;/hints&gt;&lt;br /&gt;Now can it work with ScribeFire? I fear not...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3504720297030477076-3233266127045039210?l=mathematicalmusings.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mathematicalmusings.blogspot.com/feeds/3233266127045039210/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3504720297030477076&amp;postID=3233266127045039210' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/3233266127045039210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3504720297030477076/posts/default/3233266127045039210'/><link rel='alternate' type='text/html' href='http://mathematicalmusings.blogspot.com/2007/03/so-question-is-whether-as-posted-here.html' title='Latex in Posts'/><author><name>Rupert</name><uri>http://www.blogger.com/profile/18135861636036170742</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='22' height='32' src='http://2.bp.blogspot.com/_oGJy63klAL8/TCuxnPgknlI/AAAAAAAAACs/NCi90vlNGjU/S220/.avatar.jpg'/></author><thr:total>0</thr:total></entry></feed>
