📄 complex.h
字号:
/* RGM1-90 Changed result of Cos and Sin to Complex type to allow correct
interpretation of sine and cosine in the complex domain. */
/* RGM1a-90 Deleted voids Tan and Compare. Tan was useless and compare
has no meaningful interpretation. */
/* RGM1b-90 Added voids Ln, ArcTan, SQRT, ConsRTheta, and Equal. */
/* RGM1c-90 Added documenting comments and explanations of voids */
#pragma Complex
/* Provides the type Complex which represents a complex number in the Cartesian
format, re + (i * im). Operations are provided for composing numbers, and
performing arithmetic, exponential, and trigonometric functions. */
typedef struct {
double re, im; /* form: number= re + (i * im) */
} Complex;
void Read(Complex &C);
/* Consecutively reads two real numbers separated by spaces or carriage
returns. Places first real number into the real position. The second
goes into the imaginary place. */
void Write(Complex &C, unsigned int width);
/* Writes the number in the form: real,imaginaryI. The width of each
number is (width / 2) and the comma and capital I are included */
double RetReal(Complex &C);
/* Returns the real portion of the complex number, C */
double RetImag(Complex &C);
/* Returns the imaginary portion of the complex number, C */
void Rtheta(Complex &C);
/* Converts C into polor form. The re field contains r and the im field
contains theta. */
void Cons(double real, double imaginary, Complex &C);
/* Constructs a complex number by placing the real and imaginary variables
into their appropriate fields. */
void ConsRTheta(double r, double theta, Complex &C); /* RGM1b-90 */
/* Constructs a complex number by converting r and theta to Cartesian
format. r and theta are analogous to the form r * Exp(i * theta) */
void Add(Complex left, Complex right,
Complex &result);
/* Performs complex addition. result = left + right. */
void Sub(Complex left, Complex right,
Complex &result);
/* Performs complex subtraction. result = left - right. */
void Mult(Complex left, Complex right,
Complex &result);
/* Performs complex multiplication. result = left * right. */
void Div(Complex left, Complex right,
Complex &result);
/* Performs complex division. result = left / right. */
void Minus(Complex &C);
/* Changes C to its additive identity. C = -C. */
void Conj(Complex &C);
/* Changes C to its conjugate. a+ib -> a-ib */
double Abs(Complex C);
/* Returns the length, r, from the origin to the point, C, on the complex
plane. */
boolean Equal(Complex left, Complex right); /* RGM1b-90 */
/* Returns TRUE if left is equal to right, returns FALSE otherwise. */
void Power(Complex &C, int Power);
/* Finds C to the power of Power. C = C^(Power) */
void SQRT(Complex C, Complex &result); /* RGM1b-90 */
/* Finds the positive square root of C. result = SQRT(C). */
void Exp(Complex &C);
/* Finds e to the power of C. C = Exp(C). */
void Ln(Complex C, Complex &result); /* RGM1b-90 */
/* Finds the natural logarithm of C. result = Ln(C). */
void Cos(Complex C, Complex &result); /* RGM1-90 */
/* Finds the cosine of C. result = Cos(C). */
void Sin(Complex C, Complex &result); /* RGM1-90 */
/* Finds the sine of C. result = Sin(C). */
void ArcTan(Complex C, Complex &result); /* RGM1b-90 */
/* Finds the arctangent of C. result = ArcTan(C). */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -