Why are elementwise additions much faster in separate loops than in a combined loop?

Suppose a1, b1, c1, and d1 point to heap memory and my numerical code has the following core loop.

This loop is executed 10,000 times via another outer for loop. To speed it up, I changed the code to: […]

Why is it faster to process a sorted array than an unsorted array?

Here is a piece of C++ code that seems very peculiar. For some strange reason, sorting the data miraculously makes the code almost six times faster.

Without std::sort(data, data + arraySize);, the code runs in 11.54 seconds. With the […]

What is the “–>” operator in C++?

After reading Hidden Features and Dark Corners of C++/STL on comp.lang.c++.moderated, I was completely surprised that the following snippet compiled and worked in both Visual Studio 2008 and G++ 4.4. Here’s the code:

I’d assume this is C, since […]