2016-04-21 00:23:03 +02:00
|
|
|
<?php
|
2016-04-25 22:55:34 +02:00
|
|
|
|
2016-11-20 22:53:17 +01:00
|
|
|
declare(strict_types=1);
|
2016-04-21 00:23:03 +02:00
|
|
|
|
|
|
|
namespace tests\Phpml\Math;
|
|
|
|
|
|
|
|
use Phpml\Math\Product;
|
2017-02-03 12:58:25 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
2016-04-21 00:23:03 +02:00
|
|
|
|
2017-02-03 12:58:25 +01:00
|
|
|
class ProductTest extends TestCase
|
2016-04-21 00:23:03 +02:00
|
|
|
{
|
|
|
|
public function testScalarProduct()
|
|
|
|
{
|
2016-04-21 22:12:45 +02:00
|
|
|
$this->assertEquals(10, Product::scalar([2, 3], [-1, 4]));
|
|
|
|
$this->assertEquals(-0.1, Product::scalar([1, 4, 1], [-2, 0.5, -0.1]));
|
|
|
|
$this->assertEquals(8, Product::scalar([2], [4]));
|
2016-08-02 13:07:47 +02:00
|
|
|
|
2016-07-26 02:13:52 -04:00
|
|
|
//test for non numeric values
|
|
|
|
$this->assertEquals(0, Product::scalar(['', null, [], new \stdClass()], [null]));
|
2016-04-21 00:23:03 +02:00
|
|
|
}
|
2016-04-25 22:55:34 +02:00
|
|
|
}
|