C# Class AForge.Math.Complex

Complex number wrapper class.

The class encapsulates complex number and provides set of different operators to manipulate it, lake adding, subtractio, multiplication, etc.

Sample usage:

// define two complex numbers Complex c1 = new Complex( 3, 9 ); Complex c2 = new Complex( 8, 3 ); // sum Complex s1 = Complex.Add( c1, c2 ); Complex s2 = c1 + c2; Complex s3 = c1 + 5; // difference Complex d1 = Complex.Subtract( c1, c2 ); Complex d2 = c1 - c2; Complex d3 = c1 - 2;
Datei anzeigen Open project: atosorigin/Kinect Class Usage Examples

Public Properties

Property Type Description
I Complex
Im double
One Complex
Re double
Zero Complex

Public Methods

Method Description
Add ( Complex a, Complex b ) : Complex

Adds two complex numbers.

Add ( Complex a, double s ) : Complex

Adds scalar value to a complex number.

Add ( Complex a, Complex b, Complex &result ) : void

Adds two complex numbers and puts the result into the third complex number.

Add ( Complex a, double s, Complex &result ) : void

Adds scalar value to a complex number and puts the result into another complex number.

ApproxEqual ( Complex a, Complex b ) : bool

Tests whether two complex numbers are approximately equal using default tolerance value.

The default tolerance value, which is used for the test, equals to 8.8817841970012523233891E-16.

ApproxEqual ( Complex a, Complex b, double tolerance ) : bool

Tests whether two complex numbers are approximately equal given a tolerance value.

The default tolerance value, which is used for the test, equals to 8.8817841970012523233891E-16.

Clone ( ) : Complex

Creates an exact copy of this Complex object.

Complex ( Complex c ) : System

Initializes a new instance of the Complex class.

Complex ( double re, double im ) : System

Initializes a new instance of the Complex class.

Cos ( Complex a ) : Complex

Calculates Cosine value of the complex number.

Divide ( Complex a, Complex b ) : Complex

Divides one complex number by another complex number.

Divide ( Complex a, double s ) : Complex

Divides a complex number by a scalar value.

Divide ( double s, Complex a ) : Complex

Divides a scalar value by a complex number.

Divide ( Complex a, Complex b, Complex &result ) : void

Divides one complex number by another complex number and puts the result in a third complex number.

Divide ( Complex a, double s, Complex &result ) : void

Divides a complex number by a scalar value and puts the result into another complex number.

Divide ( double s, Complex a, Complex &result ) : void

Divides a scalar value by a complex number and puts the result into another complex number.

Equals ( object obj ) : bool

Returns a value indicating whether this instance is equal to the specified object.

Exp ( Complex a ) : Complex

Calculates exponent (e raised to the specified power) of a complex number.

GetHashCode ( ) : int

Returns the hashcode for this instance.

GetObjectData ( SerializationInfo info, StreamingContext context ) : void

Populates a SerializationInfo with the data needed to serialize the target object.

Log ( Complex a ) : Complex

Calculates natural (base e) logarithm of a complex number.

Multiply ( Complex a, Complex b ) : Complex

Multiplies two complex numbers.

Multiply ( Complex a, double s ) : Complex

Multiplies a complex number by a scalar value.

Multiply ( Complex a, Complex b, Complex &result ) : void

Multiplies two complex numbers and puts the result in a third complex number.

Multiply ( Complex a, double s, Complex &result ) : void

Multiplies a complex number by a scalar value and puts the result into another complex number.

Negate ( Complex a ) : Complex

Negates a complex number.

Parse ( string s ) : Complex

Converts the specified string to its Complex equivalent.

Sin ( Complex a ) : Complex

Calculates Sine value of the complex number.

Sqrt ( Complex a ) : Complex

Calculates square root of a complex number.

Subtract ( Complex a, Complex b ) : Complex

Subtracts one complex number from another.

Subtract ( Complex a, double s ) : Complex

Subtracts a scalar from a complex number.

Subtract ( double s, Complex a ) : Complex

Subtracts a complex number from a scalar value.

Subtract ( Complex a, Complex b, Complex &result ) : void

Subtracts one complex number from another and puts the result in the third complex number.

Subtract ( Complex a, double s, Complex &result ) : void

Subtracts a scalar value from a complex number and puts the result into another complex number.

Subtract ( double s, Complex a, Complex &result ) : void

Subtracts a complex number from a scalar value and puts the result into another complex number.

Tan ( Complex a ) : Complex

Calculates Tangent value of the complex number.

ToString ( ) : string

Returns a string representation of this object.

TryParse ( string s, Complex &result ) : bool

Try to convert the specified string to its Complex equivalent.

operator ( ) : Complex

Negates the complex number.

operator ( ) : bool

Tests whether two specified complex numbers are equal.

Private Methods

Method Description
ICloneable ( ) : object

Creates an exact copy of this Complex object.

Method Details

Add() public static method

Adds two complex numbers.
public static Add ( Complex a, Complex b ) : Complex
a Complex A instance.
b Complex A instance.
return Complex

Add() public static method

Adds scalar value to a complex number.
public static Add ( Complex a, double s ) : Complex
a Complex A instance.
s double A scalar value.
return Complex

Add() public static method

Adds two complex numbers and puts the result into the third complex number.
public static Add ( Complex a, Complex b, Complex &result ) : void
a Complex A instance.
b Complex A instance.
result Complex A instance to hold the result.
return void

Add() public static method

Adds scalar value to a complex number and puts the result into another complex number.
public static Add ( Complex a, double s, Complex &result ) : void
a Complex A instance.
s double A scalar value.
result Complex A instance to hold the result.
return void

ApproxEqual() public static method

Tests whether two complex numbers are approximately equal using default tolerance value.

The default tolerance value, which is used for the test, equals to 8.8817841970012523233891E-16.

public static ApproxEqual ( Complex a, Complex b ) : bool
a Complex A instance.
b Complex A instance.
return bool

ApproxEqual() public static method

Tests whether two complex numbers are approximately equal given a tolerance value.

The default tolerance value, which is used for the test, equals to 8.8817841970012523233891E-16.

public static ApproxEqual ( Complex a, Complex b, double tolerance ) : bool
a Complex A instance.
b Complex A instance.
tolerance double The tolerance value used to test approximate equality.
return bool

Clone() public method

Creates an exact copy of this Complex object.
public Clone ( ) : Complex
return Complex

Complex() public method

Initializes a new instance of the Complex class.
public Complex ( Complex c ) : System
c Complex Source complex number.
return System

Complex() public method

Initializes a new instance of the Complex class.
public Complex ( double re, double im ) : System
re double Real part.
im double Imaginary part.
return System

Cos() public static method

Calculates Cosine value of the complex number.
public static Cos ( Complex a ) : Complex
a Complex A instance.
return Complex

Divide() public static method

Divides one complex number by another complex number.
Can not divide by zero.
public static Divide ( Complex a, Complex b ) : Complex
a Complex A instance.
b Complex A instance.
return Complex

Divide() public static method

Divides a complex number by a scalar value.
Can not divide by zero.
public static Divide ( Complex a, double s ) : Complex
a Complex A instance.
s double A scalar value.
return Complex

Divide() public static method

Divides a scalar value by a complex number.
Can not divide by zero.
public static Divide ( double s, Complex a ) : Complex
s double A scalar value.
a Complex A instance.
return Complex

Divide() public static method

Divides one complex number by another complex number and puts the result in a third complex number.
Can not divide by zero.
public static Divide ( Complex a, Complex b, Complex &result ) : void
a Complex A instance.
b Complex A instance.
result Complex A instance to hold the result.
return void

Divide() public static method

Divides a complex number by a scalar value and puts the result into another complex number.
Can not divide by zero.
public static Divide ( Complex a, double s, Complex &result ) : void
a Complex A instance.
s double A scalar value.
result Complex A instance to hold the result.
return void

Divide() public static method

Divides a scalar value by a complex number and puts the result into another complex number.
Can not divide by zero.
public static Divide ( double s, Complex a, Complex &result ) : void
s double A scalar value.
a Complex A instance.
result Complex A instance to hold the result.
return void

Equals() public method

Returns a value indicating whether this instance is equal to the specified object.
public Equals ( object obj ) : bool
obj object An object to compare to this instance.
return bool

Exp() public static method

Calculates exponent (e raised to the specified power) of a complex number.
public static Exp ( Complex a ) : Complex
a Complex A instance.
return Complex

GetHashCode() public method

Returns the hashcode for this instance.
public GetHashCode ( ) : int
return int

GetObjectData() public method

Populates a SerializationInfo with the data needed to serialize the target object.
public GetObjectData ( SerializationInfo info, StreamingContext context ) : void
info System.Runtime.Serialization.SerializationInfo The to populate with data.
context System.Runtime.Serialization.StreamingContext The destination (see ) for this serialization.
return void

Log() public static method

Calculates natural (base e) logarithm of a complex number.
public static Log ( Complex a ) : Complex
a Complex A instance.
return Complex

Multiply() public static method

Multiplies two complex numbers.
public static Multiply ( Complex a, Complex b ) : Complex
a Complex A instance.
b Complex A instance.
return Complex

Multiply() public static method

Multiplies a complex number by a scalar value.
public static Multiply ( Complex a, double s ) : Complex
a Complex A instance.
s double A scalar value.
return Complex

Multiply() public static method

Multiplies two complex numbers and puts the result in a third complex number.
public static Multiply ( Complex a, Complex b, Complex &result ) : void
a Complex A instance.
b Complex A instance.
result Complex A instance to hold the result.
return void

Multiply() public static method

Multiplies a complex number by a scalar value and puts the result into another complex number.
public static Multiply ( Complex a, double s, Complex &result ) : void
a Complex A instance.
s double A scalar value.
result Complex A instance to hold the result.
return void

Negate() public static method

Negates a complex number.
public static Negate ( Complex a ) : Complex
a Complex A instance.
return Complex

Parse() public static method

Converts the specified string to its Complex equivalent.
String representation of the complex number is not correctly formatted.
public static Parse ( string s ) : Complex
s string A string representation of a complex number.
return Complex

Sin() public static method

Calculates Sine value of the complex number.
public static Sin ( Complex a ) : Complex
a Complex A instance.
return Complex

Sqrt() public static method

Calculates square root of a complex number.
public static Sqrt ( Complex a ) : Complex
a Complex A instance.
return Complex

Subtract() public static method

Subtracts one complex number from another.
public static Subtract ( Complex a, Complex b ) : Complex
a Complex A instance to subtract from.
b Complex A instance to be subtracted.
return Complex

Subtract() public static method

Subtracts a scalar from a complex number.
public static Subtract ( Complex a, double s ) : Complex
a Complex A instance to subtract from.
s double A scalar value to be subtracted.
return Complex

Subtract() public static method

Subtracts a complex number from a scalar value.
public static Subtract ( double s, Complex a ) : Complex
s double A scalar value to subtract from.
a Complex A instance to be subtracted.
return Complex

Subtract() public static method

Subtracts one complex number from another and puts the result in the third complex number.
public static Subtract ( Complex a, Complex b, Complex &result ) : void
a Complex A instance to subtract from.
b Complex A instance to be subtracted.
result Complex A instance to hold the result.
return void

Subtract() public static method

Subtracts a scalar value from a complex number and puts the result into another complex number.
public static Subtract ( Complex a, double s, Complex &result ) : void
a Complex A instance to subtract from.
s double A scalar value to be subtracted.
result Complex A instance to hold the result.
return void

Subtract() public static method

Subtracts a complex number from a scalar value and puts the result into another complex number.
public static Subtract ( double s, Complex a, Complex &result ) : void
s double A scalar value to subtract from.
a Complex A instance to be subtracted.
result Complex A instance to hold the result.
return void

Tan() public static method

Calculates Tangent value of the complex number.
public static Tan ( Complex a ) : Complex
a Complex A instance.
return Complex

ToString() public method

Returns a string representation of this object.
public ToString ( ) : string
return string

TryParse() public static method

Try to convert the specified string to its Complex equivalent.
public static TryParse ( string s, Complex &result ) : bool
s string A string representation of a complex number.
result Complex instance to output the result to.
return bool

operator() public static method

Negates the complex number.
public static operator ( ) : Complex
return Complex

operator() public static method

Tests whether two specified complex numbers are equal.
public static operator ( ) : bool
return bool

Property Details

I public_oe static_oe property

A double-precision complex number that represents the squere root of (-1).
public static Complex I
return Complex

Im public_oe property

Imaginary part of the complex number.
public double Im
return double

One public_oe static_oe property

A double-precision complex number that represents one.
public static Complex One
return Complex

Re public_oe property

Real part of the complex number.
public double Re
return double

Zero public_oe static_oe property

A double-precision complex number that represents zero.
public static Complex Zero
return Complex