jcomplex
This project is a Java library for Complex Numbers. The Complex class is a modified version of the one in the project common-math developed by Apache Software Foundation.
This is a super lightweight project that provides support for complex numbers in Java.
Unlike the original Apache project, the Complex class in this library inherits from java.lang.Number.
How can I get the library?
You can download source and binaries from the release page.
Alternatively you can pull it from the central Maven repositories:
<dependency>
<groupId>com.github.vmicelli</groupId>
<artifactId>jcomplex</artifactId>
<version>1.0</version>
</dependency>
How to use
To use the library just create complex number instances and call the class methods.
// import complex number class
import com.vm.jcomplex.Complex;
...
// create number 12 + 13i
Complex number = new Complex(12, 13);
// create number for polar coordinates (modulus: 10, phase: Math.PI)
Complex numberFromPolar = Complex.fromPolar(10, Math.PI);
// sum the numbers
Complex sum = number.add(numberFromPolar);
The class provides many functions such as add, multiply, subtract, divide, sin, cos, tan, asin, acos, atan, exp, log, pow
and others. Operations methods return a new instance with the result.
Documentation
You can find javadoc here.
License
Code is under the Apache Licence v2.