This is an old version, view current version.

10 Compound Arithmetic and Assignment

Compound arithmetic and assignment statements combine an arithmetic operation and assignment, replacing a statement such as

 x = x op y;

with the more compact compound form

 x op= y;

For example, x = x + 1; may be replaced with x += 1;. This works for all types that support arithmetic, including the scalar types int, real, complex, the real matrix types vector, row_vector, and matrix, and the complex matrix types, complex_vector, complex_row_vector, and complex_matrix.