CFLib.org – Common Function Library Project

ComplexNum(Real, Imaginary)

Last updated November 15, 2001

Version: 1 | Requires: ColdFusion 5 | Library: MathLib

 
Rated 0 time(s). Average Rating: 0

Description:
This function simply builds a structure representing a complex number. This is a useful format to enable working with complex numbers.

Return Values:
Returns a structure representing a complex number with the keys R and I.

Example:

view plain print about
<cfset c = ComplexNum(5,-1)>
<cfdump var="#c#">

Parameters:

Name Description Required
Real Real part of the complex number. Yes
Imaginary Imaginary part of the complex number. Yes

Full UDF Source:

view plain print about
<cfscript>
/**
 * Create a complex number as a structure.
 * 
 * @param Real      Real part of the complex number. 
 * @param Imaginary      Imaginary part of the complex number. 
 * @return Returns a structure representing a complex number with the keys R and I. 
 * @author Matthew Walker (matthew@electricsheep.co.nz) 
 * @version 1, November 15, 2001 
 */

function ComplexNum(Real,Imaginary) {
  var ComplexNumber = StructNew();
  ComplexNumber.R=Real;
  ComplexNumber.I=Imaginary;
  return ComplexNumber;
}
</cfscript>
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Dave Anderson Dave Anderson added
iniToStruct
20 day(s) ago

Dave Anderson Dave Anderson added
deDupeArray
20 day(s) ago

Richard Richard added
dice
22 day(s) ago

Isaac Dealey Isaac Dealey added
getRelative
a while ago

Top Rated

Darwan Leonardo Sitepu backupDatabase
Rated 5.0, 22 time(s)

Barney Boisvert indentXml
Rated 5.0, 10 time(s)

Kevin Pepperman generateSsccAsn
Rated 5.0, 4 time(s)

Raymond Camden highlightAndCrop
Rated 5.0, 4 time(s)

Created by Raymond Camden / Design by Justin Johnson