Report a bug
If you spot a problem with this page, click here to create a GitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

mir.complex

Complex numbers
Authors:
Ilya Yaroshenko
struct Complex(T) if (is(T == float) || is(T == double) || is(T == real));

Complex!T complex(T)(const T re, const T im)
if (is(T == float) || is(T == double) || is(T == real));
Generic complex number type
T re;
Real part. Default value is zero.
T im;
Imaginary part. Default value is zero.
ref Complex opAssign(R)(Complex!R rhs)
if (!is(R == T));
ref Complex opAssign(F)(const F rhs)
if (isNumeric!F);
ref Complex opOpAssign(string op : "+", R)(Complex!R rhs) return;
ref Complex opOpAssign(string op : "-", R)(Complex!R rhs) return;
ref Complex opOpAssign(string op, R)(Complex!R rhs) return
if (op == "*" || op == "/");
ref Complex opOpAssign(string op : "+", R)(const R rhs) return
if (isNumeric!R);
ref Complex opOpAssign(string op : "-", R)(const R rhs) return
if (isNumeric!R);
ref Complex opOpAssign(string op : "*", R)(const R rhs) return
if (isNumeric!R);
ref Complex opOpAssign(string op : "/", R)(const R rhs) return
if (isNumeric!R);
bool opEquals(const Complex rhs);
size_t toHash();
bool opEquals(R)(Complex!R rhs)
if (!is(R == T));
bool opEquals(F)(const F rhs)
if (isNumeric!F);
Complex opUnary(string op : "+")();
Complex opUnary(string op : "-")();
Complex!(CommonType!(T, R)) opBinary(string op : "+", R)(Complex!R rhs);
Complex!(CommonType!(T, R)) opBinary(string op : "-", R)(Complex!R rhs);
Complex!(CommonType!(T, R)) opBinary(string op : "*", R)(Complex!R rhs);
Complex!(CommonType!(T, R)) opBinary(string op : "/", R)(Complex!R rhs);
Complex!(CommonType!(T, R)) opBinary(string op : "+", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinary(string op : "-", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinary(string op : "*", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinary(string op : "/", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinaryRight(string op : "+", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinaryRight(string op : "-", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinaryRight(string op : "*", R)(const R rhs)
if (isNumeric!R);
Complex!(CommonType!(T, R)) opBinaryRight(string op : "/", R)(const R rhs)
if (isNumeric!R);
R opCast(R)()
if (isNumeric!R || isComplex!R);