1# Fusion {#dsppp_fusion}
2
3```cpp
4Vector<float32_t,NB> d = a + b * c;
5```
6
7With this line of code, there is loop fusion : instead of having one loop per operator there is one loop for the whole computation.
8
9It is important to have some ideas of how it works to avoid some mistake in the use of the library.
10
11In above code, `a + b * c` is not computing anything !
12`a + b * c` is creating a representation of the expression : an abstract syntax tree (AST) at build time.
13
14When this AST is assigned to the variable `d` it is evaluated.
15The evaluation forces the inlining of the expression operators in one loop. The code generated thus contains only one loop with a fusion of all the operators : `+` and `*`.
16
17The library is supporting virtual vectors. They are a view on an existing part of a vector. You can use a virtual vector for instance to read some samples with a stride. Or write some samples with a stride. A virtual vector does not own its memory.
18
19If you write:
20```cpp
21d = a;
22```
23
24and `d` and `a` are virtual vectors then nothing will be written to `d` !
25
26`d` will becomes `a` and `a` will no more be valid.
27
28If you want to copy a virtual vector you need to make an expression and write:
29
30```cpp
31d = copy(a);
32```
33
34Note that this problem occurs only for virtual vectors who do not own their memory.
35
36For real vectors, a copy would occur. But since there is no overhead in adding `copy` it is better to do it to avoid problems.
37
38
39
40