### Complex Numbers

SPL fully supports complex numbers. SPL defines the constant i to represent . For example:

x = 1 + 2i

y = .5 + i

x + y  returns: 1.5 + 3i

x * y  returns: -1.5 + 2i

a = {1, 2, 3, 4}

fft(a)

returns a complex series: {10+0i, -2+2i, -2+0i, -2-2i}

Since i defines a complex number, i cannot be used as a global variable. However, i can be declared as a local variable by using the local declaration:

ilocal(x)

{

local a, i;

for (i = 0; i < x; i++)

{

x * i;

}

return(a, a * 1i);

}

(a, b) = ilocal(10)

a == 90

b == 90i

In this case, DADiSP recognizes i as a local variable and 1i as . The details of the FOR loop will be described shortly.

SPL includes several functions for manipulating complex numbers:

 Function Description REAL Real part of complex number/series IMAG Imaginary part of a complex number/series MAG Magnitude of a complex number/series PHASE Angle of a complex number/series between -π and π ANGLE Angle of a complex number/series between 0 and π CONJ Complex conjugate of series/number POLAR Convert from Cartesian to polar form MAKECARTESIAN Create complex values in real/imaginary form MAKEPOLAR Create complex values in magnitude/angle form

If an operation entails a combination of real and complex numbers, SPL assumes the imaginary part of the real number is zero.