Fork me on GitHub

flatorize_d: Generate fast D code

by Guillaume Lathoud [1], September 2015

This page presents a plugin method flatorize.getCodeD() (GitHub source) that goes on top of flatorize (see the main article, GitHub source).

See also:

Contents #

HOWTO: 2-step example #

Here is an expression definition that uses complex numbers (details in the main article):

// f:

A call to flatorize():

// note the type declarations, ignored by JavaScript but used later for C
f2 = flatorize('a:[2 float],b:[2 float],c:[2 float]->d:[2 float]',f);

...generates flatorized JavaScript code:

// f2.getDirect():

Then, a call to flatorize.getCodeD():

...generates f2_obj.code, a JavaScript string containing the D code below:

(This code, as a few others below, was produced and inserted as you loaded the page.)

Having the intermediate flatorized implementation f2 can be useful to build other flatorized implementations, i.e. to write well-encapsulated, maintainable code using many small functions.

HOWTO: 1-step shortcut #

If an intermediate flatorized implementation is not needed, one can directly create D code in a single step:

HOWTO: generate boilerplate code#

JavaScript helper methods f2_obj.helper_*() generate boilerplate D code, especially useful to manage array inputs/output:

f2_obj.helper_decl() returns a JavaScript string containing this D code:

f2_obj.helper_d() returns a JavaScript string containing the D code below. Instead of the default file name "helper.h" you can optionally specify another file name using f2_obj.helper_d({ helper_decl_name : "another_name_decl.d" })