Skip to content

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

A complex number can be created using the complex function/cast (for scalars or vector arrays)

complex(real:{k},imag:{k})

Assignment and initialisation are also supported with comma-separated arguments for both real and imaginary parts respectively,

var:Complex = real:{k}, imag:{k}

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.