Skip to content

Commit cef85ee

Browse files
committed
Adding documentation for base.py and blas.py
1 parent c8ec234 commit cef85ee

File tree

2 files changed

+159
-0
lines changed

2 files changed

+159
-0
lines changed

arrayfire/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,17 @@
66
# The complete license agreement can be obtained at:
77
# http://arrayfire.com/licenses/BSD-3-Clause
88
########################################################
9+
10+
"""
11+
Implementation of BaseArray class.
12+
"""
13+
914
from .library import *
1015
from .util import *
1116

1217
class BaseArray(object):
18+
"""
19+
Base array class for arrayfire. For internal use only.
20+
"""
1321
def __init__(self):
1422
self.arr = ct.c_void_p(0)

arrayfire/blas.py

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,185 @@
77
# http://arrayfire.com/licenses/BSD-3-Clause
88
########################################################
99

10+
"""
11+
BLAS functions for arrayfire.
12+
"""
13+
1014
from .library import *
1115
from .array import *
1216

1317
def matmul(lhs, rhs, lhs_opts=MATPROP.NONE, rhs_opts=MATPROP.NONE):
18+
"""
19+
Generalized matrix multiplication for two matrices.
20+
21+
Parameters
22+
----------
23+
24+
lhs : af.Array
25+
A 2 dimensional, real or complex arrayfire array.
26+
27+
rhs : af.Array
28+
A 2 dimensional, real or complex arrayfire array.
29+
30+
lhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
31+
Can be one of
32+
- af.MATPROP.NONE - If no op should be done on `lhs`.
33+
- af.MATPROP.TRANS - If `lhs` has to be transposed before multiplying.
34+
- af.MATPROP.CTRANS - If `lhs` has to be hermitian transposed before multiplying.
35+
36+
rhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
37+
Can be one of
38+
- af.MATPROP.NONE - If no op should be done on `rhs`.
39+
- af.MATPROP.TRANS - If `rhs` has to be transposed before multiplying.
40+
- af.MATPROP.CTRANS - If `rhs` has to be hermitian transposed before multiplying.
41+
42+
Returns
43+
-------
44+
45+
out : af.Array
46+
Output of the matrix multiplication on `lhs` and `rhs`.
47+
48+
Note
49+
-----
50+
51+
- The data types of `lhs` and `rhs` should be the same.
52+
- Batches are not supported.
53+
54+
"""
1455
out = Array()
1556
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
1657
lhs_opts.value, rhs_opts.value))
1758
return out
1859

1960
def matmulTN(lhs, rhs):
61+
"""
62+
Matrix multiplication after transposing the first matrix.
63+
64+
Parameters
65+
----------
66+
67+
lhs : af.Array
68+
A 2 dimensional, real or complex arrayfire array.
69+
70+
rhs : af.Array
71+
A 2 dimensional, real or complex arrayfire array.
72+
73+
Returns
74+
-------
75+
76+
out : af.Array
77+
Output of the matrix multiplication on `transpose(lhs)` and `rhs`.
78+
79+
Note
80+
-----
81+
82+
- The data types of `lhs` and `rhs` should be the same.
83+
- Batches are not supported.
84+
85+
"""
2086
out = Array()
2187
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
2288
MATPROP.TRANS.value, MATPROP.NONE.value))
2389
return out
2490

2591
def matmulNT(lhs, rhs):
92+
"""
93+
Matrix multiplication after transposing the second matrix.
94+
95+
Parameters
96+
----------
97+
98+
lhs : af.Array
99+
A 2 dimensional, real or complex arrayfire array.
100+
101+
rhs : af.Array
102+
A 2 dimensional, real or complex arrayfire array.
103+
104+
Returns
105+
-------
106+
107+
out : af.Array
108+
Output of the matrix multiplication on `lhs` and `transpose(rhs)`.
109+
110+
Note
111+
-----
112+
113+
- The data types of `lhs` and `rhs` should be the same.
114+
- Batches are not supported.
115+
116+
"""
26117
out = Array()
27118
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
28119
MATPROP.NONE.value, MATPROP.TRANS.value))
29120
return out
30121

31122
def matmulTT(lhs, rhs):
123+
"""
124+
Matrix multiplication after transposing both inputs.
125+
126+
Parameters
127+
----------
128+
129+
lhs : af.Array
130+
A 2 dimensional, real or complex arrayfire array.
131+
132+
rhs : af.Array
133+
A 2 dimensional, real or complex arrayfire array.
134+
135+
Returns
136+
-------
137+
138+
out : af.Array
139+
Output of the matrix multiplication on `transpose(lhs)` and `transpose(rhs)`.
140+
141+
Note
142+
-----
143+
144+
- The data types of `lhs` and `rhs` should be the same.
145+
- Batches are not supported.
146+
147+
"""
32148
out = Array()
33149
safe_call(backend.get().af_matmul(ct.pointer(out.arr), lhs.arr, rhs.arr,
34150
MATPROP.TRANS.value, MATPROP.TRANS.value))
35151
return out
36152

37153
def dot(lhs, rhs, lhs_opts=MATPROP.NONE, rhs_opts=MATPROP.NONE):
154+
"""
155+
Dot product of two input vectors.
156+
157+
Parameters
158+
----------
159+
160+
lhs : af.Array
161+
A 1 dimensional, real or complex arrayfire array.
162+
163+
rhs : af.Array
164+
A 1 dimensional, real or complex arrayfire array.
165+
166+
lhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
167+
Can be one of
168+
- af.MATPROP.NONE - If no op should be done on `lhs`.
169+
- No other options are currently supported.
170+
171+
rhs_opts: optional: af.MATPROP. default: af.MATPROP.NONE.
172+
Can be one of
173+
- af.MATPROP.NONE - If no op should be done on `rhs`.
174+
- No other options are currently supported.
175+
176+
Returns
177+
-------
178+
179+
out : af.Array
180+
Output of dot product of `lhs` and `rhs`.
181+
182+
Note
183+
-----
184+
185+
- The data types of `lhs` and `rhs` should be the same.
186+
- Batches are not supported.
187+
188+
"""
38189
out = Array()
39190
safe_call(backend.get().af_dot(ct.pointer(out.arr), lhs.arr, rhs.arr,
40191
lhs_opts.value, rhs_opts.value))

0 commit comments

Comments
 (0)