Skip to content

Paper shelf

Blitz++ arrays

A short companion to the Blitz++ arrays paper. The paper is a foundational example of how C++ templates can produce fast numerical code without the abstraction tax that array libraries usually pay.

A printed paper labelled Blitz arrays next to a numerical loop diagram

What the paper is

The Blitz++ arrays paper is the early write-up of a C++ array library that uses template metaprogramming to produce fast numerical code. The library was novel at the time because it gave you array expression syntax that compiled down to loops as efficient as hand-written C.

The file is at /ubigraph/content/Papers/pdf/BlitzArrays.pdf.

What problem it solved

Numerical libraries in C++ before Blitz++ had a recurring problem. The natural expression syntax - c = a + b for arrays - produced temporary objects at every step of an expression. A long expression like d = a + b + c produced two temporaries and three loops where a hand-written version produced one loop and no temporaries.

The cost of those temporaries showed up as runtime overhead. The cost of the loops showed up as cache pressure. Together they made the natural syntax noticeably slower than the equivalent C code.

Blitz++ used template metaprogramming to produce, at compile time, a single tight loop for an entire array expression. The natural syntax stayed. The temporaries went away. The performance matched hand-written C.

Why it matters now

The specific techniques in the Blitz++ paper are now part of the standard repertoire of C++ library design. Expression templates appear in most serious C++ numerical libraries. The trick is no longer surprising.

The paper is still worth reading because it is the worked example. The motivation is presented clearly. The technique is presented clearly. The performance results are presented clearly. As an introduction to what compile-time work can buy you, it remains one of the better starting points.

How it connects to graph tooling

The most obvious connection is that a graph viewer is, at its core, a numerical simulation. The inner loop of a force-directed layout computes forces between vertices. The performance of that loop determines how many vertices the viewer can handle.

The Blitz++ techniques apply directly to that loop. An array of vertex positions, an array of vertex velocities, an array of forces - these are exactly the kind of data the paper is about. A graph viewer built on the same techniques can handle more vertices at higher frame rates than one built on naive C++ array classes.

The C++ template papers and graph tools lab note goes into this connection in more detail.

What the paper does not cover

The paper is about array operations, not graph operations. It does not discuss layout algorithms, force computations specific to graphs, or any of the other things a graph viewer needs.

It also does not cover the design of a viewer’s API. The streaming model that the original Ubigraph viewer uses is a different kind of design problem and is not what the paper is about.

If you came to this page looking for graph algorithm material, the demos index and the random graph layout note are the right places.

A note on authorship

The file at the original path is referenced under the historical Ubigraph distribution. The exact provenance of any copy of the PDF requires individual verification before any claim can be made about authorship or version. This site does not present the file as a certified original until that check has been completed.

Where to go from here