The FUSE subsystem is made available through the includes libLSS/tools/fused_array.hpp, libLSS/tools/fuse_wrapper.hpp. They define wrappers and operators to make the writing of expressions on array relatively trivial, parallelized and possibly vectorized if the arrays permit. To illustrate this there are two examples in the library of testcases: test_fused_array.cpp and test_fuse_wrapper.cpp.

We will start from a most basic example:

These few lines create a one dimensional array of length N. Then this array is wrapped in the seamless FUSE expression system. It is quite advised to use auto here as the types can be complex and difficult to guess for newcomers. Finally, the last line fills the array with value 1. This is a trivial example but we can do better:

This transforms the content of a by evaluating {$cos(2\pi x)^2$} for each element {$x$} of the array wrapped in w_a. This is done without copy using the lazy expression mechanism. It is possible to save the expression for later:

Note that nothing is evaluated. This only occurs at the assignment phase. This wrap behaves also mostly like a virtual array:

accesses computes the i-th value of the expression and nothing else.

Some other helpers in the libLSS supports natively the fuse mechanism. That is the case for RandomNumber::poisson for example:

This piece of code would compute a poisson realization for a mean value given by the element of the b expression (which must be a wrapped array or one expression of it) and stores this into c.

The sum reduce (parallel reduction) operation is supported by the wrapper:

Some arrays could be entirely virtual, i.e. derived from C++ expressions. This needs to invoke a lower layer of the FUSE mechanism. Creating a pure virtual array looks like that:

This operation creates a virtual array and wraps it immediately. The virtual array is a double bidimensional array (the two template parameters), and infinite. Its element are computed using the provided lambda function, which obligatorily takes 2 parameters. It is possible to make finite virtual arrays by adding an extent parameter:

Only in that case it is possible to query the dimension of the array.

Finally

FUSED mechanism does not yet support automatic dimensional broadcast!