Engee documentation

abs

Absolute value or modulus.

Library

EngeeDSP

Syntax

Function call

Arguments

Input arguments

# X — input data

+ scalar | vector | the matrix | multidimensional array

Details

Input data specified as a scalar, vector, matrix, or multidimensional array. If X — complex, then it should have the type Float32 or Float64.

Типы данных

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

Support for complex numbers

Yes

Output arguments

# Y is the absolute value or module of the input data

+ scalar | vector | the matrix | multidimensional array

Details

The absolute value or modulus of the input data elements X. Data size and type Y match the size and type X.

Examples

The absolute value of the scalar

Details

Calculate the absolute value of the number −5.

import EngeeDSP.Functions: abs
y=abs(-5)
5

Absolute value of the vector

Details

Set the vector x and calculate the absolute value y.

import EngeeDSP.Functions: abs
x = [1.3 -3.56 8.23 -5 -0.01]
y=abs(x)
1×5 Matrix{Float64}:
 1.3  3.56  8.23  5.0  0.01

The module of a complex number

Details

Create a complex number X and calculate its modulus Y.

import EngeeDSP.Functions: abs

X = 3+im * 4
Y = abs(X)
5.0

Additional information

Absolute value

Details

The absolute value (or modulus) of a real number is the corresponding non—negative value without taking into account the sign.

For a real number the absolute value is:

  • if greater than or equal to zero;

  • if less than zero.

Function abs(−0) returns 0.

The module of a complex number

Details

The modulus of a complex number is the length of the vector drawn from the origin to the complex value displayed on the complex plane.

For a complex number the module is defined as