Skip to content

Commit

Permalink
docs: update with new methods and change homepage.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrique-borba committed May 11, 2024
1 parent 9a7f9a6 commit 4ea0f0c
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 23 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@



# Website

This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
Expand Down
19 changes: 19 additions & 0 deletions api/manipulation/ndarray-atleast_1d.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";

# NDArray::atleast_1d

```php
public function atleast_1d(NDArray|array|GdImage $array): array;
```

---

## Notes

:::tip

#### GPU SUPPORTED
This operation is supported by GPU (VRAM).

:::
19 changes: 19 additions & 0 deletions api/manipulation/ndarray-atleast_2d.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";

# NDArray::atleast_2d

```php
public function atleast_2d(NDArray|array|GdImage $array): array;
```

---

## Notes

:::tip

#### GPU SUPPORTED
This operation is supported by GPU (VRAM).

:::
19 changes: 19 additions & 0 deletions api/manipulation/ndarray-atleast_3d.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";

# NDArray::atleast_3d

```php
public function atleast_3d(NDArray|array|GdImage $array): array;
```

---

## Notes

:::tip

#### GPU SUPPORTED
This operation is supported by GPU (VRAM).

:::
2 changes: 1 addition & 1 deletion api/manipulation/ndarray-copy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Create a copy of array `$a`.
Default = NULL, copy on the same device as `$a`

- **0** - CPU copy (same as `$a->cpu()`);
- **1** - GPU copu (same as `$a->gpu()`);
- **1** - GPU copy (same as `$a->gpu()`);

---

Expand Down
91 changes: 91 additions & 0 deletions api/manipulation/ndarray-expand_dims.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";

# NDArray::expand_dims

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

---

## Parameters

### `$target`
- **Type** - NDArray | array | GdImage
- Target array.

### `$axis`
- **Type** - array | int
- This parameter specifies the position where the new axis (or axes) will be inserted within the expanded array.

---

## Examples

<Tabs>
<TabItem value="example1" label="Example 1" default>


```php
use \NDArray as nd;

$a = nd::array([[1, 2], [3, 4]]);
echo nd::expand_dims($a, [0, 1]);
```
```text @title="Output"
[[[1, 2, 3, 4]]]
```


</TabItem>
<TabItem value="example2" label="Example 2" default>


```php
use \NDArray as nd;

$a = nd::array([1, 2, 3, 4]);
echo nd::expand_dims($val, -1);
```
```text @title="Output"
[[1]
[2]
[3]
[4]]
```


</TabItem>
<TabItem value="example3" label="Example 3" default>


```php
use \NDArray as nd;

$a = nd::array([[1, 2], [3, 4]]);
echo nd::expand_dims($val, 4);
```
```text @title="Output"
Fatal error: Uncaught Error: invalid axis or axes provided. in /home/henrique/Documentos/Repositórios/numpower/test.php:8
Stack trace:
#0 /home/numpower/test.php(4): NDArray::expand_dims(Object(NDArray), 5)
#1 {main}
thrown in /home/numpower/test.php on line 4
```


</TabItem>
</Tabs>

---

## Notes

:::tip

#### GPU SUPPORTED
This operation is supported by GPU (VRAM).

:::
8 changes: 8 additions & 0 deletions api/signal-processing/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Signal Processing",
"position": 2,
"link": {
"type": "generated-index",
"description": "NumPower signal processing tools."
}
}
File renamed without changes.
48 changes: 48 additions & 0 deletions api/signal-processing/ndarray-correlate2d.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# NDArray::correlate2d

```php
public static function convolve2d(NDArray|array|GdImage $a, NDArray|array|GdImage $b, string $mode, string $boundary, scalar $fill_value = 0.0f): NDArray;
```
Convolve two 2-dimensional arrays.

Convolve `$a` and `$b` with output size determined by `$mode`, and boundary conditions determined by `$boundary` and `$fill_value`.

#### $mode options

- **full** - Full discrete linear convolution of the inputs
- **valid** - The output consists only of those elements that do not rely on the zero-padding. In ‘valid’ mode, either `$a` or `$b` must be at least as large as the other in every dimension.
- **same** - The output is the same size as `$a`, centered with respect to the ‘full’ output.

#### $boundary options

- **fill** - Pad input arrays with `$fill_value`
- **wrap** - Circular boundary
- **symm** - Symmetrical boundary

---

## Parameters

### `$a` `$b`
- **Type** - NDArray | array | GdImage
- The arrays to perform the convolution.

### `$mode`
- **Type** - string
- The size of the output. Can be: `full`, `valid` and `same`

### `$boundary`
- **Type** - string
- A flag indicating how to handle boundaries. Can be: `fill`, `wrap` and `symm`

---


## Notes

:::tip

#### GPU SUPPORTED
This operation is supported by GPU (VRAM) and contains a custom CUDA kernel.

:::
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const darkCodeTheme = require('prism-react-renderer/themes/dracula');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'NumPower',
tagline: 'A library for numerical calculations and scientific computing made for PHP',
tagline: 'Extension for numerical calculations and scientific computing made for PHP',
favicon: 'img/favicon.ico',

// Set the production url of your site here
Expand Down
17 changes: 17 additions & 0 deletions src/components/HomePageCodeTyping/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';

export default function TypingCode() {
return (
<div style={{position: 'absolute', float: 'left', zIndex: 1, width: '100%', textAlign: 'left'}}>
<div className="row">
<div className="col typecode" style={{width: '100%', marginLeft: '50px'}}><p><img
src="https://readme-typing-svg.demolab.com?font=Fira+Code&duration=2000&pause=500&multiline=true&width=435&height=100&separator=%3C&lines=%24a+%3D+nd%3A%3Aarray(%5B%5B1%2C+2%5D%2C+%5B3%2C+4%5D%5D);%3C%24b+%3D+%24a+*+2;%3Cprint_r(%24b);"
alt="Typing SVG"/></p></div>
<div className="col typecode" style={{width: '100%', textAlign: 'right'}}><p><img
src="https://readme-typing-svg.demolab.com?font=Fira+Code&duration=2000&pause=500&multiline=true&width=435&height=100&separator=%3C&lines=%24a_gpu+%3D+%24a-%3Egpu();%3C%24b_gpu+%3D+%24b-%3Egpu();%3C%24m+%3D+nd%3A%3Amatmul(%24a_gpu%2C+%24b_gpu);"
alt="Typing SVG"/></p></div>
</div>
</div>
);
}

Empty file.
56 changes: 40 additions & 16 deletions src/components/HomepageFeatures/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,54 @@ import styles from './styles.module.css';

const FeatureList = [
{
title: 'AVX2 and GPU support',
title: 'Modern instructions and GPU support',
description: (
<>
NumPower was designed from the ground up to utilize AVX2 and the GPU to
NumPower was designed from the ground up to utilize AVX2, BLAS and the GPU to
further improve performance.
</>
),
},
{
title: 'Efficient memory usage',
title: 'N-dimensional arrays',
description: (
<>
With the use of strided linear arrays, slices, buffer sharing and a specific GC engine,
NumPower manages memory more efficiently than a matrix in PHP arrays
Inspired by NumPy, NumPower arrays are N-dimensional and have efficient methods for slicing and indexing N-dimensional arrays.
</>
),
},
{
title: 'Powered by C',
title: 'Mathematical Tools',
description: (
<>
By using a purely C backend we can extract even more of your machine's computational power
Count on dozens of high-performance mathematical operations, including: trigonometry, statistics, linear algebra and more.
</>
),
},
{
title: 'CUDA Support',
description: (
<>
NumPower was developed from scratch to operate with GPUs that support CUDA. You can easily store and perform operations using your GPU's memory and processor.
</>
),
},
{
title: 'Image processing',
description: (
<>
You can use GD images as input to perform various image processing. You can use slicing and convolution methods for example to crop or apply custom filters.
</>
),
},
{
title: 'Efficient memory usage',
description: (
<>
Initially implemented with single precision floats, NDArray allows you to work with more data with less memory. We plan to add more types in the near future.
</>
),
}
];

function Feature({Svg, title, description}) {
Expand All @@ -46,14 +69,15 @@ function Feature({Svg, title, description}) {

export default function HomepageFeatures() {
return (
<section className={styles.features}>
<div className="container">
<div className="row">
{FeatureList.map((props, idx) => (
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
<section className={styles.features}>
<div className="container">
<div className="row">
{FeatureList.map((props, idx) => (
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
);
}

2 changes: 1 addition & 1 deletion src/components/HomepageFeatures/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
.featureSvg {
height: 200px;
width: 200px;
}
}
6 changes: 6 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
--ifm-code-font-size: 95%;
--ifm-link-color: #00b4d8;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);
.typecode {
display: none;
};
}

/* For readability concerns, you should choose a lighter palette in dark mode. */
Expand All @@ -30,4 +33,7 @@
--ifm-button-background-color: #023e8a;
--ifm-footer-background-color: #023e8a;
--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
.typecode {
display: none;
};
}
Loading

0 comments on commit 4ea0f0c

Please sign in to comment.