## Code You Can Replace from MATLAB Code

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.

### Math 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 math functions with application-specific implementations.

FunctionData Type SupportScalar, Vector, Matrix SupportReal, Complex Support
`abs`1Floating pointScalarReal
`acos`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`acosd`Floating pointScalar
Vector
Matrix
Real
Complex
`acot`Floating pointScalar
Vector
Matrix
Real
Complex
`acotd`Floating pointScalar
Vector
Matrix
Real
Complex
`acoth`Floating pointScalar
Vector
Matrix
Real
Complex
`acsc`Floating pointScalar
Vector
Matrix
Real
Complex
`acscd`Floating pointScalar
Vector
Matrix
Real
Complex
`acsch`Floating pointScalar
Vector
Matrix
Real
Complex
`asec`Floating pointScalar
Vector
Matrix
Real
Complex
`asecd`Floating pointScalar
Vector
Matrix
Real
Complex
`asech`Floating pointScalar
Vector
Matrix
Real
Complex
`asin`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`asind`Floating pointScalar
Vector
Matrix
Real
Complex
`atan`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`atan2`Floating pointScalar
Vector
Matrix
Real
`atan2d`Floating pointScalar
Vector
Matrix
Real
`atand`Floating pointScalar
Vector
Matrix
Real
Complex
`cos`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`ceil`
• Floating-point

• Scalar

• Floating-point

• Scalar

• Floating-point

• Scalar

`cosd`Floating pointScalar
Vector
Matrix
Real
Complex
`cosh`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`cot`Floating pointScalar
Vector
Matrix
Real
Complex
`cotd`Floating pointScalar
Vector
Matrix
Real
Complex
`coth`Floating pointScalar
Vector
Matrix
Real
Complex
`csc`Floating pointScalar
Vector
Matrix
Real
Complex
`cscd`Floating pointScalar
Vector
Matrix
Real
Complex
`csch`Floating pointScalar
Vector
Matrix
Real
Complex
`exp`Floating pointScalarReal
`fix`Floating pointScalarReal
`floor`
• Floating-point

• Scalar

• Floating-point

• Scalar

• Floating-point

• Scalar

`hypot`Floating pointScalar
Vector
Matrix
Real
`ldexp`Floating pointScalarReal
`log`Floating pointScalar
Vector
Matrix
Real
Complex
`log10`Floating pointScalar
Vector
Matrix
Real
Complex
`log2`Floating pointScalar
Vector
Matrix
Real
Complex
`max`Integer
Floating point
ScalarReal
`min`Integer
Floating point
ScalarReal
`pow`Floating pointScalarReal
`rem`Floating pointScalarReal
`round`Floating pointScalarReal
`sec`Floating pointScalar
Vector
Matrix
Real
Complex
`secd`Floating pointScalar
Vector
Matrix
Real
Complex
`sech`Floating pointScalar
Vector
Matrix
Real
Complex
`sign`Floating pointScalarReal
`sin`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`sind`Floating pointScalar
Vector
Matrix
Real
Complex
`sinh`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`sqrt`Floating pointScalarReal
`tan`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output
`tand`Floating pointScalar
Vector
Matrix
Real
Complex
`tanh`Floating pointScalar
Vector
Matrix
Real
Complex
Complex input/complex output
Real input/complex output

1 Wrap on integer overflow only

### Memory Functions

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.

FunctionData Type SupportScalar, Vector, Matrix SupportReal, 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.

### Operators

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.

OperatorKeyData Type SupportScalar, Vector, Matrix SupportReal, 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
ScalarReal
Multiplication followed by division (`u1*u2/u3`)7`RTW_OP_MULDIV`Integer
Fixed-point
ScalarReal
Greater than (`>`)```RTW_OP_GREATER_ THAN```Integer
Floating point
Fixed-point
Mixed
Scalar
Vector
Matrix
Real
Complex
Greater than or equal (`>=`)```RTW_OP_GREATER_ THAN_OR_EQUAL```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_ OR_EUQAL```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 (`*`) operator (`RTW_OP_MUL`) for scalar 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 (```U1_slope * U2_slope == Mul_output_slope``` and ```Mul_output_slope == output_slope_of_shift_operation```).

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 (```U1_slope * U2_slope == Mul_output_slope == U3_slope * Div_output_slope```).
{"ft_lang_label":"__label__en","ft_lang_prob":0.55880755,"math_prob":0.9588412,"size":8375,"snap":"2021-43-2021-49","text_gpt3_token_len":2072,"char_repetition_ratio":0.35742444,"word_repetition_ratio":0.38495576,"special_character_ratio":0.19856717,"punctuation_ratio":0.038936373,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9960268,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-28T00:20:51Z\",\"WARC-Record-ID\":\"<urn:uuid:9cd2517a-3c4f-4ae5-bff7-84395552b01b>\",\"Content-Length\":\"85474\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:4931142c-84f1-4ccd-85d0-73d467541b16>\",\"WARC-Concurrent-To\":\"<urn:uuid:00535cd8-687d-45be-8806-e6d4bfc89bbc>\",\"WARC-IP-Address\":\"104.104.91.201\",\"WARC-Target-URI\":\"https://it.mathworks.com/help/ecoder/ug/code-you-can-replace-from-matlab-code.html\",\"WARC-Payload-Digest\":\"sha1:OKEB4TOBIS3QOB33QRHMA4VPCXVWG545\",\"WARC-Block-Digest\":\"sha1:IHJPJ4VNMUNVXS5633LRIRMDNZXGC2IY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323588244.55_warc_CC-MAIN-20211027212831-20211028002831-00610.warc.gz\"}"}