webit / complex-number
There is no license information available for the latest version (1.0.0) of this package.
Web-IT Complex number wrapper
1.0.0
2015-05-09 09:49 UTC
Requires
- php: >=5.3.3
Requires (Dev)
- phpunit/phpunit: ~4.2
This package is auto-updated.
Last update: 2024-10-20 22:25:37 UTC
README
Object wrapper for Complex Number. Provides immutable Complex and ComplexArray classes. Supports operations like: adding, subtraction, multiplication, dividing, square root, absolute and multiplication by scalar value.
Installation
via Composer
Add the webit/complex-number into composer.json
{ "require": { "php": ">=5.3.2", "webit/complex-number": "~1.0" } }
Usage
$num1 = new Complex(1, 3); // (real, imaginary) // or $num2 = Complex::create(5, 5); $sum = $num1->add($num2); $diff = $num1->sub($num2); $prod = $num1->mul($num2); $quot = $num1->div($num2); $sqrt = $num1->sqrt(); $abs = $num1->abs(); // scalar $conjugated = $num1->getConjugated(); $complexArray1 = new ComplexArray(array(23.4, 23.55)); // accepts array of floats or array of Complex // or $complexArray2 = ComplexArray::create(array(23.4, 23.55)); foreach ($complexArray1 as $complex) { echo $complex ."\n"; }