Code that the code generator replaces depends on the code replacement library (CRL) that you use. By default, the code generator does not apply a code replacement library. Your choice of libraries is dependent on product licensing and whether you have access to custom libraries.
When generating C/C++ code from MATLAB® code, depending on code replacement libraries available in your development environment, you can configure the code generator to replace instances of the following math functions with application-specific implementations.
Function | Data Type Support | Scalar, Vector, Matrix Support | Real, Complex Support |
---|---|---|---|
abs 1 | Floating point | Scalar | Real |
acos | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
acosd | Floating point | Scalar Vector Matrix | Real Complex |
acot | Floating point | Scalar Vector Matrix | Real Complex |
acotd | Floating point | Scalar Vector Matrix | Real Complex |
acoth | Floating point | Scalar Vector Matrix | Real Complex |
acsc | Floating point | Scalar Vector Matrix | Real Complex |
acscd | Floating point | Scalar Vector Matrix | Real Complex |
acsch | Floating point | Scalar Vector Matrix | Real Complex |
asec | Floating point | Scalar Vector Matrix | Real Complex |
asecd | Floating point | Scalar Vector Matrix | Real Complex |
asech | Floating point | Scalar Vector Matrix | Real Complex |
asin | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
asind | Floating point | Scalar Vector Matrix | Real Complex |
atan | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
atan2 | Floating point | Scalar Vector Matrix | Real |
atan2d | Floating point | Scalar Vector Matrix | Real |
atand | Floating point | Scalar Vector Matrix | Real Complex |
cos | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
ceil |
|
|
|
cosd | Floating point | Scalar Vector Matrix | Real Complex |
cosh | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
cot | Floating point | Scalar Vector Matrix | Real Complex |
cotd | Floating point | Scalar Vector Matrix | Real Complex |
coth | Floating point | Scalar Vector Matrix | Real Complex |
csc | Floating point | Scalar Vector Matrix | Real Complex |
cscd | Floating point | Scalar Vector Matrix | Real Complex |
csch | Floating point | Scalar Vector Matrix | Real Complex |
exp | Floating point | Scalar | Real |
fix | Floating point | Scalar | Real |
floor |
|
|
|
hypot | Floating point | Scalar Vector Matrix | Real |
ldexp | Floating point | Scalar | Real |
log | Floating point | Scalar Vector Matrix | Real Complex |
log10 | Floating point | Scalar Vector Matrix | Real Complex |
log2 | Floating point | Scalar Vector Matrix | Real Complex |
max | Integer Floating point | Scalar | Real |
min | Integer Floating point | Scalar | Real |
pow | Floating point | Scalar | Real |
rem | Floating point | Scalar | Real |
round | Floating point | Scalar | Real |
sec | Floating point | Scalar Vector Matrix | Real Complex |
secd | Floating point | Scalar Vector Matrix | Real Complex |
sech | Floating point | Scalar Vector Matrix | Real Complex |
sign | Floating point | Scalar | Real |
sin | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
sind | Floating point | Scalar Vector Matrix | Real Complex |
sinh | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
sqrt | Floating point | Scalar | Real |
tan | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
tand | Floating point | Scalar Vector Matrix | Real Complex |
tanh | Floating point | Scalar Vector Matrix | Real Complex Complex input/complex output Real input/complex output |
1 Wrap on integer overflow only |
Depending on code replacement libraries available in your development environment, you can configure the code generator to replace instances of the following memory functions with application-specific implementations.
Function | Data Type Support | Scalar, Vector, Matrix Support | Real, Complex Support |
---|---|---|---|
memcmp | Void pointer (void* ) | Scalar Vector Matrix | Real Complex |
memcpy | Void pointer (void* ) | Scalar Vector Matrix | Real Complex |
memset | Void pointer (void* ) | Scalar Vector Matrix | Real Complex |
memset2zero | Void pointer (void* ) | Scalar Vector Matrix | Real Complex |
Some target processors provide optimized functions to set memory
to zero. Use the code replacement library programming interface to
replace the memset2zero
function with more efficient
target-specific functions.
When generating C/C++ code from MATLAB code, depending on code replacement libraries available in your development environment, you can configure the code generator to replace instances of the following operators with application-specific implementations.
Mixed data type support indicates you can specify different data types of different inputs.
Operator | Key | Data Type Support | Scalar, Vector, Matrix Support | Real, Complex Support |
---|---|---|---|---|
Addition (+ )1 | RTW_OP_ADD | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Subtraction (- )1 | RTW_OP_MINUS | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Multiplication (* )2 | RTW_OP_MUL | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Division (/ ) | RTW_OP_DIV | Integer Floating point Fixed-point Mixed | Scalar | Real Complex |
Data type conversion (cast) | RTW_OP_CAST | Integer Floating point3 Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Shift left (<< ) | RTW_OP_SL | Integer Fixed-point Mixed | Scalar Vector Matrix | Real |
Shift right arithmetic (>> )4 | RTW_OP_SRA | Integer Fixed-point Mixed | Scalar Vector Matrix | Real |
Shift right logical (>> ) | RTW_OP_SRL | Integer Fixed-point Mixed | Scalar Vector Matrix | Real |
Element-wise matrix multiplication (.* )5 | RTW_OP_ELEM_MUL | Integer Floating point Fixed-point Mixed | Vector Matrix | Real Complex |
Complex conjugation | RTW_OP_CONJUGATE | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Transposition (.' ) | RTW_OP_TRANS | Integer Floating point Fixed-point Mixed | Vector Matrix | Real Complex |
Hermitian (complex conjugate) transposition (' ) | RTW_OP_HERMITIAN | Integer Floating point Fixed-point Mixed | Vector Matrix | Real Complex |
Multiplication with transposition2 | RTW_OP_TRMUL | Integer Floating point Fixed-point Mixed | Vector Matrix | Real Complex |
Multiplication with Hermitian transposition2 | RTW_OP_HMMUL | Integer Floating point Fixed-point Mixed | Vector Matrix | Real Complex |
Multiplication followed by shift right arithmetic (u1*u2>>u3 )6 | RTW_OP_MUL_SRA | Integer Fixed-point | Scalar | Real |
Multiplication followed by division (u1*u2/u3 )7 | RTW_OP_MULDIV | Integer Fixed-point | Scalar | Real |
Greater than (> ) | RTW_OP_GREATER_ | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Greater than or equal (>= ) | RTW_OP_GREATER_ | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Less than (< ) | RTW_OP_LESS_THAN | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Less than or equal (<= ) | RTW_OP_LESS_THAN_ | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Equal (== ) | RTW_OP_EUQAL | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
Not equal (!= ) | RTW_OP_NOT_EUQAL | Integer Floating point Fixed-point Mixed | Scalar Vector Matrix | Real Complex |
1 See Addition and Subtraction Operator Code Replacement for details to consider when defining mappings for addition and subtraction code replacements. 2 Can map to Basic Linear Algebra Subroutine (BLAS) multiplication functions. 3 Scaled floating point is not supported. 4 Code replacement libraries that provide arithmetic shift right implementations should also provide logical shift right implementations, because some arithmetic shift rights are converted to logical shift rights during code generation. 5 Use the
multiplication ( 6 Requires scalar, real, or
fixed-point data types with zero bias; output type of the multiplication operation to
accommodate all possible output values; shift operand
is an unsigned integer; and net slope is equal to 1 ( 7
Requires scalar, real, or fixed-point data types with zero bias; output type of the
multiplication operation to accommodate all possible
output values; and net slope is equal to 1 ( |