Output of file : CMPLX.PAS contained in archive : MANDEL1.ZIP
UNIT Cmplx;

{ In the following descriptions,
Capital letters (A, B) are real numbers or real parts of complex
numbers. Lowercase letters (a, b) are real factors of complex
parts. i is the square root of -1 (sqrt(-1)).

Sub_Comp (C1, C2, C_Out);
Mult_Comp (C1, C2, C_Out);
Mult_RC (C, R, C_Out);
Sub_C_From_R (R, C, C_Out);
Div_C_By_R (C, R, C_Out);
Size_Of_C (C);
Square_Size_Of_C (C);
}

INTERFACE

TYPE
Complex = RECORD
R, I: real
END;

VAR C: Complex);

PROCEDURE Sub_Comp (A, B: Complex;
VAR C: Complex);

PROCEDURE Mult_Comp (A, B: Complex;
VAR C: Complex);

PROCEDURE Div_Comp (A, B: Complex;
VAR C: Complex);

PROCEDURE Div_R_By_C (R: real;
C: Complex;
VAR C_Out: Complex);

PROCEDURE Mult_RC (C: Complex;
R: real;
VAR C_Out: Complex);

PROCEDURE Sub_C_From_R (R: real;
C: Complex;
VAR C_Out: Complex);

PROCEDURE Div_C_By_R (C: Complex;
R: real;
VAR C_Out: Complex);

FUNCTION Size_Of_C (C: Complex): real;
FUNCTION Square_Size_Of_C (C: Complex): real;

{********************************************************************}

IMPLEMENTATION

VAR C: Complex);

{ RESULT == (A+ai)+(B+bi) == A+ai+B+bi == (A+B)*(a+b)i }

BEGIN
C.R := A.R + B.R;
C.I := A.I + B.I;

{********************************************************************}

PROCEDURE Sub_Comp (A, B: Complex;
VAR C: Complex);

{ RESULT == (A+ai)-(B+bi) == A+ai-B+bi == (A-B)*(a-b)i }

BEGIN
C.R := A.R - B.R;
C.I := A.I - B.I;
END { Sub_Comp };

{********************************************************************}

PROCEDURE Mult_Comp (A, B: Complex;
VAR C: Complex);

{ RESULT == (A+ai)(B+bi) == AB + Abi + Bai + aibi == (AB-ab)+(Ab+aB)i}

BEGIN
C.R := A.R * B.R - A.I * B.I;
C.I := A.R * B.I + A.I * B.R;
END { Mult_Comp };

{********************************************************************}

PROCEDURE Div_Comp (A, B: Complex;
VAR C: Complex);

{RESULT == (A+ai)/(B+bi) == (AB + ab)/(B^2 + b^2) + ((aB - Ab)/(B^2 + b^2))i }

VAR
D: real;

BEGIN
D := Sqr (B.R) + Sqr (B.I);
C.R := (A.R * B.R + A.I * B.I)/D;
C.I := (A.I * B.R - A.R * B.I)/D;
END { Div_Comp };

{********************************************************************}

PROCEDURE Div_R_By_C (R: real;
C: Complex;
VAR C_Out: Complex);

VAR
A: Complex;

BEGIN
A.R := R;
A.I := 0;
Div_Comp (A, C, C_Out)
END {Div_R_By_C };

{*******************************************************************}

PROCEDURE Mult_RC (C: Complex;
R: real;
VAR C_Out: Complex);

{ RESULT == (C+ci)R == CR + cRi }

BEGIN
C_Out.R := C.R * R;
C_Out.I := C.I * R
END { Mult_RC };

{*********************************************************************}

PROCEDURE Sub_C_From_R (R: real;
C: Complex;
VAR C_Out: Complex);

{ RESULT == R-(C+ci) == R-C-ci == (R-C)-ci }

BEGIN
C_Out.R := R - C.R;
C_Out.I := -C.I
END { Sub_C_From_R };

{*********************************************************************}

PROCEDURE Div_C_By_R (C: Complex;
R: real;
VAR C_Out: Complex);

{ RESULT == (C+ci)/R == C/R + ci/R == (C/R)+(c/R)i }

BEGIN
C_Out.R := C.R / R;
C_Out.I := C.I / R
END { Div_C_By_R };

{*********************************************************************}

FUNCTION Size_Of_C (C: Complex): real;

BEGIN
Size_Of_C := Sqrt (Sqr (C.R) + Sqr (C.I))
END { Size_Of_C };

{*********************************************************************}

FUNCTION Square_Size_Of_C (C: Complex): real;

BEGIN
Square_Size_Of_C := Sqr (C.R) + Sqr (C.I)
END { Square_Size_Of_C };

END.


### 3 Responses to “Category : Printer + Display GraphicsArchive   : MANDEL1.ZIPFilename : CMPLX.PAS”

1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/