update stubs

This commit is contained in:
CismonX 2019-02-23 10:07:23 +08:00
parent 9537e5c868
commit b94bb13758
16 changed files with 189 additions and 80 deletions

33
stubs/Complex.php Normal file
View File

@ -0,0 +1,33 @@
<?php
namespace Arma;
/**
* Represents a complex number.
*
* @package Arma
*/
abstract class Complex
{
/**
* Real part of complex number.
*
* @var number
*/
public $real;
/**
* Imaginary part of complex number.
*
* @var number
*/
public $imag;
/**
* Constructor.
*
* @param number $real[optional]
* @param number $imag[optional]
*/
abstract function __construct($real, $imag);
}

View File

@ -2,6 +2,11 @@
namespace Arma;
/**
* Interface for a column vector with complex numbers as elements.
*
* @package Arma
*/
interface CxColvec extends CxVec
{

View File

@ -2,6 +2,11 @@
namespace Arma;
/**
* Interface for a row vector with complex numbers as elements.
*
* @package Arma
*/
interface CxRowvec extends CxVec
{

View File

@ -7,7 +7,7 @@ namespace Arma;
*
* @package Arma
*/
interface Mat extends Internal\Accessible, Internal\Operable, Internal\MatBase
interface Mat extends Internal\Common, Internal\Dense, Internal\MatBase
{
/**
* Construct the matrix to have user specified dimensions and fill with specified pattern.
@ -43,6 +43,15 @@ interface Mat extends Internal\Accessible, Internal\Operable, Internal\MatBase
*/
static function fromSparse($sp_mat);
/**
* Set all the elements of an object to one, optionally first changing the size to specified dimensions.
*
* @param $n_rows[optional]
* @param $n_cols[optional]
* @return void
*/
function ones($n_rows, $n_cols);
/**
* Set all the elements to random values, optionally first changing the size to specified dimensions.
*

20
stubs/SpCxMat.php Normal file
View File

@ -0,0 +1,20 @@
<?php
namespace Arma;
/**
* Interface for a sparse matrix with complex numbers as elements.
*
* @package Arma
*/
interface SpCxMat extends SpMat
{
/**
* Construct a complex sparse matrix out of two non-complex sparse matrices.
*
* @param SpMat $real
* @param SpMat $imag
* @return static
*/
static function fromMats($real, $imag);
}

View File

@ -2,7 +2,12 @@
namespace Arma;
interface SpMat extends Internal\Accessible, Internal\MatBase
/**
* Interface for a sparse matrix.
*
* @package Arma
*/
interface SpMat extends Internal\Common, Internal\MatBase
{
}

View File

@ -2,7 +2,7 @@
namespace Arma;
interface Vec extends Internal\Accessible, Internal\Operable, Internal\VecBase
interface Vec extends Internal\Common, Internal\Dense, Internal\VecBase
{
/**
* Construct the vector to have user specified size and fill with specified pattern.

13
stubs/impl/CxDouble.php Normal file
View File

@ -0,0 +1,13 @@
<?php
namespace Arma;
/**
* Represents a complex number with doubles as real and imaginary part.
*
* @package Arma
*/
class CxDouble extends Complex
{
}

View File

@ -1,8 +0,0 @@
<?php
namespace Arma;
class CxIColvec implements CxColvec
{
}

View File

@ -1,8 +0,0 @@
<?php
namespace Arma;
class CxIMat implements CxMat
{
}

View File

@ -1,8 +0,0 @@
<?php
namespace Arma;
class CxIRowvec implements CxRowvec
{
}

8
stubs/impl/SpCxDMat.php Normal file
View File

@ -0,0 +1,8 @@
<?php
namespace Arma;
class SpCxDMat implements SpCxMat
{
}

View File

@ -3,11 +3,11 @@
namespace Arma\Internal;
/**
* Interface for objects whose elements can be accessed.
* Interface for all container objects.
*
* @package Arma\Internal
*/
interface Accessible
interface Common
{
/**
* Get number of rows.
@ -51,4 +51,53 @@ interface Accessible
* @return mixed
*/
function &at($i, $j);
/**
* Addition of two objects.
*
* @param static $other
* @return static
*/
function add($other);
/**
* Subtraction of two objects.
*
* @param static $other
* @return static
*/
function sub($other);
/**
* Negation of the object.
*
* @return static
*/
function neg();
/**
* Matrix multiplication of two objects.
*
* @param static $other
* @return static
*/
function mul($other);
/**
* Element-wise multiplication of two objects.
*
* @param static $other
* @return static
*/
function dotMul($other);
/**
* Set the size to be the same as the given object.
*
* The given object must be of the same root type as the calling object.
*
* @param static $other
* @return void
*/
function copySize($other);
}

View File

@ -3,51 +3,12 @@
namespace Arma\Internal;
/**
* Interface for objects which support arithmetic operations.
* Interface for objects with a dense layout (Mat and Vec).
*
* @package Arma\Internal
*/
interface Operable
interface Dense
{
/**
* Addition of two objects.
*
* @param static $other
* @return static
*/
function add($other);
/**
* Subtraction of two objects.
*
* @param static $other
* @return static
*/
function sub($other);
/**
* Negation of the object.
*
* @return static
*/
function neg();
/**
* Matrix multiplication of two objects.
*
* @param static $other
* @return static
*/
function mul($other);
/**
* Element-wise multiplication of two objects.
*
* @param static $other
* @return static
*/
function dotMul($other);
/**
* Element-wise division of an object by another object or a scalar.
*
@ -104,4 +65,24 @@ interface Operable
* @return \Arma\IMat
*/
function notSmallerThan($other);
/**
* Sets the elements to a specified value.
*
* The type of value must match the type of elements used by the container object.
*
* @param number|\Arma\Complex $value
* @return void
*/
function fill($value);
/**
* Fill with values provided by a functor or lambda function.
*
* For matrices, filling is done column-by-column.
*
* @param callable $callback
* @return void
*/
function imbue($callback);
}

View File

@ -3,7 +3,7 @@
namespace Arma\Internal;
/**
* Interface for matrix-only operations.
* Interface for matrix-only(Mat and SpMat) operations.
*
* @package Arma\Internal
*/
@ -18,15 +18,6 @@ interface MatBase
*/
function zeros($n_rows, $n_cols);
/**
* Set all the elements of an object to one, optionally first changing the size to specified dimensions.
*
* @param $n_rows[optional]
* @param $n_cols[optional]
* @return void
*/
function ones($n_rows, $n_cols);
/**
* Set the elements along the main diagonal to one and off-diagonal elements to zero, optionally
* first changing the size to specified dimensions.
@ -59,6 +50,15 @@ interface MatBase
*/
function resize($n_rows, $n_cols);
/**
* Change the size of an object, without explicitly preserving data and without initialising the elements.
*
* @param $n_rows[optional]
* @param $n_cols[optional]
* @return void
*/
function setSize($n_rows, $n_cols);
/**
* Read/write access to a diagonal in a matrix.
*

View File

@ -2,6 +2,11 @@
namespace Arma\Internal;
/**
* Interface for vector-only objects.
*
* @package Arma\Internal
*/
interface VecBase
{
/**