Posts Tagged “programming”

I got the following error when trying to compile the latest svn version of opencv:

error: invalid controlling predicate

A quick Google search yielded this gem of a compiler bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38650.

The offending loop:

#ifdef _OPENMP
#pragma omp for schedule(static, 1)
#endif /* _OPENMP */
for( i = first; (i < first + count) && next; i++ )

That is all.

UPDATE: Turns out I was using a stale configuration file from svn for this build. It seems like OpenCV has entirely too many build systems. They should ditch autoconf and go with cmake exclusively.

Comments No Comments »

In response to a recent Coding Horror piece on Spartan programming I’d like to humbly submit two examples from my own recent work.

First, in C++ we have:

for (int i = 0; i < nstates; i++) {
    for (int a = 0; a < nactions; a++) {
        Q[i][a] += alpha * delta * e[i][a];
        e[i][a] *= gamma * lambda;
    }
}

Next, in Python with Numpy:

self.Q += self.alpha * delta * self.e
self.e *= self.gamma * self.ld

These are identical temporal difference updates in two versions of a Sarsa reinforcement learning agent. Having reasonable syntax and semantics for vector and matrix operations is essential for sparse programming in any kind of numerically intensive setting.

Comments No Comments »