std.complex - D Programming Language - Digital Mars

D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Wed Sep 2 00:11:53 2009

# std.complex

Module that will replace the built-in types cfloat, cdouble, creal, ifloat, idouble, and ireal.

Author:
Andrei Alexandrescu

enum Representation;
  Representation choices for the Complex type. Cartesian representation is better when using additive operations and when real and imaginary part are to be manipulated separately. Polar representation is more advantageous when using multiplicative operations and when modulus and angle are to be manipulated separately.

  cartesian
    Use Cartesian representation.

  polar
    Use polar representation.

struct Complex(Num,Representation rep = Representation.cartesian);
  Complex type parameterized with the numeric type (e.g. float, double, or real) and the representation.

  alias getRe;
    Gets the real component of the number. Might involve a calculation, subject to representation. Use x.re to statically enforce Cartesian representation.

  alias getIm;
    Gets the imaginary component of the number. Might involve a calculation, subject to representation. Use x.im to statically enforce Cartesian representation.

  alias getModulus;
    Gets the modulus of the number. Might involve a calculation, subject to representation. Use x.modulus to statically enforce polar representation.

  alias getAngle;
    Gets the angle of the number. Might involve a calculation, subject to representation. Use x.angle to statically enforce polar representation.

Copyright © 1999-2009 by Digital Mars, All Rights Reserved | Page generated by Ddoc.