diff --git a/src/Phpml/Math/Product.php b/src/Phpml/Math/Product.php new file mode 100644 index 0000000..992eeaa --- /dev/null +++ b/src/Phpml/Math/Product.php @@ -0,0 +1,25 @@ + $value) { + $product += $value * $b[$index]; + } + + return $product; + } + +} diff --git a/tests/Phpml/Math/ProductTest.php b/tests/Phpml/Math/ProductTest.php new file mode 100644 index 0000000..d7aa015 --- /dev/null +++ b/tests/Phpml/Math/ProductTest.php @@ -0,0 +1,20 @@ +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])); + } + +} \ No newline at end of file