Qu

real

Builtin index · Core maths

result = re(x)

Input: x · Output: result

What it is

Real component of a Complex/CVec/CMat (identity — x passed through unchanged — when x is already real). x is a scalar, Vec, or Mat (real or complex).

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = re(x)
x Complex, CVec, Vec, CMat, Mat, or scalarnot documented yet
result Complex, Num, CVec, Vec, CMat, or Mat
Returns the same shape as x but always real-valued — a Complex gives a Num, a CVec a real Vec, a CMat a real Mat.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

xr = real(ifft(X, N))
print("round-trip err = {max(abs(xr - x)):.2e}")
output
round-trip err = 4.93e-32

from numerics-dsp

t = 1, 2, ..., 50        # N = 50, not a power of two

x = sin(t)
X = fft(x)
print("length(X) = {length(X)}")
print("round trip err = {max(abs(real(ifft(X)) - x)):.2e}")
output
length(X) = 50
round trip err = 3.33e-16

from numerics-dsp

See also

re — documented in the same entry.