Skip to content

Commit 5012e31

Browse files
committed
Added functions documentation pages.
1 parent 118b53d commit 5012e31

38 files changed

+1120
-21
lines changed

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
'sphinx.ext.doctest',
2525
'sphinx.ext.autodoc',
2626
'sphinx.ext.mathjax',
27+
'sphinx_collapse',
2728
]
2829

2930
templates_path = ['_templates']
@@ -36,6 +37,6 @@
3637

3738
html_theme = 'sphinxawesome_theme'
3839
html_static_path = ['_static']
39-
40+
html_permalinks = False
4041

4142

docs/functions.rst

Lines changed: 106 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,122 @@
11
Functions
22
=========
33

4+
Documentation grouped by category:
45

56

6-
Introduction
7-
------------
7+
.. collapse:: Arrayfire Classes
88

9-
This is the introductory section of File 1.
9+
.. list-table::
1010

11-
Modules
12-
-------
11+
* - Class 1
12+
- Description of Class 1
1313

14-
Here is some content for the first section.
1514

16-
Mod
17-
~~~
15+
.. collapse:: Arrayfire Functions
1816

19-
This is a subsection under Section 1.
17+
.. list-table::
2018

21-
Mod1
22-
~~~~
19+
* - :doc:`af.array() <functions/array>`
20+
- Creates an array from a list or other data structure.
21+
* - :doc:`af.zeros() <functions/zeros>`
22+
- Creates an array filled with zeros.
23+
* - :doc:`af.ones() <functions/ones>`
24+
- Creates an array filled with ones.
25+
* - :doc:`af.randu() <functions/randu>`
26+
- Creates an array with random uniform values.
27+
* - :doc:`af.randn() <functions/randn>`
28+
- Creates an array with random normal values.
29+
* - :doc:`af.transpose() <functions/transpose>`
30+
- Transposes an array.
31+
* - :doc:`af.reshape() <functions/reshape>`
32+
- Reshapes an array.
33+
* - :doc:`af.reorder() <functions/reorder>`
34+
- Reorders dimensions of an array.
35+
* - :doc:`af.slice() <functions/slice>`
36+
- Extracts a slice of an array.
37+
* - :doc:`af.join() <functions/join>`
38+
- Joins arrays along a specified dimension.
39+
* - :doc:`af.add() <functions/add>`
40+
- Performs element-wise addition.
41+
* - :doc:`af.subtract() <functions/subtract>`
42+
- Performs element-wise subtraction.
43+
* - :doc:`af.multiply() <functions/multiply>`
44+
- Performs element-wise multiplication.
45+
* - :doc:`af.divide() <functions/divide>`
46+
- Performs element-wise division.
47+
* - :doc:`af.dot() <functions/dot>`
48+
- Computes the dot product of two arrays.
49+
* - :doc:`af.exp() <functions/exp>`
50+
- Computes the exponential of each element.
51+
* - :doc:`af.log() <functions/log>`
52+
- Computes the natural logarithm of each element.
53+
* - :doc:`af.sqrt() <functions/sqrt>`
54+
- Computes the square root of each element.
55+
* - :doc:`af.matmul() <functions/matmul>`
56+
- Matrix multiplication.
57+
* - :doc:`af.inv() <functions/inv>`
58+
- Computes the inverse of a matrix.
59+
* - :doc:`af.det() <functions/det>`
60+
- Computes the determinant of a matrix.
61+
* - :doc:`af.eig() <functions/eig>`
62+
- Computes eigenvalues and eigenvectors.
63+
* - :doc:`af.fft() <functions/fft>`
64+
- Computes the Fast Fourier Transform.
65+
* - :doc:`af.ifft() <functions/ifft>`
66+
- Computes the Inverse Fast Fourier Transform.
67+
* - :doc:`af.mean() <functions/mean>`
68+
- Computes the mean of elements.
69+
* - :doc:`af.stdev() <functions/sttdev>`
70+
- Computes the standard deviation.
71+
* - :doc:`af.median() <functions/median>`
72+
- Computes the median value.
73+
* - :doc:`af.sum() <functions/sum>`
74+
- Computes the sum of elements.
75+
* - :doc:`af.prod() <functions/prod>`
76+
- Computes the product of elements.
77+
* - :doc:`af.device() <functions/device>`
78+
- Returns the device identifier.
79+
* - :doc:`af.get_device() <functions/get_device>`
80+
- Matrix multiplication.
81+
* - :doc:`af.set_device() <functions/set_device>`
82+
- Gets the current device.
83+
* - :doc:`af.get() <functions/get>`
84+
- Copies data from the GPU to the CPU.
85+
* - :doc:`af.min() <functions/min>`
86+
- Finds the minimum value.
87+
* - :doc:`af.max() <functions/max>`
88+
- Finds the maximum value.
2389

24-
More content for the second section.
2590

26-
Mod2
27-
~~~~
91+
.. collapse:: Arrayfire Functions by Category
2892

29-
This concludes the content of File 1.
93+
.. list-table::
3094

31-
Mod3
32-
~~~~
95+
* - **Array Creation**
96+
- Functions in this category are used to initialize arrays with specific values or patterns.
97+
* - **Array Manipulation**
98+
- These functions help modify the structure or arrangement of arrays.
99+
* - **Mathematical Operations**
100+
- Functions for performing fundamental arithmetic and mathematical operations on arrays.
101+
* - **Linear Algebra**
102+
- Functions for performing linear algebra operations, essential in many scientific and engineering tasks.
103+
* - **Fourier Transforms**
104+
- Functions for performing Fourier analysis, essential for signal processing and frequency analysis.
105+
* - **Statistics**
106+
- Functions for computing statistical metrics and analyzing data distributions.
107+
* - **Data Reduction**
108+
- Functions for aggregating and reducing data to summarize or condense information.
109+
* - **Utilities**
110+
- General-purpose functions for managing arrays and devices.
111+
* - **Special Functions**
112+
- Functions for creating and applying specific types of filters, commonly used in signal processing and analysis.
33113

34-
Mod4
35-
~~~~
114+
115+
.. collapse:: Graphics
116+
117+
.. list-table::
118+
119+
* - **Rendering Function**
120+
- Rendering Function to draw images, plots etc
121+
* - **Window Function**
122+
- Window Creation, modification and destruction of functions

docs/functions/add.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
add
2+
===
3+
The 'af.add()' function in ArrayFire is used to perform element-wise addition between arrays. This function enables you to add corresponding elements of two arrays or an array and a scalar, resulting in a new array where each element is the sum of the respective elements from the input arrays or the scalar.
4+
5+
6+
Function
7+
--------
8+
:literal:`af.add()`
9+
- Python interface used to perform element-wise addition.
10+
11+
Detailed Description
12+
--------------------
13+
The 'af.add()' function computes the sum of two arrays or an array and a scalar, element by element. When adding two arrays, both must have the same dimensions, or be broadcastable to a common shape. For array-scalar addition, the scalar value is added to each element of the array. This function is particularly useful for operations requiring element-wise arithmetic.
14+
15+
Function Documentation
16+
----------------------
17+
.. sidebar:: af.add()
18+
19+
Syntax:
20+
af.add(array1, array2)
21+
af.add(array, scalar)
22+
23+
Parameters:
24+
'array1': The first ArrayFire array in the addition operation.
25+
'array2': The second ArrayFire array with the same dimensions as 'array1', or compatible for broadcasting.
26+
'array': An ArrayFire array to which the scalar is added.
27+
'scalar': A scalar value to be added to each element of 'array'.
28+
29+
Returns:
30+
An ArrayFire array containing the element-wise sum of the inputs.

docs/functions/array.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
array
2+
=====
3+
The 'af.array()' function is part of the ArrayFire library, which provides a powerful framework for performing high-performance numerical computations. This function is designed to create an ArrayFire array from various data structures, such as Python lists or other iterable collections.
4+
5+
Function
6+
--------
7+
:literal:`af.array()`
8+
- Python interface to form an array.
9+
10+
11+
Detailed Description
12+
--------------------
13+
The 'af.array()' function allows you to convert a data structure, such as a Python list or tuple, into an ArrayFire array. This conversion is essential for leveraging ArrayFire's optimized computational capabilities. By creating an array from a list or another iterable, you can perform efficient mathematical operations, matrix manipulations, and other numerical computations using ArrayFire's APIs.
14+
15+
The function supports multiple data types and can handle multi-dimensional arrays. The ability to create an ArrayFire array from native Python structures makes it easier to integrate ArrayFire into Python-based workflows.
16+
17+
Function Documentation
18+
----------------------
19+
.. sidebar:: af.array()
20+
21+
Syntax:
22+
af.array(data)
23+
24+
Parameters:
25+
'data': A list, tuple, or another iterable containing the elements to be converted into an ArrayFire array. The data should be in a format that ArrayFire can interpret, such as nested lists for multi-dimensional arrays.
26+
27+
Returns:
28+
An ArrayFire array containing the elements from the input data structure.
29+
30+

docs/functions/det.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
det
2+
===
3+
The 'af.det()' function in ArrayFire computes the determinant of a square matrix. The determinant is a scalar value that provides important properties of the matrix, such as whether it is invertible. It is a fundamental operation in linear algebra with applications in areas such as system of equations, matrix inversion, and eigenvalue problems.
4+
5+
Function
6+
--------
7+
:literal:`af.det()`
8+
- Python interface to find determinant of a square matrix.
9+
10+
Detailed Description
11+
--------------------
12+
The 'af.det()' function calculates the determinant of a square matrix. The matrix must be square, meaning the number of rows must be equal to the number of columns. The determinant of a matrix is a scalar that can provide information about the matrix, such as its invertibility. If the determinant is zero, the matrix is singular (non-invertible); if it is non-zero, the matrix is invertible.
13+
14+
Function Documentation
15+
----------------------
16+
.. sidebar:: af.det()
17+
18+
Syntax:
19+
af.det(matrix)
20+
21+
Parameters:
22+
'matrix': A 2D ArrayFire array (matrix) whose determinant is to be calculated. The matrix must be square, i.e., the number of rows must be equal to the number of columns.
23+
24+
Returns:
25+
A scalar value representing the determinant of the input matrix. The type of the result will be the same as the input matrix data type.

docs/functions/device.rst

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
device
2+
======
3+
The 'af.device()' function in the ArrayFire library is used to get or set the current device or device properties. This function provides an interface to interact with the GPU or CPU device being used for computations. It allows you to select a particular device from available options or query the properties of the current device.
4+
5+
Function
6+
--------
7+
:literal:`af.device()`
8+
- Python interface to get or set device properties.
9+
10+
Detailed Description
11+
--------------------
12+
The 'af.device()' function is useful for managing and querying the device that ArrayFire is using for computations. This function can perform various tasks related to device management, such as:
13+
14+
- Getting the Current Device: Retrieve the index of the currently selected device.
15+
- Setting the Current Device: Select a specific device for computations.
16+
- Querying Device Properties: Obtain information about the current device.
17+
This functionality is important for applications that need to explicitly choose between multiple GPUs or check device capabilities.
18+
19+
Function Documentation
20+
----------------------
21+
.. sidebar:: af.device()
22+
23+
Syntax:
24+
af.device(option=None, value=None)
25+
26+
Parameters:
27+
'option' (optional): Specifies the type of information or action. Can be one of the following:
28+
29+
- "device": Get the current device index.
30+
- "set": Set the current device index.
31+
- "count": Get the number of available devices.
32+
- "name": Get the name of the current device.
33+
- "info": Get detailed information about the current device.
34+
35+
'value (optional)': The index of the device to set. Used only when the option is "set". If option is "set", this parameter should be an integer representing the device index.
36+
37+
Returns:
38+
Depending on the option, the function returns various types of information:
39+
- If 'option' is "device": The index of the current device.
40+
- If 'option' is "count": The number of available devices.
41+
- If 'option' is "name": The name of the current device.
42+
- If 'option' is "info": Detailed information about the current device.

docs/functions/divide.rst

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
divide
2+
======
3+
The 'af.divide()' function in the ArrayFire library performs element-wise division of two arrays. This function allows you to divide one array by another, or to divide each element of an array by a scalar value. It supports operations on arrays of the same shape or on a scalar and an array.
4+
5+
Function
6+
--------
7+
:literal:`af.divide`
8+
- Python interface for dividing one array by another.
9+
10+
Detailed Description
11+
--------------------
12+
The af.divide() function is used to perform element-wise division of arrays or between an array and a scalar. This operation divides each element of the first array by the corresponding element of the second array, or divides each element of the array by the scalar value.
13+
14+
**Element-wise Division:** When dividing two arrays, the function performs the division for each corresponding element of the arrays.
15+
16+
**Scalar Division:** When dividing an array by a scalar, the function divides each element of the array by the scalar value.
17+
18+
The function handles broadcasting automatically when the dimensions of the arrays are compatible.
19+
20+
Function Documentation
21+
----------------------
22+
.. sidebar:: af.divide
23+
24+
Syntax:
25+
af.divide(array1, array2)
26+
af.divide(array, scalar)
27+
28+
29+
Parameters:
30+
- array1: The first ArrayFire array (numerator) in the division operation.
31+
- array2: The second ArrayFire array (denominator) in the division operation. Must have the same shape as array1 or be a scalar.
32+
- array: The ArrayFire array to be divided by a scalar.
33+
- scalar: The scalar value used to divide each element of array.
34+
35+
Returns:
36+
An ArrayFire array containing the results of the element-wise division. The resulting array will have the same shape as the input arrays.

docs/functions/dot.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
dot
2+
===
3+
The 'af.dot()' function in ArrayFire computes the dot product of two arrays. This function is used for calculating the scalar product of two vectors or the matrix multiplication when applied to matrices. It is a fundamental operation in linear algebra with applications in various fields such as machine learning, physics, and numerical computing.
4+
5+
Function
6+
--------
7+
:literal:`af.dot()`
8+
- Python interface to compute dot product of two arrays.
9+
10+
Detailed Description
11+
--------------------
12+
The af.dot() function computes the dot product, which can refer to different operations depending on the type of input:
13+
14+
**Dot Product of Two Vectors:** For 1D arrays (vectors), the function calculates the scalar product. This is the sum of the products of corresponding elements of the vectors.
15+
16+
**Matrix Multiplication:** For 2D arrays (matrices), it performs matrix multiplication, which is also referred to as the dot product in this context.
17+
18+
Function Documentation
19+
----------------------
20+
.. sidebar:: af.dot()
21+
22+
Syntax:
23+
af.dot(array1, array2)
24+
25+
Parameters:
26+
'array1': The first ArrayFire array (vector or matrix) in the dot product operation.
27+
'array2': The second ArrayFire array (vector or matrix) in the dot product operation. Must be compatible with 'array1' for dot product or matrix multiplication.
28+
29+
Returns:
30+
- For vectors: A scalar value representing the dot product of the vectors.
31+
- For matrices: An ArrayFire array representing the result of matrix multiplication.

docs/functions/eig.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
eig
2+
===
3+
The 'af.eig()' function in ArrayFire computes the eigenvalues and eigenvectors of a square matrix. This function is essential in linear algebra for analyzing matrices and is used in various applications including machine learning, physics, and numerical analysis.
4+
5+
Function
6+
--------
7+
:literal:`af.eig()`
8+
- Python interface for computing the eigenvalues and eigenvectors of a square matrix.
9+
10+
Detailed Description
11+
--------------------
12+
The 'af.eig()' function computes the eigenvalues and eigenvectors of a square matrix. For a given matrix
13+
A, eigenvalues and eigenvectors are defined such that:
14+
15+
𝐴𝑣 = 𝜆𝑣
16+
17+
18+
where:
19+
- λ represents an eigenvalue.
20+
- v represents the corresponding eigenvector.
21+
The function returns two arrays:
22+
- An array containing the eigenvalues of the matrix.
23+
- An array containing the eigenvectors of the matrix. Each column in this array corresponds to an eigenvector.
24+
25+
Function Documentation
26+
----------------------
27+
.. sidebar:: af.eig()
28+
29+
Syntax:
30+
eigenvalues, eigenvectors = af.eig(matrix)
31+
32+
Parameters:
33+
'matrix': A 2D ArrayFire array (matrix) for which eigenvalues and eigenvectors are to be computed. The matrix must be square (i.e., the number of rows must be equal to the number of columns).
34+
35+
Returns:
36+
- eigenvalues: An ArrayFire array containing the eigenvalues of the input matrix.
37+
- eigenvectors: An ArrayFire array containing the eigenvectors of the input matrix. Each column of this array is an eigenvector corresponding to the eigenvalues.

0 commit comments

Comments
 (0)