Skip to content
This repository was archived by the owner on Jul 10, 2023. It is now read-only.

Dev #20

Merged
merged 29 commits into from
Mar 27, 2018
Merged

Dev #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88cbbe6
Updated .travis.yml
henrique-borba Mar 26, 2018
dfac4cc
Updated .travis.yml with new OS configuration
henrique-borba Mar 26, 2018
77588ea
Reduced test sizes for travis memory limits.
henrique-borba Mar 26, 2018
b623a98
Removed clover coverage from testing.
henrique-borba Mar 26, 2018
6e4e8b8
Removed coveralls. Removed PHP 7.1 support after too many zend_heap p…
henrique-borba Mar 26, 2018
1d5e403
Allow failures for PHP 7.0 and PHP 7.1 for future investigation.
henrique-borba Mar 26, 2018
165a122
Testing new travis.yml build
henrique-borba Mar 26, 2018
d3993e9
Testing old configuration with .travis
henrique-borba Mar 26, 2018
912de43
Updated Transformable operations and CArray to new C implementation.
henrique-borba Mar 26, 2018
6adf37b
Updated travis-ci
henrique-borba Mar 26, 2018
f3125dd
Test Travis
henrique-borba Mar 26, 2018
5bd107f
Added logo to README.MD
henrique-borba Mar 27, 2018
a933749
High quality README.MD logo
henrique-borba Mar 27, 2018
520756d
Merge branch 'master' into dev
henrique-borba Mar 27, 2018
e94256e
Logo image reduction on README.MD
henrique-borba Mar 27, 2018
e086191
Merge remote-tracking branch 'origin/dev' into dev
henrique-borba Mar 27, 2018
2528016
Merge branch 'master' into dev
henrique-borba Mar 27, 2018
c368ba6
Implemented __toString for handle CArray print_r static method. Imple…
henrique-borba Mar 27, 2018
a5c2d59
Merge remote-tracking branch 'origin/dev' into dev
henrique-borba Mar 27, 2018
0c7cb36
Implemented recently logspace CArray initializer.
henrique-borba Mar 27, 2018
1cf3cce
Don't use ZEND_ALLOCATION during travis build for test purposes.
henrique-borba Mar 27, 2018
6b7749e
Removed CCACHE from travis file.
henrique-borba Mar 27, 2018
88c8441
Added PHP 7.2.3 to travis file.
henrique-borba Mar 27, 2018
ad3b481
Implemented `asarray` for NumPy compatibilities (alias of toArray). A…
henrique-borba Mar 27, 2018
fae7848
Merge remote-tracking branch 'remotes/origin/master' into dev
henrique-borba Mar 27, 2018
504829b
Removed travis for now.
henrique-borba Mar 27, 2018
f1d2d7d
Merge branch 'master' into dev
henrique-borba Mar 27, 2018
8b107f7
Updated README.MD
henrique-borba Mar 27, 2018
094424f
Merge remote-tracking branch 'origin/dev' into dev
henrique-borba Mar 27, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ matrix:
fast_finish: true
allow_failures:
- php: 7.1
- php: 7.2
- php: 7.2.3


Expand Down
135 changes: 11 additions & 124 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ composer require phpsci/phpsci:dev-master

## Getting Started

You can create an CArray using the default constructor:
You can create an CArray using the `fromArray` static method:

```php
$autoloader = require_once dirname(__DIR__) . '/vendor/autoload.php';

use PHPSci\PHPSci as psci;

$matrix = new psci([[2 , 4], [6 , 9]]);
$matrix = psci::fromArray([[2 , 4], [6 , 9]]);
echo $matrix;
```

Expand All @@ -50,7 +50,7 @@ echo $matrix;
[ 6 9 ]
]
```

Let's transpose our recently created Matrix:
```php
echo psci::transpose($matrix);
```
Expand All @@ -64,135 +64,22 @@ echo psci::transpose($matrix);

## How it works?

PHPSci is powered by **CArrays**.
In every executed operation, PHPSci turns your PHP array into a CArray, try to look at the CArray as something like
Numpy's NDArray (NOTICE: they work extremely different, CArray just pretend to be equal using abtractions).
PHPSci is powered by **CArrays**. To understand more about how it works, read [PHPSci CArrays](https://www.github.com/phpsci/phpsci-ext)
and it [documentation](http://phpsci-carray.readthedocs.io).

### Inside CArrays
A `print_r` look at a CArray
```php
PHPSci\PHPSci Object
(
[value:PHPSci\PHPSci:private] =>
[c_array:protected] => CPHPSci Object
[internal_pointer:protected] => PHPSci\Kernel\Orchestrator\MemoryPointer Object
(
[dim] => 2
[rows] => 2
[cols] => 2
[c_array_size] => 48
[php_array] => Array
(
[0] => Array
(
[0] => 0
[1] => 1
)

[1] => Array
(
[0] => 2
[1] => 3
)

)

[uuid:protected] => 1
[rows:protected] => 2
[cols:protected] => 2
)

)
```
Everything inside `[c_array:protected] => CPHPSci Object` is generated
by C code.

## Performance
Some tests made with i5, 8GB RAM, 64-bits machine with Fedora 27 and
4GB available for PHP.

`Must recent tests`

#### PHP Array to CArray
Creating CArrays from PHP arrays with shape `(rows,cols)`.
NOTICE: This does'nt include the time PHP took to create it own array.
```php
CREATE CARRAY PHPSCI
========================================
CArray (100,100): 4.0E-6 sec(s)
CArray (200,200): 6.0E-6 sec(s)
CArray (300,300): 6.0E-6 sec(s)
CArray (400,400): 6.0E-6 sec(s)
CArray (500,500): 6.0E-6 sec(s)
CArray (600,600): 7.0E-6 sec(s)
CArray (700,700): 6.0E-6 sec(s)
CArray (800,800): 6.0E-6 sec(s)
CArray (900,900): 7.0E-6 sec(s)
```
With PHP array creation time:
```php
CREATE CARRAY PHPSCI W/ PHP TIME INCLUDED
========================================
CArray (100,100): 0.02138790133667 sec(s)
CArray (200,200): 0.070839967758179 sec(s)
CArray (300,300): 0.15959695954895 sec(s)
CArray (400,400): 0.28583201411438 sec(s)
CArray (500,500): 0.44160203118896 sec(s)
CArray (600,600): 0.63806594715881 sec(s)
CArray (700,700): 0.86629609246826 sec(s)
CArray (800,800): 1.1416860022125 sec(s)
CArray (900,900): 1.4429839515991 sec(s)
```
#### Matrix Multiplication
Matmul with CArrays from PHP arrays with shape `(rows,cols)`.
NOTICE: Only the operation time.
```php
MATMUL PHPSCI
========================================
CArray (100,100): 0.0044419765472412 sec(s)
CArray (200,200): 0.0084681510925293 sec(s)
CArray (300,300): 0.027091979980469 sec(s)
CArray (400,400): 0.069776773452759 sec(s)
CArray (500,500): 0.13852596282959 sec(s)
CArray (600,600): 0.24525594711304 sec(s)
CArray (700,700): 0.39853596687317 sec(s)
CArray (800,800): 0.57897710800171 sec(s)
CArray (900,900): 1.2307569980621 sec(s)
```
```php
MATMUL PHP IJK
========================================
PHP Array (100,100): 0.28780794143677 sec(s)
PHP Array (200,200): 2.2915270328522 sec(s)
PHP Array (300,300): 7.7198770046234 sec(s)
PHP Array (400,400): 18.349531173706 sec(s)
PHP Array (500,500): 36.395827054977 sec(s)
PHP Array (600,600): 62.111531972885 sec(s)
PHP Array (700,700): 98.794425010681 sec(s)
```

#### Matrix Transpose
Transpose CArray with shape `(rows,cols)`.
NOTICE: Only the operation time.
```php
TRANSPOSE PHPSCI CARRAY
========================================
CArray (100,100): 0.0037569999694824
CArray (200,200): 0.0010581016540527
CArray (300,300): 0.0028419494628906
CArray (400,400): 0.0050318241119385
CArray (500,500): 0.0081629753112793
CArray (600,600): 0.013552904129028
CArray (700,700): 0.019199848175049
CArray (800,800): 0.023442029953003
CArray (900,900): 0.030239820480347
```
```php
TRANSPOSE PHP IJ
========================================
PHP Array (100,100): 0.0057671070098877
PHP Array (200,200): 0.0091550350189209
PHP Array (300,300): 0.021449089050293
PHP Array (400,400): 0.037893056869507
PHP Array (500,500): 0.059904813766479
PHP Array (600,600): 0.087919950485229
PHP Array (700,700): 0.11952710151672
PHP Array (800,800): 0.15573596954346
PHP Array (900,900): 0.19703006744385
```
Everything inside `MemoryPointer Object` is generated by C code. Use `echo` to see your matrix instead
of `print_r` as PHPSci don't use PHP Arrays.