Category Archives: Programming

Faster waterlines with OpenMP

This example has three times more fibers, and thus also CL-points, than the original one, but it still runs in a reasonable time of ~15s because (1) I hard-coded the matrix-determinant expressions everywhere instead of relying on a slow general purpose function and (2) the batch-processing of the fibers now uses OpenMP in order to [...]

Radians vs. DiamondAngle

Over at Freesteel, Julian talks about using a “DiamondAngle” in the interval [0,4] for representing a plane angle instead of the usual radian in [0,2PI]. The argument is that using diangles there is an exact floating-point number for north/south/east/west, and that conversion to/from diangles is faster because it doesn’t involve calling trigonometric functions. I did [...]

Matrix determinant with Boost::uBLAS

Boost uBLAS provides BLAS functionality, but doesn’t have a function for computing the determinant of a matrix. Googling for this turns up a few code snippets, but it’s best to document this completely here now since I got it to work, and it will be useful for opencamlib sooner or later. 1 2 3 4 [...]

VTK test

Tried to make the code from last time a bit clearer by splitting it into two files: vtkscreen.py and test2.py conversion to video again by first converting PNG to JPEG: mogrify -format jpg -quality 97 *.png And then encoding JPEGs into a movie: mencoder mf://*.jpg -mf fps=25:type=jpg -ovc lavc -lavcopts vcodec=mpeg4 -ac copy -o output.avi [...]

OpenMP test on i7

Here’s a simple piece of c-code (try zipped version) for testing how to parallelize code with OpenMP. It compiles with gcc -fopenmp -lm otest.c The CPU-load while running looks like this: Looks like two logical CPUs never get used (two low lines beyond “5″ in the chart). It outputs some timing information: running with 1 threads: [...]

More pystones with shedskin

As I’m very much an amateur programmer with not too much time to learn new stuff I’ve decided my CAM-algorithms are going to be written in Python (don’t hold your breath, they’ll be online when they’ll be online…). The benefits of rapid development will more than outweigh the performance issues of Python at this stage. [...]

multiprocessing pystone benchmark

A simple pystone benchmark using the python multiprocessing package. Seems to scale quite well – guess how many cores my machine has! ” Simple multiprocessing test.pystones benchmark ” ” Anders Wallin 2008Jun15 anders.e.e.wallin (at) gmail.com ” from test import pystone import processing import time STONES_PER_PROCESS= 10*pystone.LOOPS def f(q): t=pystone.pystones(STONES_PER_PROCESS) q.put(t,block=True) if __name__ == ‘__main__’: print [...]