Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| NdArray | |
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace SciPhp; |
| 6 | |
| 7 | use SciPhp\NdArray\Decorator; |
| 8 | use SciPhp\NdArray\Formatter; |
| 9 | |
| 10 | /** |
| 11 | * Base array |
| 12 | * |
| 13 | * @link http://sciphp.org/ref.ndarray |
| 14 | * |
| 15 | * @property NdArray $T Permute the dimensions of an array. |
| 16 | * @property int $ndim Number of dimensions of an array. |
| 17 | * @property int $size Number of elements of an array. |
| 18 | * @property array $shape Tuple of array dimensions. |
| 19 | * @property array $data Access data as a PHP array. |
| 20 | */ |
| 21 | final class NdArray extends Decorator |
| 22 | { |
| 23 | /** |
| 24 | * Constructor |
| 25 | * |
| 26 | * @param array $data |
| 27 | * @param string $identifier A NdArray identifier |
| 28 | */ |
| 29 | public function __construct(array $data, ?string $identifier = null) |
| 30 | { |
| 31 | $this->data = $data; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Pretty printer |
| 36 | */ |
| 37 | public function __toString(): string |
| 38 | { |
| 39 | return (new Formatter($this))->toString(); |
| 40 | } |
| 41 | } |