diff --git a/README.md b/README.md index aaba2fa1..b2339267 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ + + + # Website This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. diff --git a/api/manipulation/ndarray-atleast_1d.mdx b/api/manipulation/ndarray-atleast_1d.mdx new file mode 100644 index 00000000..05bfa34f --- /dev/null +++ b/api/manipulation/ndarray-atleast_1d.mdx @@ -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). + +::: \ No newline at end of file diff --git a/api/manipulation/ndarray-atleast_2d.mdx b/api/manipulation/ndarray-atleast_2d.mdx new file mode 100644 index 00000000..a69d1838 --- /dev/null +++ b/api/manipulation/ndarray-atleast_2d.mdx @@ -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). + +::: \ No newline at end of file diff --git a/api/manipulation/ndarray-atleast_3d.mdx b/api/manipulation/ndarray-atleast_3d.mdx new file mode 100644 index 00000000..addf6bde --- /dev/null +++ b/api/manipulation/ndarray-atleast_3d.mdx @@ -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). + +::: \ No newline at end of file diff --git a/api/manipulation/ndarray-copy.mdx b/api/manipulation/ndarray-copy.mdx index 5bdfd5d2..9b378836 100644 --- a/api/manipulation/ndarray-copy.mdx +++ b/api/manipulation/ndarray-copy.mdx @@ -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()`); --- diff --git a/api/manipulation/ndarray-expand_dims.mdx b/api/manipulation/ndarray-expand_dims.mdx new file mode 100644 index 00000000..13060c2f --- /dev/null +++ b/api/manipulation/ndarray-expand_dims.mdx @@ -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 + + + + + +```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]]] +``` + + + + + + +```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]] +``` + + + + + + +```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 +``` + + + + + +--- + +## Notes + +:::tip + +#### GPU SUPPORTED +This operation is supported by GPU (VRAM). + +::: \ No newline at end of file diff --git a/api/signal-processing/_category_.json b/api/signal-processing/_category_.json new file mode 100644 index 00000000..eeb7e00c --- /dev/null +++ b/api/signal-processing/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Signal Processing", + "position": 2, + "link": { + "type": "generated-index", + "description": "NumPower signal processing tools." + } +} diff --git a/api/linear-algebra/ndarray-convolve2d.mdx b/api/signal-processing/ndarray-convolve2d.mdx similarity index 100% rename from api/linear-algebra/ndarray-convolve2d.mdx rename to api/signal-processing/ndarray-convolve2d.mdx diff --git a/api/signal-processing/ndarray-correlate2d.mdx b/api/signal-processing/ndarray-correlate2d.mdx new file mode 100644 index 00000000..2298f10e --- /dev/null +++ b/api/signal-processing/ndarray-correlate2d.mdx @@ -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. + +::: diff --git a/docusaurus.config.js b/docusaurus.config.js index 6afd8d39..001c50d6 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -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 diff --git a/src/components/HomePageCodeTyping/index.js b/src/components/HomePageCodeTyping/index.js new file mode 100644 index 00000000..6bf9c54e --- /dev/null +++ b/src/components/HomePageCodeTyping/index.js @@ -0,0 +1,17 @@ +import React from 'react'; + +export default function TypingCode() { + return ( +
+
+

Typing SVG

+

Typing SVG

+
+
+ ); +} + diff --git a/src/components/HomePageCodeTyping/styles.module.css b/src/components/HomePageCodeTyping/styles.module.css new file mode 100644 index 00000000..e69de29b diff --git a/src/components/HomepageFeatures/index.js b/src/components/HomepageFeatures/index.js index b8684a77..e49f0463 100644 --- a/src/components/HomepageFeatures/index.js +++ b/src/components/HomepageFeatures/index.js @@ -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}) { @@ -46,14 +69,15 @@ function Feature({Svg, title, description}) { export default function HomepageFeatures() { return ( -
-
-
- {FeatureList.map((props, idx) => ( - - ))} -
-
-
+
+
+
+ {FeatureList.map((props, idx) => ( + + ))} +
+
+
); } + diff --git a/src/components/HomepageFeatures/styles.module.css b/src/components/HomepageFeatures/styles.module.css index b248eb2e..35fcb92d 100644 --- a/src/components/HomepageFeatures/styles.module.css +++ b/src/components/HomepageFeatures/styles.module.css @@ -8,4 +8,4 @@ .featureSvg { height: 200px; width: 200px; -} +} \ No newline at end of file diff --git a/src/css/custom.css b/src/css/custom.css index 70fdb9a4..7ea830ea 100644 --- a/src/css/custom.css +++ b/src/css/custom.css @@ -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. */ @@ -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; + }; } diff --git a/src/pages/index.js b/src/pages/index.js index 851477ad..2c95181e 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -6,6 +6,7 @@ import Layout from '@theme/Layout'; import HomepageFeatures from '@site/src/components/HomepageFeatures'; import { useColorMode } from '@docusaurus/theme-common'; import styles from './index.module.css'; +import TypingCode from "../components/HomePageCodeTyping"; function HomepageHeader() { const {siteConfig} = useDocusaurusContext(); @@ -13,7 +14,7 @@ function HomepageHeader() { return (
- +

{siteConfig.title}

{siteConfig.tagline}

@@ -24,6 +25,7 @@ function HomepageHeader() {
+
); } @@ -32,11 +34,11 @@ export default function Home() { const {siteConfig} = useDocusaurusContext(); return ( + title={`${siteConfig.title}`} + description="Extension for numerical calculations and scientific computing made for PHP">
- +
);