Closed for Summer (2016)

April 26, 2016

It’s that time again. The semester’s almost over, only a few assignments and exams to mark; everybody’s busy at their own stuff. Like the last few summers, I’ll kind of close the blog until September. I said “kind of” because maybe I’ll post a few things anyway. Especially that this summer will be interesting: more time for research, 7ECM, which I will attend, and a few other things. Seeya in September!

(RGB II, 2560×1440)

(RGB II, 2560×1440)


Respace

April 19, 2016

The two seemingly trivial and unimportant problems of what kind of whitespaces and how to use them are still not solved. Some still use hard-coded tabs in their source code, and because they set tabs to be two spaces wide in their favorite editor, they expect the rest of the planet to have done so. The result is that spacing will break in another person’s editor, and the code will look like it’s been written by a four years old. Also, when tabs and spaces are mixed, and randomly interpreted, the indentation, the general aspect of how the code is presented, is broken.

turbo-napkin

While marking assignments, I encountered a number of such pieces of code. So I decided to fix that with a simple Emacs command.

Read the rest of this entry »


Le café des sciences

April 12, 2016

This week, as you might have guessed, was pretty busy as the semester is coming to a close. Among many things, I prepared lecture notes, marked assignments, and all that, but I also got to launch the café des sciences de l’UQAR.

science

A university is a place where we are supposed to transmit knowledge, but more importantly transmit a love of knowledge and keep alive the joy of discovery. The café des sciences is about that transmission: once a month a guest comes to talk about what his point of view on science is, what research he (or she) is conducting, and everybody is invited. Not only professors. Not only students. Everyone. That’s why the café des sciences will not always be held within the university walls, but will visit café in the general Rimouski area.

You can read more about the café des sciences here. You’re all invited!

You can follow us on twitter at https://twitter.com/CafeScienceUQAR


Making a good random table

April 5, 2016

I am still experimenting with hash functions, and I was toying with the Zobrist hash function[1] that is best known for its use in chess engines. The hash function is conceptually simple: you need a large table of random numbers, indexed, in a chess application, by the position on the board of the piece and by the piece itself. To compute a hash for a whole board configuration, you simply xor all the random numbers together. The hard part is choosing the random numbers.

IMG_0405-small

Read the rest of this entry »


Storage size from bits

March 29, 2016

Last week, we had a look at the computation of Log2 using templates and constexpr. Of course, I had ulterior motives. In particular, I was interested in allocating just the right number of bits for a field in a bit field, but rather than hard-coding it, having it deduced from a template argument. Let’s see how we can do that.

Read the rest of this entry »


Log2 (with C++ metaprogramming)

March 22, 2016

C++ meta-programming a powerful tool. Not only can you use it to build generic types (such as the STL’s std::list), you can also use it to have compile-time evaluation. Let’s have a look at a simple problem that can be solved in two very different ways: computing the Log base 2 of an integer.

Read the rest of this entry »


Sums of powers

March 15, 2016

When you’re studying algorithms, there is a number of series and expression that keep showing up. A while ago, I discussed the special form \sum_{i=1}^n i a^i. But that’s not the only one. Another form that keeps showing up is

\displaystyle s_k(n)=\sum_{i=1}^n i^k.

We can look the particular form this sum takes for specific k in some compendium (like CRC’s tables and formulae, that have seen 30-something editions over the last half century), or… you can find the formula yourself. It’s a bit tedious, but not that complicated.

Read the rest of this entry »


Follow

Get every new post delivered to your Inbox.

Join 109 other followers