Object
|
+---DComplex
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.
#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;
}