php-ml/tests/Phpml/Math/ProductTest.php

21 lines
532 B
PHP
Raw Normal View History

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
namespace tests\Phpml\Math;
use Phpml\Math\Product;
class ProductTest extends \PHPUnit_Framework_TestCase
{
public function testScalarProduct()
{
2016-04-21 20:12:45 +00: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]));
//test for non numeric values
$this->assertEquals(0, Product::scalar(['', null, [], new \stdClass()], [null]));
2016-04-20 22:23:03 +00:00
}
2016-04-25 20:55:34 +00:00
}