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