flatorize_d
: Generate fast D codeby 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:
asm.js
plugin.asm.js
, C and D (source on GitHub).asm.js
, C, D…; GitHub).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 flatorize
d implementation f2
can be useful to build other flatorize
d implementations, i.e. to write well-encapsulated, maintainable code using many small functions.
If an intermediate flatorize
d implementation is not needed, one can directly create D code in a single step:
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" })