diff --git a/README.md b/README.md
index 11d054c..34ad015 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@
[](https://coveralls.io/github/phpsci/phpsci?branch=master)
-
+
diff --git a/src/PHPSci/Kernel/CArray/CArrayWrapper.php b/src/PHPSci/Kernel/CArray/CArrayWrapper.php
index 86c1447..e7517aa 100644
--- a/src/PHPSci/Kernel/CArray/CArrayWrapper.php
+++ b/src/PHPSci/Kernel/CArray/CArrayWrapper.php
@@ -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;
@@ -16,8 +17,7 @@
*/
abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable
{
-
- use Transformable, Creatable, Operatable, Rangeable;
+ use Transformable, Creatable, Operatable, Rangeable, Printable, Inflatable;
/**
* @var
@@ -26,7 +26,6 @@ abstract class CArrayWrapper implements Stackable, \ArrayAccess, \Countable
/**
- *
* @return int|void
*/
public function count()
@@ -126,13 +125,7 @@ public function __invoke()
// TODO: Implement __invoke() method.
}
- /**
- *
- */
- public function __toString()
- {
- // TODO: Implement __toString() method.
- }
+
/**
* Get current Pointer Object
diff --git a/src/PHPSci/Kernel/CArray/Printable.php b/src/PHPSci/Kernel/CArray/Printable.php
new file mode 100644
index 0000000..6a0fbce
--- /dev/null
+++ b/src/PHPSci/Kernel/CArray/Printable.php
@@ -0,0 +1,23 @@
+
+ * @package PHPSci\Kernel\CArray
+ */
+trait Printable
+{
+ /**
+ * Print current CArray
+ *
+ * @author Henrique Borba
+ */
+ public function __toString()
+ {
+ echo \CArray::print_r($this->ptr()->getPointer(), $this->rows, $this->cols);
+ return '';
+ }
+}
\ No newline at end of file
diff --git a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php
index ddd6f8d..7b8da17 100644
--- a/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php
+++ b/src/PHPSci/Kernel/Orchestrator/MemoryPointer.php
@@ -42,12 +42,12 @@ public function getPointer() {
}
/**
- * Get current UUID
+ * Get current UUID (alias of getPointer)
*
* @author Henrique Borba
*/
public function getUUID() {
- return $this->uuid;
+ return $this->getPointer();
}
/**
diff --git a/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php b/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php
new file mode 100644
index 0000000..e275a2f
--- /dev/null
+++ b/src/PHPSci/Kernel/PropertiesProcessor/Inflatable.php
@@ -0,0 +1,27 @@
+
+ * @package PHPSci\Kernel\PropertiesProcessor
+ */
+trait Inflatable
+{
+
+ /**
+ * Emulates properties based on available classes.
+ *
+ * @author Henrique Borba
+ * @param $name
+ * @return
+ */
+ public function __get($name)
+ {
+ return call_user_func('PHPSci\\Kernel\\PropertiesProcessor\\'.$name.'::run', $this);
+ }
+
+}
\ No newline at end of file
diff --git a/src/PHPSci/PropertiesProcessor/PropertiesProcessor.php b/src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php
similarity index 76%
rename from src/PHPSci/PropertiesProcessor/PropertiesProcessor.php
rename to src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php
index 801d4fa..216c553 100644
--- a/src/PHPSci/PropertiesProcessor/PropertiesProcessor.php
+++ b/src/PHPSci/Kernel/PropertiesProcessor/PropertiesProcessor.php
@@ -1,5 +1,5 @@
* @param PHPSci $obj
* @return int
*/
public static function run(PHPSci $obj)
{
- return $obj->getCols();
+ return $obj->ptr()->getCols();
}
}
\ No newline at end of file
diff --git a/src/PHPSci/PropertiesProcessor/rows.php b/src/PHPSci/Kernel/PropertiesProcessor/rows.php
similarity index 80%
rename from src/PHPSci/PropertiesProcessor/rows.php
rename to src/PHPSci/Kernel/PropertiesProcessor/rows.php
index 6eceaaa..705b784 100644
--- a/src/PHPSci/PropertiesProcessor/rows.php
+++ b/src/PHPSci/Kernel/PropertiesProcessor/rows.php
@@ -1,5 +1,5 @@
getRows();
+ return $obj->ptr()->getRows();
}
}
\ No newline at end of file
diff --git a/src/PHPSci/PropertiesProcessor/sizeOf.php b/src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php
similarity index 64%
rename from src/PHPSci/PropertiesProcessor/sizeOf.php
rename to src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php
index c9398f9..4e78ac1 100644
--- a/src/PHPSci/PropertiesProcessor/sizeOf.php
+++ b/src/PHPSci/Kernel/PropertiesProcessor/sizeOf.php
@@ -1,5 +1,5 @@
sizeOf();
+ return $obj->ptr()->sizeOf();
}
}
\ No newline at end of file
diff --git a/src/PHPSci/Kernel/PropertiesProcessor/took.php b/src/PHPSci/Kernel/PropertiesProcessor/took.php
new file mode 100644
index 0000000..1102779
--- /dev/null
+++ b/src/PHPSci/Kernel/PropertiesProcessor/took.php
@@ -0,0 +1,24 @@
+getTook();
+ }
+}
\ No newline at end of file
diff --git a/src/PHPSci/Kernel/Ranges/Rangeable.php b/src/PHPSci/Kernel/Ranges/Rangeable.php
index 51a69cd..e4f72f0 100644
--- a/src/PHPSci/Kernel/Ranges/Rangeable.php
+++ b/src/PHPSci/Kernel/Ranges/Rangeable.php
@@ -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
+ * @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
+ )
+ );
+ }
+
}
\ No newline at end of file
diff --git a/src/PHPSci/PropertiesProcessor/took.php b/src/PHPSci/PropertiesProcessor/took.php
deleted file mode 100644
index daf3368..0000000
--- a/src/PHPSci/PropertiesProcessor/took.php
+++ /dev/null
@@ -1,14 +0,0 @@
-getTook();
- }
-}
\ No newline at end of file
diff --git a/tests/Ranges/LogspaceTest.php b/tests/Ranges/LogspaceTest.php
new file mode 100644
index 0000000..69b2b8f
--- /dev/null
+++ b/tests/Ranges/LogspaceTest.php
@@ -0,0 +1,31 @@
+
+ * @package PHPSci\Tests\Ranges
+ */
+class LogspaceTest extends TestCase
+{
+
+ /**
+ * Test logspace static range initializer
+ *
+ * @author Henrique Borba
+ */
+ 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);
+ }
+
+}
\ No newline at end of file