2013-07-17 19:24:07 +02:00
|
|
|
.. highlight:: c
|
|
|
|
|
|
|
|
Assignment
|
|
|
|
=========================
|
|
|
|
|
|
|
|
The `value classes` and the `view classes` have a quite general assignment operator.
|
|
|
|
We will illustrate it on the `array` class, it is the same for `matrix` and `vector`.
|
|
|
|
|
|
|
|
* **Syntax** : the syntax is the same in both cases::
|
|
|
|
|
|
|
|
template<typename RHS> array & operator=(const RHS & X);
|
|
|
|
template<typename RHS> array_view & operator=(const RHS & X);
|
|
|
|
|
|
|
|
* **What can be RHS ?**
|
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
RHS can be ... anything that models the :ref:`ImmutableCuboidArray` concept !
|
2013-07-17 19:24:07 +02:00
|
|
|
|
|
|
|
e.g. : array, array_view, matrix, matrix_view,
|
|
|
|
but also formal expression (See , e.g. A+B), or any custom object of your choice.
|
|
|
|
|
|
|
|
* **Behaviour**
|
|
|
|
|
|
|
|
================= ======================================================================= ======================================================================================
|
|
|
|
Topic value class : array, matrix, vector view: array_view, matrix_view, vector_view
|
|
|
|
================= ======================================================================= ======================================================================================
|
2013-08-22 16:55:51 +02:00
|
|
|
RHS ... - RHS models the concept :ref:`ImmutableCuboidArray`. - RHS models :ref:`ImmutableCuboidArray`
|
2013-07-17 19:24:07 +02:00
|
|
|
[or less ? : RHS can be evaluated in the domain_type::value_type, no domain needed.].
|
|
|
|
Effect - array is resized to have a domain X.domain() - View's domain must match X's domain or behaviour is undefined.
|
|
|
|
- array is filled with the evaluation of X. - array is filled with the evaluation of X.
|
|
|
|
================= ======================================================================= ======================================================================================
|
|
|
|
|
|
|
|
* By evaluation of X, we mean :
|
|
|
|
|
|
|
|
- a copy if X is an array.
|
|
|
|
- computing the value if X is an expression.
|
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
Compound operators (+=, -=, * =, /=)
|
|
|
|
-------------------------------------------------
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
* **Syntax**
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
The syntax is natural ::
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
template<typename RHS> array & operator += (const RHS & X);
|
|
|
|
template<typename RHS> array & operator -= (const RHS & X);
|
|
|
|
template<typename RHS> array & operator *= (const Scalar & S);
|
|
|
|
template<typename RHS> array & operator /= (const Scalar & S);
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
* **What can be RHS ?**
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
Same as for = operator.
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
* **Behaviour**
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
Similar to for = operator, with obvious changes.
|
2013-07-17 19:24:07 +02:00
|
|
|
|
2013-08-22 16:55:51 +02:00
|
|
|
|