/usr/share/SuperCollider/HelpSource/Classes/Complex.schelp is in supercollider-common 1:3.8.0~repack-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | CLASS:: Complex
summary:: complex number
categories:: Math
related::Classes/Polar, Classes/SimpleNumber, Classes/Float, Classes/Integer
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.
CLASSMETHODS::
method:: new
Create a new complex number with the given real and imaginary parts.
argument:: real
the real part
argument:: imag
the imaginary part
returns:: a new instance of Complex.
discussion::
code::
a = Complex(2, 5);
a.real;
a.imag;
::
INSTANCEMETHODS::
subsection:: math support
method:: real
The real part of the number.
method:: imag
The imaginary part of the number.
method:: conjugate
the complex conjugate.
discussion::
code::
Complex(2, 9).conjugate
::
method:: +
Complex addition.
discussion::
code::
Complex(2, 9) + Complex(-6, 2)
::
method:: -
Complex subtraction
discussion::
code::
Complex(2, 9) - Complex(-6, 2)
::
method:: *
Complex multiplication
discussion::
code::
Complex(2, 9) * Complex(-6, 2)
::
method:: /
Complex division.
discussion::
code::
Complex(2, 9) / Complex(-6, 2)
::
method:: exp
Complex exponentiation with base e.
discussion::
code::
exp(Complex(2, 9))
::
code::
exp(Complex(0, pi)) == -1 // Euler's formula: true
::
method:: squared
Complex self multiplication.
discussion::
code::
squared(Complex(2, 1))
::
method:: cubed
complex triple self multiplication.
discussion::
code::
cubed(Complex(2, 1))
::
method:: **, pow
Complex exponentiation
discussion::
not implemented for all combinations - some are mathematically ambiguous.
code::
Complex(0, 2) ** 6
::
code::
2.3 ** Complex(0, 2)
::
code::
Complex(2, 9) ** 1.2 // not defined
::
method:: <
the comparison of just the real parts.
discussion::
code::
Complex(2, 9) < Complex(5, 1);
::
method:: ==
the comparison assuming that the reals (floats) are fully embedded in the complex numbers
discussion::
code::
Complex(1, 0) == 1;
Complex(1, 5) == Complex(1, 5);
::
method:: neg
negation of both parts
discussion::
code::
Complex(2, 9).neg
::
method:: abs
the absolute value of a complex number is its magnitude.
discussion::
code::
Complex(3, 4).abs
::
method:: magnitude
distance to the origin.
method:: magnitudeApx
method:: rho
the distance to the origin.
method:: angle, phase, theta
the angle in radians.
subsection:: conversion
method:: asPoint
Convert to a link::Classes/Point::.
method:: asPolar
Convert to a Polar
method:: asInteger
real part as link::Classes/Integer::.
method:: asFloat
real part as link::Classes/Float::.
method:: asComplex
returns this
subsection:: misc
method:: coerce
method:: hash
a hash value
method:: printOn
print this on given stream
method:: performBinaryOpOnSignal
method:: performBinaryOpOnComplex
method:: performBinaryOpOnSimpleNumber
method:: performBinaryOpOnUGen
EXAMPLES::
Basic example:
code::
a = Complex(0, 1);
a * a; // returns Complex(-1, 0);
::
Julia set approximation:
code::
f = { |z| z * z + Complex(0.70176, 0.3842) };
(
var n = 80, xs = 400, ys = 400, dx = xs / n, dy = ys / n, zoom = 3, offset = -0.5;
var field = { |x| { |y| Complex(x / n + offset * zoom, y / n + offset * zoom) } ! n } ! n;
w = Window("Julia set", bounds:Rect(200, 200, xs, ys)).front;
w.view.background_(Color.black);
w.drawFunc = {
n.do { |x|
n.do { |y|
var z = field[x][y];
z = f.(z);
field[x][y] = z;
Pen.color = Color.gray(z.rho.linlin(-100, 100, 1, 0));
Pen.addRect(
Rect(x * dx, y * dy, dx, dy)
);
Pen.fill
}
}
};
fork({ 6.do { w.refresh; 2.wait } }, AppClock)
)
::
|