85 lines
3.6 KiB
XML
85 lines
3.6 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!--
|
|
Copyright 2003-2004 The Apache Software Foundation
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
|
<!-- $Revision: 1.1 $ $Date: 2004/04/26 20:06:50 $ -->
|
|
<document url="stat.html">
|
|
<properties>
|
|
<title>The Commons Math User Guide - Statistics</title>
|
|
</properties>
|
|
<body>
|
|
<section name="7 Complex Numbers">
|
|
<subsection name="7.1 Overview" href="overview">
|
|
<p>
|
|
The complex packages provides a complex number type as well as complex
|
|
versions of common transcendental functions and complex number
|
|
formatting.
|
|
</p>
|
|
</subsection>
|
|
<subsection name="7.2 Complex Numbers" href="complex">
|
|
<p>
|
|
<a href="../apidocs/org/apache/commons/math/complex/Complex.html">
|
|
org.apache.commons.math.complex.Complex</a> provides a complex number
|
|
type that forms the basis for the complex functionality found in
|
|
commons-math.
|
|
</p>
|
|
<p>
|
|
To create a complex number, simply call the constructor passing in two
|
|
floating-point arguments, the first being the real part of the
|
|
complex number and the second being the imaginary part:
|
|
<source>Complex c = new Complex(1.0, 3.0); // 1 + 3i</source>
|
|
</p>
|
|
<p>
|
|
The <code>Complex</code> class provides many unary and binary
|
|
complex number operations. These operations provide the means to add,
|
|
subtract, multiple and, divide complex numbers along with other
|
|
complex number functions similar to the real number functions found in
|
|
<code>java.math.BigDecimal</code>:
|
|
<source>Complex lhs = new Complex(1.0, 3.0);
|
|
Complex rhs = new Complex(2.0, 5.0);
|
|
|
|
Complex answer = lhs.add(rhs); // add two complex numbers
|
|
answer = lhs.subtract(rhs); // subtract two complex numbers
|
|
answer = lhs.abs(); // absolute value
|
|
answer = lhs.conjugate(rhs); // complex conjugate</source>
|
|
</p>
|
|
</subsection>
|
|
<subsection name="7.3 Complex Transcendental Functions" href="function">
|
|
<p>
|
|
<a href="../apidocs/org/apache/commons/math/complex/ComplexMath.html">
|
|
org.apache.commons.math.complex.ComplexMath</a> provides
|
|
implementations of serveral transcendental functions involving complex
|
|
number arguments. These operations provide the means to compute the
|
|
log, sine, tangent and, other complex values similar to the real
|
|
number functions found in <code>java.lang.Math</code>:
|
|
<source>Complex first = new Complex(1.0, 3.0);
|
|
Complex second = new Complex(2.0, 5.0);
|
|
|
|
Complex answer = ComplexMath.log(first); // natural logarithm.
|
|
answer = ComplexMath.cos(first); // cosine
|
|
answer = ComplexMath.pow(first, second); // first raised to the power of second</source>
|
|
</p>
|
|
</subsection>
|
|
<subsection name="7.4 Complex Formatting" href="formatting">
|
|
<p>This is yet to be written. Any contributions will be gratefully
|
|
accepted!</p>
|
|
</subsection>
|
|
</section>
|
|
</body>
|
|
</document>
|