Elementwise operations
Once you have a few vectors or matrices defined, you can manipulate
them, in parallel, much like their scalar equivalents. For example:
intVector A(N), B(N), C(N);
...
A = B + C;
What this means is that corresponding elements (which are scalars) of
the vectors B and C are added, and then assigned to the corresponding
element of vector A. It is similar to the C code
int A[N], B[N], C[N];
...
for (i = 0; i < N; i++)
A[i] = B[i] + C[i];
There are many elementwise operators:
- arithmetic: add (+), subtract (-), multiply (*), divide (/), mod (%), negate (-)
- assignment: =, +=, -=, *=, /=, %=
- increment, decrement: ++, --
- comparison: < , < =, ==, > , > =, !=
- boolean: and (&&), or (||), not (!)
Not all operators apply to all types of vectors or matrices (see
details for vectors and matrices).