ChaosPro Home
Introduction
What's New
Palettes
Using Formulas
Layering in ChaosPro
Rendering
Fractal Parameter Windows
Windows
Menu
3D Transformations
Animations
Formula Compiler
Writing Formulas
Language Reference
Introduction
Basic Syntax
Datatypes
Constants
Variables
Expressions
Operators
Functions
Control Structures
Compiler Directives
Functions
Interface to ChaosPro
Special Features, Notes...
Alpha Channel
Hints and Tips
Compatibility
Fractal Type Reference
Tutorials
Appendix
CHAOSPRO 4.0
Release 4.0
.

Hints

Optimizations


ChaosPro tries to do some optimizations. Despite the optimizations done by ChaosPro you should try to help ChaosPro and write fast formulas. The optimizations in ChaosPro can be applied in only a few cases. Only the formula writer himself knows the exact meaning of the formula, knows when an expression is constant.

Optimizations done by ChaosPro include:

  • modifying your expressions so that the FPU is used more efficiently. That means a*sin(c) will be transformed into sin(c)*a. Why is sin(c)*a faster? Well, what happens if you calculate a*sin(c)? At first a gets fetched into the internal registers. After that c gets fetched. Then the program recognizes that the sine of c should be calculated. The Intel-Pentium FPU has only 8 registers. Now 4 registers are already used: two by a and two by c. In order to calculate sin(c) the routines need 5 registers. Thus a must be unloaded, sin(c) calculated, a loaded and then the multiplication can be done.
    But if the expression is sin(c)*a, then c gets fetched into the internal registers. The sine of c can be calculated, because 6 registers are free. After having calculated sin(c) only two registers are blocked (by sin(c), i.e. the result only). a can be fetched without problem, and the result can be multiplicated. As a general rule: Operators get exchanged so the most expensive operations are done at first.
  • elimitating constant expressions: If ChaosPro detects constant expressions, it will evaluate them and place the result at the correct location. So you can write rad=deg*(pi/180). ChaosPro will evaluate pi/180 as a constant and rewrite it to rad=deg*0.01745329251. Even if you assign a constant value to a variable and the variable does not change, ChaosPro will detect this and assume that the variable is constant. And again, it will rewrite all operations which use this variable...
    By default, parameters are assumed to be constant!
  • if-statements based on constant expressions (parameters are constant!) are completely eliminated: The formula gets rewritten on the fly (you won’t notice anything). That means you can do as many if-constructs as you like as long as the if-expressions are constant and can be evaluated at the beginning of the fractal calculation process. These if-statements won’t slow down the calculation in any way.

Writing to parameters


Writing to parameters basically is allowed. But in order to support elimitating if-constructs you should not write to parameters because then they are no constants any more. So please make sure you know what you do.

New: Writing to parameters also affects the parameter window! If a formula changes the value of a parameter, then the parameter window will reflect that change and display the new value as soon as the fractal has been calculated. This feature is used by the flame fractal formula: It has two modes: Either you enter dozends of parameters manually or you select the "random" mode, in which all parameters are set to some random values. And if you like the result, you can switch to manual mode and see the random parameters from the previous round and start tweaking these parameters.

Parameters get initialized at the very beginning. So changing a parameter assigns a new value for all subsequent pixels! That means, parameters do not get initialized at the beginning of each pixel iteration, only at the very beginning of the fractal calculation!

By the way: ChaosPro automatically recognizes that you write to a parameter and internally declares it as non-constant.

Illegal Operations


Many functions only provide results if the input parameter lies in a correct range (the definition range). If the input parameter does not lie in the definition area then the result is unpredictable. Please do not rely on such values as it may change in future.

If during the calculation of a fractal image such an exception occurs (division by zero, NaN's, infinity, sqrt(-1), etc.), then ChaosPro will detect this. At the end of the calculation a message will be added to the message window containing the number of pixels which may be wrong because they rely on FPU exceptions.

Infinite Loops


Plase take particular notice to infinite loops: ChaosPro does not recognize them. If you produce an infinite loop then ChaosPro is blocked and you have to kill it. Perhaps future versions will allow you to continue.

Variable conflicts


Perhaps you may ask what happens if a transformation, an iteration formula and the coloring formulas all have the same variable declared?

Well, each formula has its own workspace for local variables and parameters. That means if each formula has a variable b defined, then all these same-named variables are different and do not interfer in any way.

Iteration formulas and coloring formulas share the workspace of the predefined variables. So if you assign a new value to a predefined variable, the new value is valid for the other formulas as well. And due to that you can read/write to z in the loop function of the iteration formula and read/write to z in the loop function of a coloring algorithm and ... they interfer ! You could use any other predefined variable to exchange data between the formula section and the coloring section, but that would be really bad code. And additionally most of the predefined variables get initialized only at the beginning of the fractal calculation, not at the beginning of each pixel...

The workspace of transformations and iteration formulas regarding predefined variables is different.