Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Class to handle complex numbers natively

0.00/5 (No votes)
6 Dec 2006 1  
Over 100 methods, operators, and overloads.

Introduction

This is a different kind of complex number class for VB.NET than most of the ones I have seen. It is written so that the functions and operators can perform calculations natively by the calling class or method. It is indended to be highly extensible and easy to use.

For example, the arcSin function looks like this:

Public Function arcSin(ByVal z As Complex) As Complex 
     Return -i * Ln((i * z) + Sqrt(1 - z ^ 2)) 
End Function

..and the inverse hyperbolic cosecant looks like this:

Public Function arcCsch(ByVal z As Complex) As Complex
     Return Ln(Sqrt(1 + (1 / (z ^ 2))) + 1 / z)
End Function

These are the mathematical equations for complex numbers, and they will work for complex or real numbers. All 24 trigonometric and hyperbolic functions and their inverses are included in the source code.

Also included are operator and function overloads so that equations such as z+2 (mixing complex and real numbers (in this case doubles or integers)) is valid and allowed. Also perfectly valid are equations such as arcSin(2), where '2' is a real (Double) argument but the result is complex because there are no real number solutions for it.

Included is a class which contains the declarations, constructors, and operators, and a module which has all of the math code in it, and finally a Form class which provides some examples on how to declare and use the methods.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here