» software » libquat » libquat


Libquat is a GPLed iteration library for functions of complex and quaternion variables. Its main features are a flex/bison parser supporting a wide range of functions at runtime, and dynamic compilation of these functions for efficient iteration.
Libquat is the engine behind most of what you see here at In addition I have brutally hacked XaoS to use libquat as well.
Libquat is written in C++, and has a C interface as well. To compile libquat you'll need flex/bison or lex/yacc and a working c++ setup.
For the adventurous and the brave, you can download the latest CVS snapshot. If you would like a possibly more recent copy, we now have anon cvs as well. It works fine for me under linux, and should (in theory) compile on any *NIX platform. Maybe even some others as well. Who knows?


Quaternion / complex iteration
Many different functions can be iterated. Libquat supports quaternion, complex, and scalar functions. This means that in addition to the standard complex fractal types (julia/mandelbrot), non analytic functions can be iterated as well. A good example is the burning ship. Equations like this don't satisfy Cauchy-Riemann and hence can't be thought of as maps on the complex plane. Instead they map R2 to R2. Or if you like, you can also map R4 to R4. More direct support for such maps in planned.

Runtime function parser

I have written a description of the syntax and grammar. It has been implemented with flex and bison.

Constant folding

Wherever it can, libquat does its best to fold any constants together. This means that it will take an expression like e^(i*pi/2) and fold it down to i before iterating the function.

Common subexpression elimination.

Faced with a function such as z^2/(z^2+1), libquat will only compute z^2 once.

Dynamic compilation

Given an expression, libquat can generate C code to iterate that expression for you. It then proceeds to compile the code and load it as a shared library, all on the fly. The resulting code is generally about twice as fast as the interpreted version. For most applications this more than makes up for the overhead of generating, compiling, and loading the optimized code.

Future Plans

More operators
More trancendental functions, such as the inverse trig functions, as well as logarithms.
Fractional exponents of complex numbers and quaternions are also planned. This will allow for square roots and the like.
Negative exponents are also not handled, but it would be trivial to do so given the current state of affairs.
Also complex to complex powers and quaternion to quaternion powers would be nice. The math gets rather hairy and I haven't bothered to figure it out yet.

Periodicity checking

Detecting periodic orbits early on could speed things considerably when dealing with certain sets.

Better error handling

Libquat currently doesn't handle errors in a robust manner. Some sort of callback mechanism would be nice.

Known Problems

[a b] does not seem to be functioning properly.

log is broken, as is tan and tanh

Previous iterates (q_(n-2)) are not implemented in the compiled version.

Last modified: Fri Jan 22 20:57:20 UTC 1999