From 69e98ca96b243ac8b86d693fb0aaeaff6f3961d9 Mon Sep 17 00:00:00 2001 From: CismonX Date: Mon, 4 Nov 2019 16:19:23 +0800 Subject: [PATCH] refactor stubs --- stubs/internal/DenseResizableVector.php | 9 ++++++++ stubs/internal/ResizableVector.php | 18 +++++++++++++++ stubs/internal/SparseResizableMatrix.php | 2 +- stubs/internal/SparseResizableVector.php | 28 +++++++++++++++++++++++ stubs/internal/SparseVector.php | 16 ------------- stubs/internal/Vector.php | 29 ------------------------ 6 files changed, 56 insertions(+), 46 deletions(-) diff --git a/stubs/internal/DenseResizableVector.php b/stubs/internal/DenseResizableVector.php index d460b74..facad8f 100644 --- a/stubs/internal/DenseResizableVector.php +++ b/stubs/internal/DenseResizableVector.php @@ -13,6 +13,15 @@ interface DenseResizableVector extends DenseVector, ResizableVector { // Initialization + /** + * Construct the vector to have user specified size and fill with specified pattern. + * + * @param int $n_elem[optional] + * @param int $fill[optional] + * @return static + */ + static function init($n_elem, $fill); + /** * Set all the elements of an object to one, optionally first changing the size to specified dimensions. * diff --git a/stubs/internal/ResizableVector.php b/stubs/internal/ResizableVector.php index cc774c9..9befeb7 100644 --- a/stubs/internal/ResizableVector.php +++ b/stubs/internal/ResizableVector.php @@ -9,6 +9,24 @@ namespace Arma\Internal; */ interface ResizableVector extends Resizable, Vector { + /** + * Create the vector from a textual description. + * + * Elements should be separated by spaces. + * + * @param string $text + * @return static + */ + static function fromString($text); + + /** + * Create the vector from a PHP array. + * + * @param array $arr + * @return static + */ + static function fromArray($arr); + /** * Recreate the object according to given size specifications, while preserving the elements * as well as the layout of the elements. diff --git a/stubs/internal/SparseResizableMatrix.php b/stubs/internal/SparseResizableMatrix.php index 08d0608..88d628a 100644 --- a/stubs/internal/SparseResizableMatrix.php +++ b/stubs/internal/SparseResizableMatrix.php @@ -22,7 +22,7 @@ interface SparseResizableMatrix extends SparseMatrix, ResizableMatrix * @param int $n_cols[optional] * @param int $fill[optional] * @param double $density[optional] - * @return Mat + * @return static */ static function init($n_rows, $n_cols, $fill, $density); diff --git a/stubs/internal/SparseResizableVector.php b/stubs/internal/SparseResizableVector.php index b41bf97..853c67e 100644 --- a/stubs/internal/SparseResizableVector.php +++ b/stubs/internal/SparseResizableVector.php @@ -9,5 +9,33 @@ namespace Arma\Internal; */ interface SparseResizableVector extends SparseVector, ResizableVector { + /** + * Construct the vector to have user specified size and fill with specified pattern. + * + * $density should be specified when filling the vector with random values. + * + * @param int $n_elem[optional] + * @param int $fill[optional] + * @param double $density[optional] + * @return static + */ + static function init($n_elem, $fill, $density); + /// Subview + + /** + * {@inheritdoc} + * + * @param int $idx + * @return SpMapVal + */ + function __invoke($idx); + + /** + * {@inheritdoc} + * + * @param int $idx + * @return SpMapVal + */ + function at($idx); } diff --git a/stubs/internal/SparseVector.php b/stubs/internal/SparseVector.php index 9f075f3..8829153 100644 --- a/stubs/internal/SparseVector.php +++ b/stubs/internal/SparseVector.php @@ -6,21 +6,5 @@ use Arma\SpMapVal; interface SparseVector extends Sparse, Vector { - /// Subview - /** - * {@inheritdoc} - * - * @param int $idx - * @return SpMapVal - */ - function __invoke($idx); - - /** - * {@inheritdoc} - * - * @param int $idx - * @return SpMapVal - */ - function at($idx); } diff --git a/stubs/internal/Vector.php b/stubs/internal/Vector.php index 6b9a7af..d559f6d 100644 --- a/stubs/internal/Vector.php +++ b/stubs/internal/Vector.php @@ -9,35 +9,6 @@ namespace Arma\Internal; */ interface Vector { - // Constructors - - /** - * Construct the vector to have user specified size and fill with specified pattern. - * - * @param int $n_elem[optional] - * @param int $fill[optional] - * @return static - */ - static function init($n_elem, $fill); - - /** - * Create the vector from a textual description. - * - * Elements should be separated by spaces. - * - * @param string $text - * @return static - */ - static function fromString($text); - - /** - * Create the vector from a PHP array. - * - * @param array $arr - * @return static - */ - static function fromArray($arr); - // Vector subview /**