Assignment policies
The assignment statement
assign(x,e);
assigns the result of the expression e
to the container
x
.
There are various conditions of assigment, some of which are discussed here.
Size
By default, we assume that the sizes of e
and x
are equal.
An assignment policy can be created that first resizes the left hand side if
the sizes do not match.
Of course this is not possible for add_assign
and subtract_assign
.
Aliasing
It is assumed that the elemental assigment for vectors
x(i) = e(i)
is possible for any i
in 0,x.size()-1
in any order.
This is a no-aliasing assumption.
If aliasing could be possible the result should first be stored in a
temporary before assigning.
There could be a policy to create this temporary.
Sparse assignments
The assignment into a sparse container can also happen in various ways.
It could be a requirement that the sparse (nonzero) structure is equal for
left and right-hand side, or the sparse structure of the right-hand side is
inserted into the left-hand side, or the sparse structure of the left-hand side
is overwritten by the structure of the right-hand side.
Assignment policy
The assigment policy is a class that indicates when the choices discussed above
should apply whence assign
is called.
The syntax for another than the default policy is:
assign<blackend_type,assignment_policy_type>( x, e ) ;
or, when operators are used, we could have
assignment_policy( x ) = e ;