@@ -11,7 +11,7 @@ detail on this page.
1111
1212## The ` @tensor ` macro
1313
14- The prefered way to specify (a sequence of) tensor operations is by using the ` @tensor `
14+ The preferred way to specify (a sequence of) tensor operations is by using the ` @tensor `
1515macro, which accepts an
1616[ index notation] ( https://en.wikipedia.org/wiki/Abstract_index_notation ) format, a.k.a.
1717[ Einstein notation] ( https://en.wikipedia.org/wiki/Einstein_notation ) (and in particular,
@@ -38,6 +38,18 @@ tensor expression in the right hand side in an existing tensor `D`, whereas the
3838operator ` := ` results in a new tensor ` E ` with the correct properties to be created.
3939Nonetheless, the contents of ` D ` and ` E ` will be equal.
4040
41+ !!! warning "Aliasing"
42+
43+ Special care has to be taken when using the in-place `=`, combined with tensors that might
44+ alias or have overlapping memory regions. As `@tensor` assumes it is allowed to change the
45+ order of the operations within its scope, this may lead to unexpected or wrong results.
46+ For example, the result of the following expressions might be different and making use of
47+ this should be considered as undefined behavior:
48+ ```julia
49+ @tensor B[:] := L[-1, 1] * A[1, -2, 2] * R[2, -3] + α * A[-1, -2, -3]
50+ @tensor A[:] = L[-1, 1] * A[1, -2, 2] * R[2, -3] + α * A[-1, -2, -3]
51+ ```
52+
4153Following Einstein's summation convention, that contents is computed in a number of steps
4254involving the three primitive tensor operators. In this particular example, the first step
4355involves tracing/contracting the 3rd and 5th index of array ` A ` , the result of which is
0 commit comments