Category : C++ Source Code
Archive   : ZPP10.ZIP
Filename : Z_TEST.CPP

 
Output of file : Z_TEST.CPP contained in archive : ZPP10.ZIP
/* -------------------------------------------------------------------- */
/* z_test.cpp */
/* Revised 04/01/92 */
/* */
/* Copyright 1992 by Carl W. Moreland */
/* */
/* Test program for the Z++ complex number class. */
/* This source code may be freely distributed as long as the copyright */
/* notice remains intact. */
/* -------------------------------------------------------------------- */

#include
#include
#include
#include "complex.h"

void pause(void);

main()
{
_setcursortype(_NOCURSOR);
clrscr();

cout << "\r\n\r\n\r\n\r\n\r\n\r\n";
cout << " Z++ \r\n";
cout << " \r\n";
cout << " Complex number class \r\n";
cout << " Version 1.0 \r\n";
cout << " \r\n";
cout << " Written by Carl Moreland \r\n";
cout << " \r\n";
cout << " Hit any key to continue, \r\n";
cout << " or C to exit \r\n";

pause();

complex z1(3,4);
complex z2 = complex(5,-6);
complex z3;
z3 = 10.5;

cout << "\r\n";
cout << "Create some complex numbers:\r\n\r\n";
cout << "complex z1(3,4);\r\n";
cout << "complex z2 = complex(5,-6);\r\n";
cout << "complex z3;\r\n";
cout << "z3 = 10.5;\r\n\r\n";

cout << "The results are:\r\n\r\n";
cout << "z1 = " << z1 << "\r\n";
cout << "z2 = " << z2 << "\r\n";
cout << "z3 = " << z3 << "\r\n";
cout << "\r\n";
cout << "complex z2c = conj(z2);\r\n";
cout << "The complex conjugate of z2 is " << conj(z2) << "\r\n";
cout << "-z2 = " << -z2 << "\r\n";

pause();

cout << "The magnitude and angle of z1, z2, & z3 are:\r\n\r\n";
cout << "mag(z1) = " << mag(z1) << "\r\n";
cout << "ang(z1) = " << ang(z1) << " (radians)\r\n";
cout << "mag(z2) = " << mag(z2) << "\r\n";
cout << "ang(z2) = " << ang(z2) << " (radians)\r\n";
cout << "mag(z3) = " << mag(z3) << "\r\n";
cout << "ang(z3) = " << ang(z3) << " (radians)\r\n";
cout << "\r\n";

cout << "Now set the angle mode to degrees:\r\n";
Complex.SetArgMode(Z_DEGREES);
cout << "Complex.SetMode(Z_DEGREES);\r\n\r\n";

cout << "ang(z1) = " << ang(z1) << "ø\r\n";
cout << "ang(z2) = " << ang(z2) << "ø\r\n";
cout << "ang(z3) = " << ang(z3) << "ø\r\n";

Complex.SetArgMode(Z_RADIANS);
cout << "\nComplex.SetMode(Z_RADIANS);\r\n";

pause();

complex z4 = z1 + z2;
complex z5 = z1 - z2;
complex z6 = z1 * z2;
complex z7 = z1 / z2;

cout << "Now use some overloaded operators:\r\n\r\n";
cout << "complex z4 = z1 + z2;\r\n";
cout << "complex z5 = z1 - z2;\r\n";
cout << "complex z6 = z1 * z2;\r\n";
cout << "complex z7 = z1 / z2;\r\n";
cout << "\r\n";
cout << "z4 = " << z4 << "\r\n";
cout << "z5 = " << z5 << "\r\n";
cout << "z6 = " << z6 << "\r\n";
cout << "z7 = " << z7 << "\r\n";
cout << "\r\n";

pause();

z4 += z1;
z5 -= z1;
z6 *= z1;
z7 /= z1;

cout << "More overloaded operators:\n\r\n";
cout << "z4 += z1;\r\n";
cout << "z5 -= z1;\r\n";
cout << "z6 *= z1;\r\n";
cout << "z7 /= z1;\r\n";
cout << "\r\n";
cout << "z4 = " << z4 << "\r\n";
cout << "z5 = " << z5 << "\r\n";
cout << "z6 = " << z6 << "\r\n";
cout << "z7 = " << z7 << "\r\n";
cout << "\r\n";

Complex.SetPrintMode(Z_LETTER);

cout << "Complex.SetPrintMode(Z_LETTER);\r\n";
cout << "z4 = " << z4 << "\r\n";
cout << "z5 = " << z5 << "\r\n";
cout << "\r\n";

Complex.SetLetter('j');

cout << "Complex.SetLetter('j');\r\n";
cout << "z6 = " << z6 << "\r\n";
cout << "z7 = " << z7 << "\r\n";
cout << "\r\n";

Complex.SetLetter('i');
cout << "Complex.SetLetter('i');\r\n";

pause();

z4 = sqrt(z1);
z5 = pow(z1, 1.2);
z6 = pow(z1, z2);
z7 = pow(1.2, z1);

cout << "Overloaded C power functions:\r\n\r\n";
cout << "z4 = sqrt(z1);\r\n";
cout << "z5 = pow(z1, 1.2);\r\n";
cout << "z6 = pow(z1, z2);\r\n";
cout << "z7 = pow(1.2, z1);\r\n";
cout << "\r\n";
cout << "z4 = " << z4 << "\r\n";
cout << "z5 = " << z5 << "\r\n";
cout << "z6 = " << z6 << "\r\n";
cout << "z7 = " << z7 << "\r\n";

pause();

z4 = sin(z1);
z5 = cos(z1);
z6 = exp(z1);
z7 = log(z1);

cout << "Overloaded C trig functions:\r\n\r\n";
cout << "z4 = sin(z1);\r\n";
cout << "z5 = cos(z1);\r\n";
cout << "z6 = exp(z1);\r\n";
cout << "z7 = log(z1);\r\n";
cout << "\r\n";
cout << "z4 = " << z4 << "\r\n";
cout << "z5 = " << z5 << "\r\n";
cout << "z6 = " << z6 << "\r\n";
cout << "z7 = " << z7 << "\r\n";

pause();

cout << "Here are some useful constants that are declared in complex.h:\r\n\r\n";
cout << "Z0 = " << Z0 << "\r\n";
cout << "Z1 = " << Z1 << "\r\n";
cout << "Zi = " << Zi << "\r\n";
cout << "Zinf = " << Zinf << "\r\n";

pause();

return 0;
}

void pause(void)
{
char ch = getch();
if(!ch)
getch();
if(ch == 0x03)
exit(0);
clrscr();
cout << "\r\n";
}

  3 Responses to “Category : C++ Source Code
Archive   : ZPP10.ZIP
Filename : Z_TEST.CPP

  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/