home *** CD-ROM | disk | FTP | other *** search
- CMATH -- a unit of complex mathematical routines for Turbo Pascal
- versions 4, 5, and 5.5
-
- Copyright 1990, by J. W. Rider
-
- CMATH.PAS provides a library of type definitions, functions and
- procedures for manipulation of mathematically complex variables
- (having both a "real" part and an "imaginary" part) for immediate
- use within Turbo Pascal programs (tested with version 5.5).
- Routines are provided for:
-
- Binary operators:
- cadd, csub, cmult, cdiv, cpow
-
- Exponenential, power-raising, and logarithmic procedures:
- cexp, cln, csqr, csqrt
-
- Circular and hyperbolic trigonometric procedures and
- inverses:
- casin, casinh, cacos, cacosh, catan, catanh,
- csin, ccos, ctan, csinh, ccosh, ctanh
-
- Conversion functions:
- cabs, conj, cneg, cnjx, crecip, csqr, csqrt,
- phase
-
- Polynomial evaluation:
- cpoly
-
-
- Depending upon whether software or hardware numeric processing
- enabled, CMATH will use either MATH.TPU or MATH87.TPU,
- correspondingly.
-
- General design approach: While this implementation does not take
- advantage of the object-oriented syntax of TP5.5, the approach is
- still object-oriented. Each complex variable is considered to be
- an object that "knows" how to do a variety of manipulations on
- itself. Porting these units to a purer object-oriented form
- should be straight forward, but is otherwise left as an exercise
- for the reader.
-
- In order to improve performance, none of the CMATH
- routines perform any range-checking for invalid values.
- Generally, this only means that the result returned will be
- equally invalid. However, there are some special values that
- WILL result in run-time errors for some of the routines. Calling
- the CMATH routines with illegal or improper inputs is strictly at
- the programmer's risk.
-
-
- CMATH.PAS constants
-
- "MaxCXRay" is the largest index of the largest array of
- complex variables that can be represented.
-
-
- CMATH.PAS type definitions
-
- The principal type used within the unit is the "complex"
- variable, which is defined as a record with two fields: a real
- part component called "rp", and an imaginary part component
- called "ip". Since complex variables are considered storage
- mechanisms, these two components are defined as being of type
- "math.float":
-
- complex = record rp, ip: float; end;
-
-
- Additionally, CMATH.PAS defines the largest possible
- array of complex variables as "CXRay". This is defined for
- typecasting purposes, and need not be used outside of the unit.
-
-
- CMATH.PAS function and procedure definitions
-
- name (parameter list) type of result
- ---- ---------------- --------------
- cabs (var x: complex) xfloat
-
- Returns the absolute value or magnitude of the complex
- variable.
-
-
- cacos (var x: complex) ------
-
- Transforms the complex variable into its inverse circular
- cosine.
-
-
- cacosh (var x: complex) ------
-
- Transforms the complex variable into its inverse
- hyperbolic cosine.
-
-
- cadd (var x,y: complex) ------
-
- Adds the complex value of "y" to "x".
-
-
- casin (var x: complex) ------
-
- Transforms the complex variable into its inverse circular
- sine.
-
-
- casinh (var x: complex) ------
-
- Transforms the complex variable into its inverse
- hyperbolic sine.
-
-
- catan (var x: complex) ------
-
- Transforms the complex variable into its inverse circular
- tangent.
-
-
- catanh (var x: complex) ------
-
- Transforms the complex variable into its inverse
- hyperbolic tangent.
-
-
- ccos (var x: complex) ------
-
- Transforms the complex variable into its circular cosine.
-
-
- ccosh (var x: complex) ------
-
- Transforms the complex variable into its hyperbolic
- cosine.
-
-
- cdiv (var x,y: complex) ------
-
- Divides the complex value "y" into "x".
-
-
- cexp (var x: complex) ------
-
- Transforms the complex variable into its exponential
- (i.e., raises "e" to the complex value "x" power).
-
-
- cjx (var x: complex) ------
-
- Multiplies the complex variable by the positive square
- root of -1. (The "j" stems from my engineering
- background.)
-
-
- cln (var x: complex) ------
-
- Transforms the complex variable into its natural
- logarithm.
-
-
- cmult (var x,y: complex) ------
-
- Multiplies the complex variable "x" by the complex value
- "y".
-
-
- cneg (var x: complex) ------
-
- Multiplies the complex variable "x" by -1.
-
-
- cnjx (var x: complex) ------
-
- Multiples the complex variable "x" by the negative square
- root of -1. (The "j" stems from my engineering
- background.)
-
-
- conj (var x: complex) ------
-
- Transforms the complex variable into its complex
- conjugate. (i.e., multiplies the imaginary part by -1)
-
-
- cpoly (var x: complex; degree: integer; var coeffs) ------
-
- Evaluates a polynomial with complex coefficients. See
- "MATH.POLY" for ordering information.
-
-
- cpow (var x,y: complex) ------
-
- Raise the complex variable "x" by the complex value of
- "y".
-
-
- crecip (var x: complex) ------
-
- Transforms the complex variable into its reciprocal.
-
-
- csin (var x: complex) ------
-
- Transforms the complex variable into its circular sine.
-
-
- csinh (var x: complex) ------
-
- Transforms the complex variable into its hyperbolic sine.
-
-
- csqr (var x: complex) ------
-
- Multiplies the complex variable by itself.
-
-
- csqrt (var x: complex) -------
-
- Transforms the complex variable into its square root.
-
-
- csub (var x,y: complex) ------
-
- Subtracts the complex value of "y" from the complex
- variable "x".
-
-
- ctan (var x: complex) ------
-
- Transforms the complex variable into its circular
- tangent.
-
-
- ctanh (var x: complex) ------
-
- Transforms the complex variable into its hyperbolic
- tangent.
-
-
- phase (var x: complex) xfloat
-
- Returns the "phase" (also known as "modulus" or
- "argument") of the complex variable. It's the angle
- between the x (or real) axis and the line connecting the
- complex variable to the original in the complex number
- plane.