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

Implemented recently logspace CArray initializer. #16

Merged
merged 20 commits into from
Mar 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 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
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
[![Coverage Status](https://coveralls.io/repos/github/phpsci/phpsci/badge.svg?branch=master)](https://coveralls.io/github/phpsci/phpsci?branch=master)

<p align="center">
<img src="https://i.imgur.com/QoIbhqj.png" />
<img src="https://i.imgur.com/QoIbhqj.png" width="70%" />
</p>


Expand Down
13 changes: 3 additions & 10 deletions src/PHPSci/Kernel/CArray/CArrayWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use PHPSci\Kernel\Initializers\Creatable;
use PHPSci\Kernel\LinearAlgebra\Operatable;
use PHPSci\Kernel\Orchestrator\MemoryPointer;
use PHPSci\Kernel\PropertiesProcessor\Inflatable;
use PHPSci\Kernel\Ranges\Rangeable;
use PHPSci\Kernel\Transform\Transformable;
use PHPSci\PHPSci;
Expand All @@ -16,8 +17,7 @@
*/
abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable
{

use Transformable, Creatable, Operatable, Rangeable;
use Transformable, Creatable, Operatable, Rangeable, Printable, Inflatable;

/**
* @var
Expand All @@ -26,7 +26,6 @@ abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable


/**
*
* @return int|void
*/
public function count()
Expand Down Expand Up @@ -126,13 +125,7 @@ public function __invoke()
// TODO: Implement __invoke() method.
}

/**
*
*/
public function __toString()
{
// TODO: Implement __toString() method.
}


/**
* Get current Pointer Object
Expand Down
23 changes: 23 additions & 0 deletions src/PHPSci/Kernel/CArray/Printable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace PHPSci\Kernel\CArray;


/**
* Trait Printable
*
* @author Henrique Borba <[email protected]>
* @package PHPSci\Kernel\CArray
*/
trait Printable
{
/**
* Print current CArray
*
* @author Henrique Borba <[email protected]>
*/
public function __toString()
{
echo \CArray::print_r($this->ptr()->getPointer(), $this->rows, $this->cols);
return '';
}
}
4 changes: 2 additions & 2 deletions src/PHPSci/Kernel/Orchestrator/MemoryPointer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public function getPointer() {
}

/**
* Get current UUID
* Get current UUID (alias of getPointer)
*
* @author Henrique Borba <[email protected]>
*/
public function getUUID() {
return $this->uuid;
return $this->getPointer();
}

/**
Expand Down
27 changes: 27 additions & 0 deletions src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
namespace PHPSci\Kernel\PropertiesProcessor;

/**
* Trait Inflatable
*
* Dynamic properties.
*
* @author Henrique Borba <[email protected]>
* @package PHPSci\Kernel\PropertiesProcessor
*/
trait Inflatable
{

/**
* Emulates properties based on available classes.
*
* @author Henrique Borba <[email protected]>
* @param $name
* @return
*/
public function __get($name)
{
return call_user_func('PHPSci\\Kernel\\PropertiesProcessor\\'.$name.'::run', $this);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PHPSci\PropertiesProcessor;
namespace PHPSci\Kernel\PropertiesProcessor;

/**
* Class PropertiesProcessor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PHPSci\PropertiesProcessor;
namespace PHPSci\Kernel\PropertiesProcessor;

use PHPSci\PHPSci;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PHPSci\PropertiesProcessor;
namespace PHPSci\Kernel\PropertiesProcessor;


use PHPSci\PHPSci;
Expand All @@ -13,11 +13,12 @@
class cols extends PropertiesProcessor
{
/**
* @author Henrique Borba <[email protected]>
* @param PHPSci $obj
* @return int
*/
public static function run(PHPSci $obj)
{
return $obj->getCols();
return $obj->ptr()->getCols();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PHPSci\PropertiesProcessor;
namespace PHPSci\Kernel\PropertiesProcessor;


use PHPSci\PHPSci;
Expand All @@ -21,6 +21,6 @@ class rows extends PropertiesProcessor
*/
public static function run(PHPSci $obj)
{
return $obj->getRows();
return $obj->ptr()->getRows();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace PHPSci\PropertiesProcessor;
namespace PHPSci\Kernel\PropertiesProcessor;
use PHPSci\PHPSci;

/**
Expand All @@ -12,10 +12,9 @@ class sizeOf extends PropertiesProcessor
/**
* @param PHPSci $obj
* @return int
* @throws \PHPSci\Backend\Exceptions\ParameterValueException
*/
public static function run(PHPSci $obj) {
return $obj->sizeOf();
return $obj->ptr()->sizeOf();
}

}
24 changes: 24 additions & 0 deletions src/PHPSci/Kernel/PropertiesProcessor/took.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace PHPSci\Kernel\PropertiesProcessor;


use PHPSci\PHPSci;


/**
* Class took
*
* @package PHPSci\Kernel\PropertiesProcessor
*/
class took extends PropertiesProcessor
{

/**
* @param PHPSci $obj
* @return float
*/
public static function run(PHPSci $obj)
{
return $obj->getTook();
}
}
21 changes: 21 additions & 0 deletions src/PHPSci/Kernel/Ranges/Rangeable.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,25 @@ public static function linspace(float $stop, float $start = 0., float $num = 50)
);
}

/**
* Return numbers spaced evenly on a log scale.
*
* @author Henrique Borba <[email protected]>
* @param float $start base ** start is the starting value of the sequence.
* @param float $stop base ** stop is the final value of the sequence
* @param int $num Number of samples to generate. Default is 50.
* @param float $base The base of the log space.
* @return CArrayWrapper
*/
public static function logspace(float $start, float $stop, int $num = 50, float $base = 10) : CArrayWrapper {
$new_ptr = \CArray::logspace($start, $stop, $num, $base);
return new PHPSci(
new MemoryPointer(
$new_ptr,
$new_ptr->x,
$new_ptr->y
)
);
}

}
14 changes: 0 additions & 14 deletions src/PHPSci/PropertiesProcessor/took.php

This file was deleted.

31 changes: 31 additions & 0 deletions tests/Ranges/LogspaceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
namespace PHPSci\Tests\Ranges;

use PHPSci\PHPSci;
use PHPUnit\Framework\TestCase;

/**
* Class LogspaceTest
*
* @author Henrique Borba <[email protected]>
* @package PHPSci\Tests\Ranges
*/
class LogspaceTest extends TestCase
{

/**
* Test logspace static range initializer
*
* @author Henrique Borba <[email protected]>
*/
public function testLogspaceRangeInitializer() {
$expected = [100, 215.4434356689453, 464.1589660644531, 1000];
$returned = PHPSci::logspace(2,3, 4)->toArray();
$this->assertEquals($expected, $returned);

$expected = [4, 5.039683818817139, 6.349604606628418, 8];
$returned = PHPSci::logspace(2,3, 4, 2)->toArray();
$this->assertEquals($expected, $returned);
}

}