Skip to content

Commit

Permalink
docs: use PHP types only and other API documentation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
henrique-borba committed Jul 9, 2024
1 parent dc27296 commit c9b1a02
Show file tree
Hide file tree
Showing 82 changed files with 97 additions and 91 deletions.
3 changes: 2 additions & 1 deletion api/devices-functions/ndarray-setdevice.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import TabItem from '@theme/TabItem';
# NDArray::setDevice

```php
public static function setDevice(long $deviceId): null;
public static function setDevice(int $deviceId): void;
```
Specifies which GPU device to use by ID. By default, all operations are performed on GPU id = 0.

Use the `dumpDevices` method if you want to check the ID in a multi-GPU environment.

2 changes: 1 addition & 1 deletion api/initializers/ndarray-arange.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::arange

```php
public static function arange(scalar $stop, scalar $start = 0, scalar $step = 1): NDArray;
public static function arange(float|int $stop, float|int $start = 0, float|int $step = 1): NDArray;
```
Return evenly spaced values within a given interval.

Expand Down
4 changes: 2 additions & 2 deletions api/initializers/ndarray-array.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import TabItem from '@theme/TabItem';
# NDArray::array

```php
public static function array(array|scalar|GdImage $array): NDArray;
public static function array(array|float|int $array): NDArray;
```
Creates a new NDArray from a PHP array of longs or doubles. It is the equivalent of `new NDArray($array);`
Creates a new NDArray from a PHP array. It is the equivalent of `new NDArray($array);`

---

Expand Down
2 changes: 1 addition & 1 deletion api/initializers/ndarray-identity.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::identity

```php
public static function identity(long $size): NDArray;
public static function identity(int $size): NDArray;
```
This function returns a square array, where the main diagonal consists of ones and all other
elements are zeros. It takes a parameter `$size` which determines the number of rows and columns
Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-cond.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::cond

```php
public static function cond(NDArray|array $a): double;
public static function cond(NDArray|array $a): float;
```
Computes the condition number of an array.

Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-det.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::det

```php
public static function det(NDArray|array $a): double;
public static function det(NDArray|array $a): float;
```
Computes the determinant of a square array, which represents the scaling factor of the volume
of the array transformation.
Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-dot.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::dot

```php
public static function dot(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function dot(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
The `dot` function performs the dot product of two arrays. The behaviour of the function
varies depending on the dimensions and shapes of the input arrays:
Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-inner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::inner

```php
public static function inner(NDArray|array|scalar $a, NDArray|array|scalar $b);
public static function inner(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float;
```

Calculates the inner product of two arrays. This operation involves multiplying corresponding
Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-matmul.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::matmul

```php
public static function matmul($a, $b);
public static function matmul(NDArray|array $a, NDArray|array $b): NDArray;
```
Performs matrix multiplication between two arrays and returns the result as a new array.

Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-matrixrank.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::matrix_rank

```php
public static function matrix_rank(NDArray|array $a, scalar $tol = 1e-6): NDArray;
public static function matrix_rank(NDArray|array $a, float $tol = 1e-6): NDArray;
```
Calculates the numerical rank of a matrix, number of singular values of the array that are greater than tol.

Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-norm.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::norm

```php
public static function norm(NDArray|array $a, int $order = 2): double;
public static function norm(NDArray|array $a, int $order = 2): float;
```
Calculates different norms (e.g., L1 norm, L2 norm) of an array,
providing various measures of its magnitude.
Expand Down
2 changes: 1 addition & 1 deletion api/linear-algebra/ndarray-trace.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::trace

```php
public static function trace(NDArray|array $a): double;
public static function trace(NDArray|array $a): float;
```
Computes the sum of the diagonal elements of a square array, also known as the trace of the array.

Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-all.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::all

```php
public static function all(NDArray|array|scalar $a): bool;
public static function all(NDArray|array|float|int $a): bool;
```
Returns a single boolean value indicating whether all elements in the array evaluate to true. It checks if all
elements are nonzero or equivalent to true.
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-allclose.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::allclose

```php
public static function allclose(NDArray|array|scalar $a, NDArray|array|scalar $b, scalar $rtol = 1e-05, scalar atol = 1e-08): NDArray;
public static function allclose(NDArray|array|float|int $a, NDArray|array|float|int $b, float $rtol = 1e-05, float $atol = 1e-08): NDArray;
```
Checks if all elements in two arrays are approximately equal within a specified tolerance element-wise.

Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-equal.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::equal

```php
public static function equal(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function equal(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
Performs an element-wise equality comparison between two arrays and returns a
new array of the same shape. The result will be 1 where the
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-greater.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::greater

```php
public static function greater(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function greater(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
Performs an element-wise greater-than comparison between two arrays and returns a new array of the same shape.
The result will be 1 where the elements in the first array are greater than the corresponding elements in the
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-greater_equal.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::greater_equal

```php
public static function greater(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function greater_equal(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
```
Performs an element-wise greater-than-or-equal-to comparison between two arrays and returns a new
array of the same shape. The result will be 1 where the elements in the first array are greater than
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-less.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::less

```php
public static function less(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function less(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
Performs an element-wise less-than comparison between two arrays and returns a new array of the same shape.
The result will be 1 where the elements in the first array are less than the corresponding elements in the second
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-less_equal.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::less_equal

```php
public static function less_equal(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function less_equal(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
Performs an element-wise less-than-or-equal-to comparison between two arrays and returns a
new array of the same shape. The result will be 1 where the elements in the first array
Expand Down
2 changes: 1 addition & 1 deletion api/logic/ndarray-not_equal.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::not_equal

```php
public static function not_equal(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function not_equal(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray;
```
Performs an element-wise inequality comparison between two arrays and returns a new array of the same shape.
The result will be 1 where the elements are not equal and 0 where they are equal.
Expand Down
5 changes: 4 additions & 1 deletion api/manipulation/ndarray-atleast_1d.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import Tabs from "@theme/Tabs";
# NDArray::atleast_1d

```php
public function atleast_1d(NDArray|array|GdImage $array): array;
public static function atleast_1d(NDArray|array|float|int $array): NDArray;
```
Convert inputs to arrays with at least one dimension.

Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved.

---

Expand Down
3 changes: 2 additions & 1 deletion api/manipulation/ndarray-atleast_2d.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Tabs from "@theme/Tabs";
# NDArray::atleast_2d

```php
public function atleast_2d(NDArray|array|GdImage $array): array;
public static function atleast_2d(NDArray|array|float|int $array): NDArray;
```
Convert inputs to arrays with at least two dimensions.

---

Expand Down
3 changes: 2 additions & 1 deletion api/manipulation/ndarray-atleast_3d.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import Tabs from "@theme/Tabs";
# NDArray::atleast_3d

```php
public function atleast_3d(NDArray|array|GdImage $array): array;
public static function atleast_3d(NDArray|array|float|int $array): NDArray;
```
Convert inputs to arrays with at least three dimensions.

---

Expand Down
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-copy.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::copy

```php
public static function copy(NDArray|array|scalar $a, long $device = NULL): NDArray;
public static function copy(NDArray|array|float|int $a, int $device = NULL): NDArray;
```
Create a copy of array `$a`.

Expand Down
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-expand_dims.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Tabs from "@theme/Tabs";
# NDArray::expand_dims

```php
public function expand_dims(NDArray|array|GdImage $target, array|int $axis): array;
public static function expand_dims(NDArray|array|float|int $target, int|array $axis = NULL): NDArray;
```
Adds a new axis to the array at the specified position, thereby expanding its shape.

Expand Down
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-flat.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::flatten

```php
public static function flatten(NDArray|array|scalar $a): NDArray;
public static function flatten(NDArray|array|float|int $a): NDArray;
```
Return a **copy** of the array `$a` into one dimension.

Expand Down
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-reshape.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::reshape

```php
public function reshape(array $shape): NDArray;
public static function reshape(NDArray|array|float|int $target, array $shape): NDArray|float|int;
```
Changes the shape of the NDArray.

Expand Down
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-size.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::size

```php
public function size(): long;
public function size(): int;
```
Return the total number of elements in the NDArray.

Expand Down
2 changes: 1 addition & 1 deletion api/mathematical-functions/arithmetic/ndarray-add.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::add

```php
public static function add(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray|scalar;
public static function add(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
```
Add arguments element-wise

Expand Down
2 changes: 1 addition & 1 deletion api/mathematical-functions/arithmetic/ndarray-divide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::divide

```php
public static function divide(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray|double;
public static function divide(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
```
Return the division between two arrays element-wise

Expand Down
4 changes: 2 additions & 2 deletions api/mathematical-functions/arithmetic/ndarray-multiply.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::multiply

```php
public static function multiply(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray;
public static function multiply(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
```
Multiply arrays element-wise

Expand All @@ -14,7 +14,7 @@ Multiply arrays element-wise

#### `$a` `$b`
- **Type** - NDArray | array | scalar
- The arrays to be multiplied, `$a` and `$b` must be of the same shape.
- The arrays to be multiplied.

---

Expand Down
2 changes: 1 addition & 1 deletion api/mathematical-functions/arithmetic/ndarray-negative.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NDArray::negative

```php
public static function negative(NDArray|array|scalar $a): NDArray|double;
public static function negative(NDArray|array|float|int $a): NDArray|float|int;
```
Computes the element-wise negation (unary minus) of an array, returning a new array with the negation of each element.

Expand Down
2 changes: 1 addition & 1 deletion api/mathematical-functions/arithmetic/ndarray-pow.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::pow

```php
public static function pow(NDArray|array|scalar $a, NDArray|array|scalar $b): NDArray|scalar;
public static function pow(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
```
Raises each element of an array `$a` to a specified power `$b` and returns a new array containing the result.

Expand Down
2 changes: 1 addition & 1 deletion api/mathematical-functions/arithmetic/ndarray-subtract.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::subtract

```php
public static function subtract($a, $b);
public static function subtract(NDArray|array|float|int $a, NDArray|array|float|int $b): NDArray|float|int;
```
Subtract two arrays element-wise

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import TabItem from '@theme/TabItem';
# NDArray::exp

```php
public static function exp(NDArray|array|scalar $array): NDArray|double;
public static function exp(NDArray|array|float|int $array): NDArray|float|int;
```
Computes the element-wise exponential function of an array, returning a new array
with each element raised to the power of `$a`.
with each element raised to the power of `$array`.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::exp2

```php
public static function exp(NDArray|array|scalar $array): NDArray|double;
public static function exp2(NDArray|array|float|int $array): NDArray|float|int;
```
Computes the element-wise 2 raised to the power of an array,
returning a new array with each element raised to the power of 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import TabItem from '@theme/TabItem';
# NDArray::expm1

```php
public static function expm1(NDArray|array|scalar $array): NDArray|double;
public static function expm1(NDArray|array|float|int $array): NDArray|float|int;
```
Calculates the element-wise exponential minus one function, returning
a new array with each element raised to the power of `$a` - 1.
a new array with each element raised to the power of `$array` - 1.

---

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::log

```php
public static function log(NDArray|array|scalar $array): NDArray|double;
public static function log(NDArray|array|float|int $array): NDArray|float|int;
```
Calculates the element-wise natural logarithm of an array, returning
a new array with the natural logarithm of each element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::log10

```php
public static function log10(NDArray|array|scalar $array): NDArray|double;
public static function log10(NDArray|array|float|int $array): NDArray|float|int;
```
Calculates the element-wise base-10 logarithm of an array,
returning a new array with the base-10 logarithm of each element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::log1p

```php
public static function log1p(NDArray|array|scalar $array): NDArray|double;
public static function log1p(NDArray|array|float|int $array): NDArray|float|int;
```
Computes the element-wise logarithm of one plus an array, returning a new array with
the natural logarithm of each element plus one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
# NDArray::log2

```php
public static function log2(NDArray|array|scalar $array): NDArray|double;
public static function log2(NDArray|array|float|int $array): NDArray|float|int;
```
Computes the element-wise base-2 logarithm of an array,
returning a new array with the base-2 logarithm of each element
Expand Down
Loading

0 comments on commit c9b1a02

Please sign in to comment.