Skip to content

Commit

Permalink
remove unused, remove functions from loops
Browse files Browse the repository at this point in the history
  • Loading branch information
GordonLesti committed Jan 7, 2015
1 parent 1b6d2a0 commit 9cad349
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .coveralls.yml
@@ -1 +1 @@
src_dir: src
src_dir: src
4 changes: 2 additions & 2 deletions 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/).

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
1 change: 0 additions & 1 deletion src/NumPHP/Core/NumArray.php
Expand Up @@ -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;

/**
Expand Down
1 change: 0 additions & 1 deletion src/NumPHP/Core/NumArray/Cache.php
Expand Up @@ -11,7 +11,6 @@

use NumPHP\Core\Exception\CacheException;
use NumPHP\Core\Exception\CacheKeyException;
use NumPHP\Core\Exception\CacheMissException;

/**
* Class Cache
Expand Down
3 changes: 2 additions & 1 deletion src/NumPHP/Core/NumArray/Dot.php
Expand Up @@ -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];
Expand Down
2 changes: 0 additions & 2 deletions src/NumPHP/Core/NumArray/Get.php
Expand Up @@ -9,8 +9,6 @@

namespace NumPHP\Core\NumArray;

use NumPHP\Core\NumArray;

/**
* Class Get
* @package NumPHP\Core\NumArray
Expand Down
8 changes: 5 additions & 3 deletions src/NumPHP/Core/NumArray/Map.php
Expand Up @@ -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);
}

Expand Down
5 changes: 3 additions & 2 deletions src/NumPHP/Core/NumPHP.php
Expand Up @@ -18,7 +18,7 @@
*/
abstract class NumPHP
{
const VERSION = '1.0.0-dev4';
const VERSION = '1.0.0-dev5';

/**
* @return NumArray
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/NumPHP/LinAlg/LinAlg.php
Expand Up @@ -19,7 +19,7 @@
*/
class LinAlg
{
const VERSION = '1.0.0-dev4';
const VERSION = '1.0.0-dev5';

/**
* @param $array
Expand Down

0 comments on commit 9cad349

Please sign in to comment.