Complex:
Filter:
Classes | Math

Complex : Number : Magnitude : Object

complex number
Source: Complex.sc

Description

A class representing complex numbers. Note that this is a simplified representation of a complex number, which does not implement the full mathematical notion of a complex number.

Class Methods

Complex.new(real, imag)

Create a new complex number with the given real and imaginary parts.

Arguments:

real

the real part

imag

the imaginary part

Returns:

a new instance of Complex.

Discussion:

Inherited class methods

Instance Methods

math support

.real

.real = value

The real part of the number.

.imag

.imag = value

The imaginary part of the number.

.conjugate

the complex conjugate.

Discussion:

+(aNumber, adverb)

Complex addition.

Discussion:

-(aNumber, adverb)

Complex subtraction

Discussion:

*(aNumber, adverb)

Complex multiplication

Discussion:

/(aNumber, adverb)

Complex division.

Discussion:

.exp

Complex exponentiation with base e.

Discussion:

.squared

Complex self multiplication.

Discussion:

.cubed

complex triple self multiplication.

Discussion:

**(that)

From superclass: Object

.pow(aNumber)

Complex exponentiation

Discussion:

not implemented for all combinations - some are mathematically ambiguous.

<(aNumber, adverb)

the comparison of just the real parts.

Discussion:

==(aNumber, adverb)

the comparison assuming that the reals (floats) are fully embedded in the complex numbers

Discussion:

.neg

negation of both parts

Discussion:

.reciprocal

the reciprocal of a complex number

Discussion:

.abs

the absolute value of a complex number is its magnitude.

Discussion:

.magnitude

distance to the origin.

.magnitudeApx

.rho

the distance to the origin.

.angle

.phase

.theta

the angle in radians.

conversion

.asPoint

Convert to a Point.

.asPolar

Convert to a Polar

.asInteger

real part as Integer.

.asFloat

real part as Float.

.asComplex

returns this

misc

.coerce(aNumber)

.hash

a hash value

.printOn(stream)

print this on given stream

.performBinaryOpOnSignal(aSelector, aSignal, adverb)

.performBinaryOpOnComplex(aSelector, aNumber, adverb)

.performBinaryOpOnSimpleNumber(aSelector, aNumber, adverb)

.performBinaryOpOnUGen(aSelector, aUGen, adverb)

Inherited instance methods

Undocumented instance methods

.round(aNumber: 1.0)

Examples

Basic example:

Julia set approximation: