Engee documentation

Math Function

A mathematical function.

blockType: Math

Path in the library:

/Basic/Math Operations/Math Function

Description

Block Math Function performs a number of common mathematical functions on the input signal(s).

The specific function is set by the Function parameter.

Function Description Mathematical expression The equivalent in Julia

exp

The exhibitor

exp

log

The natural logarithm

log

2^u

Base degree 2

2.^u

10^u

Base degree 10

10.^u

log10

Common (base 10) logarithm

log10

magnitude^2

Comprehensive module

real(x)^2+imag(x).2

square

Squaring

u.^2

pow

Degree

(by default) or (applies only to roots of even order)

power

conj

Complex coupling

conj

reciprocal

reciprocal with Newton–Raphson method

The inverse value

1/

1./u

hypot

The square root of the sum of squares

hypot

rem

The remainder after division

rem

mod

The module after division

mod

transpose

Transposition

transpose

hermitian

Conjugate transposition

hermitian

To calculate the square root, use the block Sqrt.

The output of the block is the result of calculating the value of the function over the input(s). The functions support the following types of operations:

Function Scalar operations Element-wise vector and matrix operations Vector and matrix operations

exp

Yes

Yes

Not applicable

log

Yes

Yes

Not applicable

2^u

Yes

Yes

Not applicable

10^u

Yes

Yes

Not applicable

log10

Yes

Yes

Not applicable

magnitude^2

Yes

Yes

Not applicable

square

Yes

Yes

Not applicable

pow

Yes, at two entrances

Yes, on two inputs (any combination of dimensions satisfying the capabilities of the broadcaster)

Not applicable

conj

Yes

Yes

Not applicable

reciprocal

reciprocal with Newton–Raphson method

Yes

Yes

Not applicable

hypot

Yes, at two entrances

Yes, on two inputs (any combination of dimensions satisfying the capabilities of the broadcaster)

rem

Yes, at two entrances

Yes, on two inputs (any combination of dimensions satisfying the capabilities of the broadcaster)

Not applicable

mod

Yes, at two entrances

Yes, on two inputs (any combination of dimensions satisfying the capabilities of the broadcaster)

Not applicable

transpose

Yes

Yes

hermitian

Yes

Yes

The name of the function and the corresponding number of input ports are displayed on the block.

Use the block Math Function when you need a vector or matrix output signal.

The Newton–Raphson algorithm

For the reciprocal function, it is possible to select the Newton–Raphson algorithm, which will calculate the inverse using the Newton–Raphson approximation method. The function uses recursive approximation to find the best approximations of the roots of the real-value function.

The inverse of a real number it is defined as the zero of the function:

.

The initial approximation is selected in the range because this is the convergence domain of the function.

To calculate the roots of a function sequentially, set the value of the Number of iterations parameter. The process is repeated as follows:

,

where — the derivative of the function .

Ports

Output

# OUT_1 — function result
scalar | vector | matrix

Details

Output signal as a scalar, vector or matrix. The size of the output signal depends on the value of the Function parameter and the size of the input signals.

Data types

Float16 | Float32 | Float64 | Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 | Bool

Complex numbers support

Yes

Input

# IN_1 — input signal
scalar | vector | matrix

Details

Input signal as a scalar, vector or matrix.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Complex numbers support

Yes

# IN_2 — input signal
scalar | vector | matrix

Details

Input signal as a scalar, vector or matrix.

Dependencies

To use this port, set the Function parameter to pow, hypot, rem or mod.

Data types

Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool

Complex numbers support

Yes

Parameters

Main

# Function — mathematical function
exp | log | 2^u | 10^u | log10 | magnitude^2 | square | pow | conj | reciprocal | hypot | rem | mod | transpose | hermitian

Details

The maths function to be calculated. For more information about this parameter, see section Description.

If the Function parameter is set to pow, the Signed power parameter is also used.

Values

exp | log | 2^u | 10^u | log10 | magnitude^2 | square | pow | conj | reciprocal | hypot | rem | mod | transpose | hermitian

Default value

exp

Program usage name

Operator

Tunable

No

Evaluatable

No

# Output signal type — output signal type
auto | real | complex

Details

Specify the output signal type in the Math Function block as auto, real or complex.

Function

Input signal type

Output signal type

Auto

Real

Complex

exp, log, 2^u, 10^u, log10, quare, pow, reciprocal, conjugate, transpose, hermitian

real

`complex

real

`complex

real

`error

complex

complex

magnitude squared

real

`complex

real

`real

real

`real

complex

complex

hypot, rem, mod

real

`complex

real

error

real

`error

complex

error

Values

auto | real | complex

Default value

auto

Program usage name

OutputSignalType

Tunable

No

Evaluatable

No

# Signed power — degree sign
Logical

Details

When calculating the degree, consider the sign of the input signal. This parameter applies only to even-order roots such as , and so on.

  • included - calculation of the degree of the absolute value of the input value multiplied by the sign of the input value.

  • off - calculation of the degree of the actual value of the input value. If the first input value is negative and the second input value is an even-order root, NaN will be returned.

Dependencies

To use this parameter, set the Function parameter to pow.

Default value

false (switched off)

Program usage name

SignedPower

Tunable

No

Evaluatable

No

# Algorithm method — algorithm method for function reciprocal
Exact | Newton-Raphson

Details

The algorithm method for the reciprocal function, given as Exact or Newton-Raphson.

Dependencies

To use this parameter, set the Function parameter to reciprocal.

Values

Exact | Newton-Raphson

Default value

Exact

Program usage name

AlgorithmMethod

Tunable

No

Evaluatable

No

# Number of iterations — number of iterations for the Newton-Raphson algorithm
Int64 integer

Details

The number of iterations for the Newton-Raphson algorithm, given as a scalar.

Dependencies

To use this parameter, set the Function parameter to reciprocal and the Algorithm method parameter to Newton-Raphson.

Default value

3

Program usage name

Iterations

Tunable

No

Evaluatable

Yes

Additional options

C code generation: Yes