Using the C++ Math Library    

Operators

Operator syntax is a very convenient and natural looking shorthand for function calls. The MATLAB C++ Math Library supports a subset of the operators available in MATLAB. The library provides all of the relational operators and those arithmetic and miscellaneous operators that do not violate rules of C++ syntax. The operators that are not available as operators are available via function calls.

In MATLAB there are two classes of arithmetic operators: array operators and matrix operators. In the MATLAB C++ Math Library the arithmetic operators are matrix operators, except for + and - for which the distinction is meaningless. This means that, for example, A * B is the linear algebraic product (matrix multiplication) of A and B, rather than the elementwise product of A and B.  A and B are mwArray objects. All of the arithmetic array operators are also available via function calls.

Operators in the MATLAB C++ Math Library are vectorized. This means you can use the + operator, for example, to compute the sum of two arrays without using a loop. In C++, without some kind of an array class, you'd use one or two for-loops to compute the sum of two arrays; e.g., for every row in the array and for every column in the row, compute the sum at the row/column intersection. The operators in the MATLAB C++ Math Library all contain loops of this sort already, so there is no need for you to write them.

The section Operators in Chapter 11 lists the available operators and their function call equivalents.


 Data Types Functions