complex

Section: OATH Reference Manual (3O)
Updated: 26 August 1991
Index Return to Main Contents
 

NAME

complex (complexA, complexG) - an object that holds a complex number value  

SYNOPSIS

#include <oath/numeric.h>  

DESCRIPTION

The complex is an object that holds a value in the complex plane -- it is the root class of all numeric types. Note that complex and the other numeric types in OATH are object-oriented like bag, as opposed to value-oriented like int or float. An int is a numeric value. An integer is an object that can hold a numeric value. As a consequence, all of the fundamental operations on complex's are self-modifying. For instance, operator + is defined in terms of operator +=, not vice-versa. Functions such as sqr and sqrt reset the value of the current complex to the square or square root of itself. Separate global functions can be added to give traditional form:

       complexA sqr (complexA C) {return (+C).sqr();}

A derived type of complex may restrict either or both the resolution or the range. For instance, a real is a complex that restricts the range to the real axis of the complex plane. Similarly, an integer restricts the precision to integer values. If the value of one complex is assigned into another complex, and that complex has inadequate precision to represent the value, then the value is approximated to the next higher or next lower value in that precision (the nature of the rounding is unspecified). However, if the complex value is outside the range of the complex object that it is being assigned into, then a rangeViolation should be thrown (currently, you will get a core dump). For instance, if the value 3.221 is assigned to an integer, the integer will assume the value 3. However, if the value 3.2+i3.4 is assigned to an integer, a rangeViolation will be thrown.

As with the entire OATH library, this is an experiment in greater object- oriented reusability. Although these numeric classes appear to provide greater reuse potential, they deviate somewhat from the traditional usage of numbers in programming.  

DERIVATION

complex : obj

complex is an abstract type.  

STATIC OPERATIONS

complexA complexA:: isa (objA)
complexA::isa(O) returns O if it is truly a complex; otherwise it returns Nil.
 

MEMBER OPERATIONS

realA complexA:: makeReal (int = FALSE)
C.makeReal() makes and returns a real number representing the real part of complex number C.
realA complexA:: makeImag (int = FALSE)
C.makeImag() makes and returns a real number representing the imaginary part of complex number C.
realA complexA:: makeAbs (int = FALSE)
C.makeAbs() makes and returns a real number representing the absolute value (magnitude) of complex number C.
realA complexA:: makeArg (int = FALSE)
C.makeArg() makes and returns a real number representing the argument (direction) of complex number C.
int complexA:: hasZero ()
C.hasZero() returns TRUE if C has zero.
int complexA:: hasZeroImag ()
C.hasZeroImag() returns TRUE if C has a value on the real axis.
int complexA:: hasEqual (complexA)
C1.hasEqual(C2) returns TRUE if C1 and C2 have equivalent values.
void complexA:: print (ostream&, char = ' ')
C.print(F, S) prints the complex number C in decimal notation to ostream F, using char S to separate every three digits. If S is NUL, then no separator is used.
complexA complexA:: reset ()
C.reset() sets the numeric value of C1 to zero.
complexA complexA:: reset (complexA)
C1.reset(C2) sets the numeric value of C1 to be equal to C2.
complexA complexA:: operator <op>= (complexA)
C1 <op>= C2 performs the appropriate complex arithmetic operation, leaving the result in C1. <op> is one of +, -, *, /.
complexA complexA:: operator <op> (complexA)
C1 <op> C2 is the same as (+C1) <op>= C2.
complexA complexA:: operator <<= (integerA)
C <<= I is the same as C *= pow(2, I).
complexA complexA:: operator << (integerA)
C << I is the same as (+C) <<= I.
complexA complexA:: operator >>= (integerA)
C >>= I is the same as C /= pow(2, I).
complexA complexA:: operator << (integerA)
C >> I is the same as (+C) >>= I.
complexA complexA:: operator ++ ()
++C is the same as C += 1.
complexA complexA:: operator -- ()
--C is the same as C -= 1.
complexA complexA:: neg ()
C.neg() negates C.
complexA complexA:: operator - ()
-C is the same as (+C).neg().
complexA complexA:: conj ()
C.conj() sets C to the complex conjugate of itself.
complexA complexA:: abs ()
C.abs() sets C to the absolute value of itself (this will be a real value).
complexA complexA:: inv ()
C.inv() sets C to 1/C.
complexA complexA:: sqr ()
C.sqr() sets C to C squared.
complexA complexA:: sqrt ()
C.sqrt() sets C to the square root of C.
complexA complexA:: pow (integerA)
C.pow(I) sets C to C^I (the Ith power of C).
 

INTERNAL OPERATIONS

 

SEE ALSO

OATH(3O), obj(3O), real(3O), bigInteger(3O)  

AUTHOR

Brian M. Kennedy (Computer Science Center, Texas Instruments Incorporated)  

COPYRIGHT

Copyright (C) 1991 Texas Instruments Incorporated

Permission is granted to any individual or institution to use, copy, modify, and distribute this software, provided that this complete copyright and permission notice is maintained, intact, in all copies and supporting documentation. Texas Instruments Incorporated provides this software "as is" without express or implied warranty.  

BUGS

There is only one implementation of complex provided, and it only supports integer precision on the real axis. Thus, all the difficulties in implementing cross-implementations of functionality may not be readily apparent. Thus, this interface may need augmentation to better support implementations. Planned implementations include doubleComplex, floatComplex, bigComplex, bigComplex, doubleReal, floatReal, bigReal, bigRational, dlongRational, longRational, bigInteger, dlongInteger, and longInteger.


 

Index

NAME
SYNOPSIS
DESCRIPTION
DERIVATION
STATIC OPERATIONS
MEMBER OPERATIONS
INTERNAL OPERATIONS
SEE ALSO
AUTHOR
COPYRIGHT
BUGS

This document was created by man2html, using the manual pages.
Time: 20:37:42 GMT, July 24, 2024