Objects for Complex Arithmetic and Arbitrary Arithmetic
G'day friends, The most recent sources I have seen for Fractint still uses C. I have migrated ManpWin to C++ so that I am able to use classes to simplify complex arithmetic, especially using arbitrary arithemetic. For example here is the header file for the BigComplex class: // BigComplex.h: interface for the Complex Bignum class. // ////////////////////////////////////////////////////////////////////// #pragma once #include <math.h> #include "BigDouble.h" #define FALSE 0 #define TRUE 1 #define zerotol 1.e-50 class BigComplex { public: BigComplex(void) { } BigComplex(const BigDouble & real, const BigDouble & imaginary) { x = real; y = imaginary; } BigComplex(const BigComplex & Cmplx1)// Copy Constructor { x = Cmplx1.x; y = Cmplx1.y; } BigComplex(const BigDouble & value) { x = value; y = 0; } ~BigComplex(void); BigComplex operator =(const BigComplex &); // Assignment Operator BigComplex operator =(const BigDouble &); // Assignment to a double Operator bool operator==(BigComplex &); BigComplex operator^(BigDouble &); BigComplex operator^(BigComplex &); BigComplex operator++(void); BigComplex operator +(const BigComplex &); // Addition Operator BigComplex operator +(const BigDouble &); // complex add by double Operator BigComplex operator -(const BigComplex &); // Subtraction Operator BigComplex operator -(const BigDouble &); // complex subtract by double Operator BigComplex operator -(void); // unary minus BigComplex operator *(const BigComplex &); // Multiplication Operator BigComplex operator *(const BigDouble &); // complex multiply by double Operator BigComplex operator /(const BigComplex &); // Division Operator BigComplex operator /(const BigDouble &); // complex divide by double Operator BigDouble x, y; }; extern BigComplex CSin(BigComplex &); // sine of a complex number extern BigComplex CCos(BigComplex &); // cosine extern BigComplex CSqr(BigComplex &); // square extern BigComplex CCube(BigComplex &); // cube extern BigDouble BigCSumSqr(BigComplex &); // real squared + imaginary squared extern BigDouble BigCFabs(BigComplex &); // abs extern double CSumSqr(BigComplex &); // real squared + imaginary squared extern double CFabs(BigComplex &); // abs extern BigComplex CPolynomial(BigComplex &, int);// take a complex number to an integer power extern BigComplex CInvert(BigComplex &); // invert extern BigComplex CExp(BigComplex &); // exponent extern BigComplex CLog(BigComplex &); // log I am still developing it and have created 3 classes: Complex, BigDouble and BigComplex. These simplify fractal code immensely. Is this of interest to anyone in the Fractint fraternity? Regards, Paul. ---------------------------------------------------------- Paul de Leeuw Computers NSW Central Coast, Australia Email: pdeleeuw@deleeuw.com.au www: <http://www.deleeuw.com.au <http://www.deleeuw.com.au/> > ABN 72 360 822 562 ----------------------------------------------------------
participants (1)
-
Paul