jonny goes to england

London & co

Archive for December 2008

A Fresh Start in the Alps

leave a comment »

Recently, when I was flipping through NewScientist, I found an article about Switzerland and how great a place it is for UK scientists. That’s great news. The article first describes a few popular places to go to: IBM research in Rueschlikon (not sure how I would feel in Rueschlikon though. The sound alone invokes one or the other unpleasant reflexes). Nevertheless, IBM has interesting research going on there. Next in the list is of course ETH/EPFL which naturally come up when you speak about Switzerland and science. Third is CERN and its LHC-fame.

Lastly, the article describes a British PhD student puzzled by his high salary at IBM. Looking at the salaries in academia in UK I’m sure he earned as much as his professor back in England.

Anyway, it’s nice to know my home country is a somewhat safe fallback option or so.

Advertisements

Written by jk

December 25, 2008 at 10:36 am

Posted in english, Switzerland, UK

Pics of the week

leave a comment »

Daily Routine, an announcement at some tube station:

A pretty disgusting poster informing pedestrians that when they puke in public over the festive season they will be fined £80 (if caught)! What you see is a pint glass filled with vomit.

That said, I’m now on my way to the airport ..

Written by jk

December 21, 2008 at 3:05 pm

Posted in english, London, UK

[Picture] East End

leave a comment »

img00047

Written by jk

December 18, 2008 at 9:39 am

Posted in London, UK

Xmas move & Xmas flight

with one comment

Ok, so finally I moved again! From my old new place to my new new place. It’s smaller but warmer, more modern and I like it a lot. I made some pics when I packed up everything, then I realised that I don’t really have that much stuff!
Here’s pretty much everything:
img00050

img00051

Here’s the comparison picture from September 2007. I can’t believe this is only a little bit more than a year ago. Seems like a century lies in between.

I couldn’t really make any good pictures of the new place for some reason. Here’s one. The kitchen is actually quite large, but hidden behind the walls.

img00056

Aaanyway, I hope you won’t hear any moving stories for at least 6 months!
In other news, I fly back home to Switzerland this Sunday, 21st December for 2-3 weeks. Looking forward to that.

Written by jk

December 16, 2008 at 11:38 am

Posted in english, London, Travel

Loop unrolling

with 2 comments

Today something a bit technical once again. Only suitable for people knowing something of ML etc.

In compilers, semantics and program analysis it’s sometimes handy or needed to transform loops into nested if’s. Perhaps for efficiency reasons, for precision of some invariant detection, or perhaps to know the meaning of a loop up to some defined iteration.

Unrolling a loop twice consists of the transformation from

while(B) { C; }

to the following nested if statements:

if(B) { C; if (B) { C; while(B) { C; } } }

Recently, I thought about how to do that (more or less) elegantly given an abstract syntax tree of the loop. Here my approach in Ocaml. First, we start with a simple language of only boolean expressions and some commands.

type bexp = Random
and cmd =
  Skip
  |Assign
  |Seq of cmd list
  |If of bexp * cmd * cmd
  |While of bexp * cmd

We have a boolean expression Random and the usual commands cmd: Skip, Assignments, Sequences, If, and While constructs. Let’s define a simple loop:

let loop1 = While(Random, Assign)

Which corresponds to something like while(Random) { Assign; }. Obviously, the commands and boolean expressions are not really useful, but that’s just for demonstration purposes — it could easily be replaced with real AST constructs.

Next, let’s write out how we would like to have the first unrolling look like:

let unrolled1 = If(Random, Seq [Assign; loop1], Skip)

Which corresponds to something like if(Random) { Assign; While(Random) { Assign; } else { Skip; }. All we did is taking the body of the loop, wrapping it in an if, given the guard of the body, and concatenating the whole loop to the then-branch.

How do the second and third unrolling look like?

let unrolled2 = If(Random, Seq [Assign;
If(Random, Seq [Assign; loop1], Skip)], Skip)

let unrolled3 = If(Random, Seq [Assign;
If(Random, Seq [Assign;
If(Random, Seq [Assign; loop1], Skip)], Skip)], Skip)

Ok, we see a very repetitive structure (obviously!). Let’s try to write some functions which solve our problem.

The first pattern we see is the following: If(GUARD, Seq[ BODY; REMAINING] , Skip). Basically, we can generalise the stuff written in capitals with arguments of a function:

let buildIfSkip guard body remain = If(guard, Seq[body; remain], Skip)

Given the body and guard of loop1 we could now curry buildIfSkip as follows:

let doRemain = buildIfSkip Random Assign

The function doRemain has only one argument which defines what gets put in REMAINING.

That’s already it, almost! The first unrolling we get by:

doRemain (doRemain loop1)

which produces

If (True, Seq [Assign; If (True, Seq [Assign; While (True, Assign)], Skip)], Skip)

All which is needed now is a function which parametrises all of this. It needs to do the following:

  • Take a loop, get the guard and the body of it
  • Produce the function doRemain as shown above
  • recursively apply doRemain to itself

Here’s the complete function:

let unroll loop n =
   let guard,body = match loop with
     |While(guard,body) -> guard,body
     |_ -> raise Not_found in
   let buildIfSkip guard body remain = If(guard, Seq[body; remain], Skip) in
   let doRemain = buildIfSkip guard body in
   let iterate n f v =
      let rec iter v = function
        0  -> v
        |n -> iter (f v) (n-1) in
      iter v n in
   iterate n doRemain loop

To check we can do the following:

# unroll loop1 3 = unrolled3;;
- : bool = true
#

Feel free to use the code 🙂

Written by jk

December 11, 2008 at 10:57 pm

Posted in english, technical

Tender Talk on The Tube

with one comment

Talk on the Tube is a forum for Londoners who saw someone on the Tube they liked but didn’t dare/had the courage to talk her/him. People usually don’t talk to strangers on the tube. It’s quite a strange phenomena. You sit opposite to each other and constantly invent new methods to avoid eye contact with your neighbours. Popular ones are: reading the news paper, reading the advertisement, reading the tube map, watching to the left or right side, staring down or up, sleeping, ipodding, reading a book, see-through zombie gaze, or just generally looking angry.

Here’s an example message:

Message: You sat next to me at Waterloo Station while we waited for the northbound train. We got on together, and you started reading Sacred Games by Vikdram Chandra. I read a book on my PDA. You looked intelligent and gorgeous

No wonder London is full of singles 🙂

By the way, if you look closely, it’s snowing on my blog. The only thing which would make my life complete now is when market guys outside my window would stop the Love Me Tender endless loop.

Written by jk

December 7, 2008 at 12:43 pm

Posted in english, London, UK

Host Blog or Not?

with one comment

I’m wondering whether I should move my blog to a real hosting provider. This would probably also mean running it from a non *.wordpress.com domain.  I have a steady, but still small, stream of visitors everyday and I’m sure I could get (much?) more visitors by running it from a place where I could configure and optimise the page more. Let me write down the pros and cons I can come up with right now

Pros

  • Page can be better configured with cool WP plugins, better “optimised” for search engines, general look&feel improvements
  • I could run (non-intrusive) AdSense on the page and perhaps get some money. However, to make this mildly “profitable” in anyway I would need to get at the very least a tenfold increase in traffic..

Cons

  • Have to care about the actual hosting stuff which I really don’t enjoy anymore. I don’t really want to setup and upgrade wordpress nor care about a database or so.

So, in case you have experience in moving your blog to your own domain and getting it hosted then I’d like to hear from you..Is it worth it?

Written by jk

December 4, 2008 at 9:47 am

Posted in english