From 9cad3490d003a64361485dd7dbfee802f8a99539 Mon Sep 17 00:00:00 2001 From: Gordon Lesti Date: Wed, 7 Jan 2015 08:24:15 +0100 Subject: [PATCH] remove unused, remove functions from loops --- .coveralls.yml | 2 +- README.md | 4 ++-- composer.json | 2 +- src/NumPHP/Core/NumArray.php | 1 - src/NumPHP/Core/NumArray/Cache.php | 1 - src/NumPHP/Core/NumArray/Dot.php | 3 ++- src/NumPHP/Core/NumArray/Get.php | 2 -- src/NumPHP/Core/NumArray/Map.php | 8 +++++--- src/NumPHP/Core/NumPHP.php | 5 +++-- src/NumPHP/LinAlg/LinAlg.php | 2 +- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.coveralls.yml b/.coveralls.yml index 7712ce0..7a18ce2 100644 --- a/.coveralls.yml +++ b/.coveralls.yml @@ -1 +1 @@ -src_dir: src \ No newline at end of file +src_dir: src diff --git a/README.md b/README.md index 3490b5c..a2c480e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # NumPHP -NumPHP is a PHP library for scientific computing. The main object is the `NumArray`, it can represent a scalar, a vector +NumPHP is a mathematical PHP library for scientific computing. The main object is the `NumArray`, it can represent a scalar, a vector or a matrix. Advanced matrix arithmetic for PHP. This project is inspired by the simplicity of [NumPy](http://www.numpy.org/). @@ -15,7 +15,7 @@ or a matrix. Advanced matrix arithmetic for PHP. This project is inspired by the ## Release Information -*NumPHP 1.0.0-dev4* +*NumPHP 1.0.0-dev5* ## Requirements diff --git a/composer.json b/composer.json index d8f1242..73c04a2 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "numphp/numphp", "type": "library", - "description": "PHP library for scientific computing", + "description": "Mathematical PHP library for scientific computing", "keywords": ["numeric"], "homepage": "http://numphp.org/", "license": "MIT", diff --git a/src/NumPHP/Core/NumArray.php b/src/NumPHP/Core/NumArray.php index 8d48c07..3352cf4 100644 --- a/src/NumPHP/Core/NumArray.php +++ b/src/NumPHP/Core/NumArray.php @@ -20,7 +20,6 @@ use NumPHP\Core\NumArray\Set; use NumPHP\Core\NumArray\Shape; use NumPHP\Core\NumArray\String; -use NumPHP\Core\NumArray\Sum; use NumPHP\Core\NumArray\Transpose; /** diff --git a/src/NumPHP/Core/NumArray/Cache.php b/src/NumPHP/Core/NumArray/Cache.php index a26d077..1a87dc8 100644 --- a/src/NumPHP/Core/NumArray/Cache.php +++ b/src/NumPHP/Core/NumArray/Cache.php @@ -11,7 +11,6 @@ use NumPHP\Core\Exception\CacheException; use NumPHP\Core\Exception\CacheKeyException; -use NumPHP\Core\Exception\CacheMissException; /** * Class Cache diff --git a/src/NumPHP/Core/NumArray/Dot.php b/src/NumPHP/Core/NumArray/Dot.php index ef5c98f..f77a3a9 100644 --- a/src/NumPHP/Core/NumArray/Dot.php +++ b/src/NumPHP/Core/NumArray/Dot.php @@ -161,9 +161,10 @@ protected static function dotMatrixVector(array $data1, array $data2) protected static function dotMatrixMatrix(array $data1, array $data2) { $product = []; + $size2 = count($data2[0]); foreach ($data1 as $i => $rowI) { $row = []; - for ($j = 0; $j < count($data2[0]); $j++) { + for ($j = 0; $j < $size2; $j++) { $sum = 0; foreach ($rowI as $key => $value1) { $sum += $value1 * $data2[$key][$j]; diff --git a/src/NumPHP/Core/NumArray/Get.php b/src/NumPHP/Core/NumArray/Get.php index 75e89bb..13da440 100644 --- a/src/NumPHP/Core/NumArray/Get.php +++ b/src/NumPHP/Core/NumArray/Get.php @@ -9,8 +9,6 @@ namespace NumPHP\Core\NumArray; -use NumPHP\Core\NumArray; - /** * Class Get * @package NumPHP\Core\NumArray diff --git a/src/NumPHP/Core/NumArray/Map.php b/src/NumPHP/Core/NumArray/Map.php index 4096162..88dd68f 100644 --- a/src/NumPHP/Core/NumArray/Map.php +++ b/src/NumPHP/Core/NumArray/Map.php @@ -39,21 +39,23 @@ public static function mapArray($array1, $array2, $callback) protected static function mapRecursive($data1, $data2, $callback) { if (is_array($data1)) { + $size1 = count($data1); if (is_array($data2)) { if (count($data1) !== count($data2)) { throw new InvalidArgumentException('Shape '.count($data1).' is different from '.count($data2)); } - for ($i = 0; $i < count($data1); $i++) { + for ($i = 0; $i < $size1; $i++) { $data1[$i] = self::mapRecursive($data1[$i], $data2[$i], $callback); } } else { - for ($i = 0; $i < count($data1); $i++) { + for ($i = 0; $i < $size1; $i++) { $data1[$i] = self::mapRecursive($data1[$i], $data2, $callback); } } } else { if (is_array($data2)) { - for ($i = 0; $i < count($data2); $i++) { + $size2 = count($data2); + for ($i = 0; $i < $size2; $i++) { $data2[$i] = self::mapRecursive($data1, $data2[$i], $callback); } diff --git a/src/NumPHP/Core/NumPHP.php b/src/NumPHP/Core/NumPHP.php index 8c2ff60..f33e063 100644 --- a/src/NumPHP/Core/NumPHP.php +++ b/src/NumPHP/Core/NumPHP.php @@ -18,7 +18,7 @@ */ abstract class NumPHP { - const VERSION = '1.0.0-dev4'; + const VERSION = '1.0.0-dev5'; /** * @return NumArray @@ -85,7 +85,8 @@ public static function eye($mAxis, $nAxis = -1) $nAxis = $mAxis; } $eye = self::zeros($mAxis, $nAxis); - for ($i = 0; $i < min($mAxis, $nAxis); $i++) { + $min = min($mAxis, $nAxis); + for ($i = 0; $i < $min; $i++) { $eye->set(1, $i, $i); } diff --git a/src/NumPHP/LinAlg/LinAlg.php b/src/NumPHP/LinAlg/LinAlg.php index 0cb92a4..eca8fa6 100644 --- a/src/NumPHP/LinAlg/LinAlg.php +++ b/src/NumPHP/LinAlg/LinAlg.php @@ -19,7 +19,7 @@ */ class LinAlg { - const VERSION = '1.0.0-dev4'; + const VERSION = '1.0.0-dev5'; /** * @param $array