Pairing Functions

27/09/2011

Sometimes you have to encode reversibly two (or more) values onto a single one. The typical example of a pairing function that encodes two non-negative integers onto a single non-negative integer (therefore a function f:\mathbb{Z}^*\times\mathbb{Z}^*\to\mathbb{Z}^*) is the Cantor function, instrumental to the demonstration that, for example, the rational can be mapped onto the integers.

In a more pragmatic way, it may be necessary to encode two values onto one for data compression purposes, or to otherwise exploit a protocol that does not allow many distinct values to be sent separately. The simplest way of pairing two integer is to interleave their bits, for example, with something like:

Read the rest of this entry »


Wallpaper: Karlův Most, 5h05

22/09/2011

(Karlův Most, 5h05, 1920×1200)

You can find more wallpapers here


Wallpaper: Mes ennemis

22/09/2011

(Mes ennemis, 1920×1200)

You can find more wallpapers here


Wallpaper: Une autre gare, un autre voyage

22/09/2011

(Une autre gare, un autre voyage, 1920×1200)

You can find more wallpapers here


Wallpaper: NY

22/09/2011

(NY, 1920×1200)

You can find more wallpapers here


Wallpaper: Time²

22/09/2011

(Time², 1920×1200)

You can find more wallpapers here


Wallpaper: Karlův Most, 4h55

22/09/2011

(Karlův Most, 4h55, 1920×1200)

You can find more wallpapers here


Wallpaper: Karlův Most, 6h15

22/09/2011

(Karlův Most, 6h15, 1920×1200)

You can find more wallpapers here


Wallpaper: Les jardins du roi

22/09/2011

(Les jardins du roi, 1920×1200)

You can find more wallpapers here


Learning Python (II)

20/09/2011

One thing I really like about Python is how it makes manipulating lists quite easily, especially via slices and list comprehensions. List comprehensions, especially in generator notation form, are an easy way to create lists with specific content. Other functional programming languages (such as Mathematica, amongst others) have taught me to use “map” to transform lists. But is it always the clearest and fastest way?


Read the rest of this entry »