Class DComplex

Inherits from:
Object
Conforms to:
DSimpleArithmetic, DTextable
Declared in:
DComplex.h

Class Hierarchy

    Object
      |
      +---DComplex

Class Description

The complex class implements a number of methods for working with complex numbers. Heavily 'inspired' by the excellent ccmath library by Daniel A. Atkinson (c) Copyright 2000.

Example:
#include <stdio.h>
#include "ofc/DComplex.h"

int main(int argc, char *argv[])
{
  DComplex *cp1 = [DComplex alloc];
  DComplex *cp2 = [DComplex new  ];
  DComplex *cp3 = [DComplex new  ];
  DText    *str;

  [cp1 init :0.5 :0.5];                // Init with 0.5+0.5j

  [cp2 set  :2.0 :3.0];                // Set with 2+3j

  [cp3 move :cp1];                     // cp3 = cp1

  [cp2 mul  :cp1];                     // cp2 = cp2 * cp1

  [cp3 sub  :cp2 :cp1];                // cp3 = cp2 - cp1

  str = [cp3 toText];

  printf("Complex3 = %.3f + j %0.3f or \"%s\".\n", [cp3 re], [cp3 im], [str cstring]);
  printf("ABS(complex3) = %.3f\n", [cp3 abs]);

  [str free];
  [cp1 free];
  [cp2 free];
  [cp3 free];

  return 0;
}
Last modified:
20-Jul-2008 (DComplex.h)

Instance Variables

private double _re
private double _im

Method Index


generated 06-Sep-2008 by ObjcDoc 3.0.0