Record TComplex

Unit

Declaration

type TComplex = record

Description

Represents a complex number in Cartesian form: z = Re + i·Im.

A complex number consists of:

The imaginary unit i is defined by i² = -1. All arithmetic operations follow standard complex number algebra.

Overview

Methods

Public function Arg: double;
Public function Conjugate: TComplex;
Public function IsNotNull: boolean;
Public function IsNull: boolean;
Public function Norm: double;
Public function Reciprocal: TComplex;
Public function SquaredNorm: double;
Public function ToString: string;
Public function ToString(APrecision, ADigits: integer): string;
Public procedure Zero;
Public class operator *(const ALeft: double; const ARight: TComplex): TComplex; inline;
Public class operator *(const ALeft: TComplex; const ARight: double): TComplex; inline;
Public class operator *(const ALeft, ARight: TComplex): TComplex; inline;
Public class operator +(const ALeft: double; const ARight: TComplex): TComplex; inline;
Public class operator +(const AValue: TComplex): TComplex; inline;
Public class operator +(const ALeft: TComplex; const ARight: double): TComplex; inline;
Public class operator +(const ALeft, ARight: TComplex): TComplex; inline;
Public class operator -(const ALeft: double; const ARight: TComplex): TComplex; inline;
Public class operator -(const AValue: TComplex): TComplex; inline;
Public class operator -(const ALeft: TComplex; const ARight: double): TComplex; inline;
Public class operator -(const ALeft, ARight: TComplex): TComplex; inline;
Public class operator /(const ALeft: double; const ARight: TComplex): TComplex; inline;
Public class operator /(const ALeft: TComplex; const ARight: double): TComplex; inline;
Public class operator /(const ALeft, ARight: TComplex): TComplex; inline;
Public class operator :=(const AValue: double): TComplex;
Public class operator <>(const ALeft, ARight: TComplex): boolean; inline;
Public class operator =(const ALeft, ARight: TComplex): boolean; inline;

Properties

Public property Im: double read fIm write fIm;
Public property Re: double read fRe write fRe;

Description

Methods

Public function Arg: double;

Returns the argument (phase angle) of the complex number, in radians. The argument is defined as φ = arctan(Im / Re), adjusted for quadrant. Returns a value in the range [-π, π].

Public function Conjugate: TComplex;

Returns the complex conjugate of the number. If z = a + i·b, the conjugate is z* = a - i·b.

Public function IsNotNull: boolean;

Returns True if the complex number is not zero, i.e. at least one of Re or Im is non-zero.

Public function IsNull: boolean;

Returns True if the complex number is zero, i.e. both Re = 0 and Im = 0.

Public function Norm: double;

Returns the modulus (magnitude) of the complex number. Defined as |z| = √(Re² + Im²).

Public function Reciprocal: TComplex;

Returns the reciprocal of the complex number: 1 / z.

Exceptions raised
Exception
if the number is zero, i.e. |z| = 0.
Public function SquaredNorm: double;

Returns the squared modulus of the complex number. Defined as |z|² = Re² + Im². Avoids the square root computation of Norm.

Public function ToString: string;

Converts the complex number to its default string representation. The format is a + bi or a - bi.

Public function ToString(APrecision, ADigits: integer): string;

Converts the complex number to a formatted string with controlled precision.

Parameters
APrecision
Number of significant digits for floating point formatting.
ADigits
Minimum number of digits in the output.
Public procedure Zero;

Sets the complex number to zero. After this call Re = 0.0 and Im = 0.0. Useful to reset a complex number before accumulating sums.

Public class operator *(const ALeft: double; const ARight: TComplex): TComplex; inline;

Returns the product of a real number and a complex number.

Public class operator *(const ALeft: TComplex; const ARight: double): TComplex; inline;

Returns the product of a complex number and a real number.

Public class operator *(const ALeft, ARight: TComplex): TComplex; inline;

Returns the product of two complex numbers. (a+bi)·(c+di) = (ac - bd) + (ad + bc)i

Public class operator +(const ALeft: double; const ARight: TComplex): TComplex; inline;

Returns the sum of a real number and a complex number.

Public class operator +(const AValue: TComplex): TComplex; inline;

Unary plus. Returns the complex number unchanged.

Public class operator +(const ALeft: TComplex; const ARight: double): TComplex; inline;

Returns the sum of a complex number and a real number.

Public class operator +(const ALeft, ARight: TComplex): TComplex; inline;

Returns the sum of two complex numbers: (a+bi) + (c+di) = (a+c) + (b+d)i.

Public class operator -(const ALeft: double; const ARight: TComplex): TComplex; inline;

Returns the difference of a real number and a complex number.

Public class operator -(const AValue: TComplex): TComplex; inline;

Unary minus. Returns the negation of the complex number: -(a+bi) = -a - bi.

Public class operator -(const ALeft: TComplex; const ARight: double): TComplex; inline;

Returns the difference of a complex number and a real number.

Public class operator -(const ALeft, ARight: TComplex): TComplex; inline;

Returns the difference of two complex numbers: (a+bi) - (c+di) = (a-c) + (b-d)i.

Public class operator /(const ALeft: double; const ARight: TComplex): TComplex; inline;

Returns the quotient of a real number divided by a complex number.

Public class operator /(const ALeft: TComplex; const ARight: double): TComplex; inline;

Returns the quotient of a complex number divided by a real number.

Public class operator /(const ALeft, ARight: TComplex): TComplex; inline;

Returns the quotient of two complex numbers.

Exceptions raised
Exception
if the divisor is zero, i.e. |ARight| = 0.
Public class operator :=(const AValue: double): TComplex;

Implicit conversion from a real value to a complex number. The resulting complex number has Im = 0.

Public class operator <>(const ALeft, ARight: TComplex): boolean; inline;

Returns True if the real or imaginary parts of the two operands differ.

Public class operator =(const ALeft, ARight: TComplex): boolean; inline;

Returns True if both the real and imaginary parts of the two operands are equal.

Properties

Public property Im: double read fIm write fIm;

Imaginary part of the complex number.

Public property Re: double read fRe write fRe;

Real part of the complex number.


Generated by PasDoc 1.0.4.