(Start at the beginning of the series – and all the source can be found in my github repo) So FNV1 was easy, and Murmur3 wasn’t too much harder; for a challenge and to see how far I could go, I decided to try to compute an MD5 string hash using C++11 constexpr. This was… Continue reading More string hashing with C++11 constexpr

# Category: C++

## C++11 compile-time string hashing

(Start at the beginning of the series – and all the source can be found in my github repo) Now that I was used to writing C++11-style constexpr, I decided to try some compile-time string hashing. It turns out that FNV1 is very easy to express in a move-down-the-string recursive style: namespace detail { constexpr… Continue reading C++11 compile-time string hashing

## More constexpr floating-point computation

(Start at the beginning of the series – and all the source can be found in my github repo) In the last post, I covered my first forays into writing C++11-style constexpr floating point math functions. Once I’d done some trig functions, exp, and floor and friends, it seemed like the rest would be a… Continue reading More constexpr floating-point computation

## Floating-point maths, constexpr style

(Start at the beginning of the series – and all the source can be found in my github repo) To ease into constexpr programming I decided to tackle some floating-point maths functions. Disclaimer: I’m not a mathematician and this code has not been rigorously tested for numeric stability or convergence in general. I wrote it… Continue reading Floating-point maths, constexpr style

## Experimenting with constexpr

Since seeing Scott Schurr at C++Now in Aspen and hearing his talks about constexpr, it’s been on my list of things to try out, and recently I got around to it. With the release of Visual Studio 2015, Microsoft’s compiler now finally supports C++11 style constexpr (modulo some minor issues), so it’s a good time… Continue reading Experimenting with constexpr

## CppCon 2015

CppCon 2015 is over and I’m home from Bellevue. It was a really great week; I learned a lot, talked to lots of interesting folks, and traded C++ tips and techniques with the cognoscenti. Having been to C++Now, I knew a bunch of people already, which was a good leg-up on socializing during the conference.… Continue reading CppCon 2015

## Exercising Ranges (part 8)

(Start at the beginning of the series if you want more context.) Extras from the Haskell Prelude Having implemented iterate, there were a couple of other useful things from the Haskell Prelude that I wanted to have available with ranges. First, there’s cycle. It simply takes a finite range and repeats it ad infinitum. The… Continue reading Exercising Ranges (part 8)

## Exercising Ranges (part 7)

(Start at the beginning of the series if you want more context.) Calculus operations It’s relatively simple to do differentiation and integration of power series, since they’re just regular polynomial-style. No trigonometric identities, logarithms or other tricky integrals here. Just the plain rule for positive powers of x. For differentiation, we have: [latex]\frac{d}{dx}kx^{n} = knx^{n-1}[/latex]… Continue reading Exercising Ranges (part 7)

## Exercising Ranges (part 6)

(Start at the beginning of the series if you want more context.) Multiplying power series Now we come to something that took considerable thought: how to multiply ranges. Doug McIlroy’s Haskell version of range multiplication is succinct, lazily evaluated and recursive. (f:ft) * gs@(g:gt) = f*g : ft*gs + series(f)*gt Which is to say, mathematically,… Continue reading Exercising Ranges (part 6)

## Exercising Ranges (part 5)

(Start at the beginning of the series if you want more context.) Generalising iota To pretty-print a reversible polynomial, we need to provide for reversibility of iota. So what is iota? It makes a range by repeatedly incrementing a value. What if instead of increment, we use an arbitrary function? We could do this with… Continue reading Exercising Ranges (part 5)