Complex Arithmetic and Operators
Csound supports all arithmetic and a set of operators for Complex variables and arrays:
- +,-, * and / for Complex-Complex, Complex-k, and Complex-i expressions (returning Complex)
- +,-, * and / for Complex[]-Complex[] and Complex[]-k expressions (returning Complex)
For Complex and Complex[] types, the following functions are supported
- abs - magnitude
- arg - argument
- complex - rectangular conversion
- conj - conjugation
- exp - argument
- imag - imaginary part
- log - logarithm
- polar - polar conversion
- real - real part
A complex number can be created using the complex
function/cast (for
scalars or vector arrays)
Assignment and initialisation are also supported with comma-separated arguments for both real and imaginary parts respectively,
Generally, operations resulting in Complex types run at both at init and perf-time. Operations consuming Complex types run at either init, perf, or init and perf, depending on the output type.