webit / complex-number
该软件包最新版本(1.0.0)没有提供许可证信息。
Web-IT复数包装器
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-09-20 22:12:49 UTC
README
复数对象的包装器。提供不可变的 Complex 和 ComplexArray 类。支持以下操作:加法、减法、乘法、除法、平方根、绝对值以及与标量值的乘法。
安装
通过 Composer
将 webit/complex-number 添加到 composer.json
{ "require": { "php": ">=5.3.2", "webit/complex-number": "~1.0" } }
使用方法
$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"; }