Using the C++ Math Library |
 |
Arithmetic Operators
These binary operators perform arithmetic on their operands. The two operands for an element-wise arithmetic operator must be the same size. Operators that are not element-wise are not so uniform; they may have other operator-specific restrictions on operand size.
Table 11-1: C++ Arithmetic Operators
C++ Operator
|
Definition
|
Equivalent C++ Function
|
+
|
Element-wise addition
|
plus()
|
-
|
Element-wise subtraction
|
minus(), unaryminus()
|
*
|
Matrix multiplication
|
mtimes()
|
/
|
Matrix right division
|
mrdivide()
|
^
|
Matrix exponentiation
|
mpower()
|
Because the MATLAB syntax differs from the C++ syntax, several MATLAB operators are available in C++ as functions rather than as operators.
Table 11-2: C++ Functional Equivalents to MATLAB Operators
MATLAB Operator only
|
Definition
|
Equivalent C++ Function
|
\
|
Matrix left-division
|
mldivide()
|
.\
|
Element-wise left-division
|
ldivide()
|
./
|
Element-wise right-division
|
rdivide()
|
.*
|
Element-wise multiplication
|
times()
|
.^
|
Element-wise exponentiation
|
power()
|
'
|
Complex-conjugate transpose
|
ctranspose()
|
.'
|
Noncomplex transpose
|
transpose()
|
| Operators | | Relational Operators |  |