@@ -15,62 +15,101 @@ import ArrayFire.FFI
15
15
import ArrayFire.Types
16
16
import ArrayFire.Internal.Types
17
17
18
- -- | This function factorizes a matrix A into two unitary matrices U and Vt, and a diagonal matrix S such that
19
- -- A=U∗S∗Vt
18
+ -- | Singular Value Decomposition
20
19
--
21
- -- If A has M rows and N columns, U is of the size M x M , V is of size N x N, and S is of size M x N
20
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__svd.htm)
22
21
--
23
22
-- The arrayfire function only returns the non zero diagonal elements of S.
24
23
--
25
24
svd
26
25
:: AFType a
27
26
=> Array a
28
- -- ^ Input matrix
27
+ -- ^ the input Matrix
29
28
-> (Array a , Array a , Array a )
30
- -- ^ 'u' is the output array containing U
31
- --
32
- -- 'v' is the output array containing the diagonal values of sigma, (singular values of the input matrix))
33
- --
34
- -- 'vt' is the output array containing V^H
29
+ -- ^ Output 'Array' containing (U, diagonal values of sigma, V^H)
35
30
svd = (`op3p` af_svd)
36
31
37
- -- | Calculates the 'svd' of an Array in place.
32
+ -- | Singular Value Decomposition (in-place)
33
+ --
34
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__svd.htm)
35
+ --
36
+ -- The arrayfire function only returns the non zero diagonal elements of S.
37
+ --
38
38
svdInPlace
39
39
:: AFType a
40
40
=> Array a
41
+ -- ^ the input matrix
41
42
-> (Array a , Array a , Array a )
43
+ -- ^ Output 'Array' containing (U, diagonal values of sigma, V^H)
42
44
svdInPlace = (`op3p` af_svd_inplace)
43
45
44
- -- | Calculates the 'lu' decomposition of an Array.
46
+ -- | Perform LU decomposition
47
+ --
48
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__lu.htm)
49
+ --
50
+ -- C Interface for LU decomposition.
51
+ --
45
52
lu
46
53
:: AFType a
47
54
=> Array a
55
+ -- ^ is the input matrix
48
56
-> (Array a , Array a , Array a )
57
+ -- ^ Returns the output 'Array's (lower, upper, pivot)
49
58
lu = (`op3p` af_lu)
50
59
51
- -- | Calculates the 'lu' decomposition of an Array in place.
60
+ -- | Perform LU decomposition (in-place).
61
+ --
62
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__lu.htm#ga0adcdc4b189c34644a7153c6ce9c4f7f)
63
+ --
64
+ -- C Interface for in place LU decomposition.
65
+ --
52
66
luInPlace
53
67
:: AFType a
54
68
=> Array a
69
+ -- ^ contains the input on entry, the packed LU decomposition on exit.
55
70
-> Bool
71
+ -- ^ specifies if the pivot is returned in original LAPACK compliant format
56
72
-> Array a
73
+ -- ^ will contain the permutation indices to map the input to the decomposition
57
74
luInPlace a (fromIntegral . fromEnum -> b) = a `op1` (\ x y -> af_lu_inplace x y b)
58
75
59
- -- | Calculates the 'qr' decomposition of an Array.
76
+ -- | Perform QR decomposition
77
+ --
78
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__qr.htm)
79
+ --
80
+ -- C Interface for QR decomposition.
81
+ --
60
82
qr
61
83
:: AFType a
62
84
=> Array a
85
+ -- ^ the input matrix
63
86
-> (Array a , Array a , Array a )
87
+ -- ^ Returns (q, r, tau) 'Array's
88
+ -- /q/ is the orthogonal matrix from QR decomposition
89
+ -- /r/ is the upper triangular matrix from QR decomposition
90
+ -- /tau/ will contain additional information needed for solving a least squares problem using /q/ and /r/
64
91
qr = (`op3p` af_qr)
65
92
66
- -- | Calculates the 'qr' decomposition of an Array in place.
93
+ -- | Perform QR decomposition
94
+ --
95
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__qr.htm)
96
+ --
97
+ -- C Interface for QR decomposition.
98
+ --
67
99
qrInPlace
68
100
:: AFType a
69
101
=> Array a
102
+ -- ^ is the input matrix on entry. It contains packed QR decomposition on exit
70
103
-> Array a
104
+ -- ^ will contain additional information needed for unpacking the data
71
105
qrInPlace = (`op1` af_qr_inplace)
72
106
73
- -- | Calculates the 'cholesky' factorization of an 'Array'
107
+ -- | Perform Cholesky Decomposition
108
+ --
109
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__cholesky.htm)
110
+ --
111
+ -- This function decomposes a positive definite matrix A into two triangular matrices.
112
+ --
74
113
cholesky
75
114
:: AFType a
76
115
=> Array a
@@ -79,48 +118,87 @@ cholesky
79
118
-- ^ a boolean determining if out is upper or lower triangular
80
119
-> (Int , Array a )
81
120
-- ^ contains the triangular matrix. Multiply 'Int' with its conjugate transpose reproduces the input array.
121
+ -- is 0 if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.
82
122
cholesky a (fromIntegral . fromEnum -> b) = do
83
123
let (x',y') = op1b a (\ x y z -> af_cholesky x y z b)
84
124
(fromIntegral x', y')
85
125
86
- -- | Calculates the 'cholesky' factorization in place.
126
+ -- | Perform Cholesky Decomposition
127
+ --
128
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__cholesky.htm)
129
+ --
130
+ -- C Interface for in place cholesky decomposition.
131
+ --
87
132
choleskyInplace
88
133
:: AFType a
89
134
=> Array a
135
+ -- ^ is the input matrix on entry. It contains the triangular matrix on exit.
90
136
-> Bool
137
+ -- ^ a boolean determining if in is upper or lower triangular
91
138
-> Int
139
+ -- ^ is 0 if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.
92
140
choleskyInplace a (fromIntegral . fromEnum -> b) =
93
141
fromIntegral $ infoFromArray a (\ x y -> af_cholesky_inplace x y b)
94
142
143
+ -- | Solve a system of equations
144
+ --
145
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__solve__func__gen.htm)
146
+ --
95
147
solve
96
148
:: AFType a
97
149
=> Array a
150
+ -- ^ is the coefficient matrix
98
151
-> Array a
152
+ -- ^ is the measured values
99
153
-> MatProp
154
+ -- ^ determining various properties of matrix a
100
155
-> Array a
156
+ -- ^ is the matrix of unknown variables
101
157
solve a b m =
102
158
op2 a b (\ x y z -> af_solve x y z (toMatProp m))
103
159
160
+ -- | Solve a system of equations.
161
+ --
162
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__solve__lu__func__gen.htm)
163
+ --
104
164
solveLU
105
165
:: AFType a
106
166
=> Array a
167
+ -- ^ is the output matrix from packed LU decomposition of the coefficient matrix
107
168
-> Array a
169
+ -- ^ is the pivot array from packed LU decomposition of the coefficient matrix
108
170
-> Array a
171
+ -- ^ is the matrix of measured values
109
172
-> MatProp
173
+ -- ^ determining various properties of matrix a
110
174
-> Array a
175
+ -- ^ will contain the matrix of unknown variables
111
176
solveLU a b c m =
112
177
op3 a b c (\ x y z w -> af_solve_lu x y z w (toMatProp m))
113
178
179
+ -- | Invert a matrix.
180
+ --
181
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__ops__func__inv.htm)
182
+ --
183
+ -- C Interface for inverting a matrix.
184
+ --
114
185
inverse
115
186
:: AFType a
116
187
=> Array a
188
+ -- ^ is input matrix
117
189
-> MatProp
190
+ -- ^ determining various properties of matrix in
118
191
-> Array a
192
+ -- ^ will contain the inverse of matrix in
119
193
inverse a m =
120
194
a `op1` (\ x y -> af_inverse x y (toMatProp m))
121
195
122
- -- | Not implemented in '3.6.4'
123
- -- Calculates pseudo inverse of 'Array'.
196
+ -- | Pseudo-inverse
197
+ --
198
+ -- Not implemented in /3.6.4/
199
+ --
200
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__p_inv.htm)
201
+ --
124
202
pinverse
125
203
:: AFType a
126
204
=> Array a
@@ -130,35 +208,63 @@ pinverse
130
208
pinverse a d m =
131
209
a `op1` (\ x y -> af_pinverse x y d (toMatProp m))
132
210
133
- -- | Calculates 'rank' of 'Array'
211
+ -- | Find the rank of the input matrix
212
+ --
213
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__factor__func__rank.htm)
214
+ --
215
+ -- This function uses af::qr to find the rank of the input matrix within the given tolerance.
216
+ --
134
217
rank
135
218
:: AFType a
136
219
=> Array a
220
+ -- ^ is input matrix
137
221
-> Double
222
+ -- ^ is the tolerance value
138
223
-> Int
224
+ -- ^ will contain the rank of in
139
225
rank a b =
140
226
fromIntegral (a `infoFromArray` (\ x y -> af_rank x y b))
141
227
142
- -- | Calculates the determinant of an 'Array'
228
+ -- | Find the determinant of a Matrix
229
+ --
230
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__ops__func__det.htm)
231
+ --
232
+ -- C Interface for finding the determinant of a matrix.
233
+ --
143
234
det
144
235
:: AFType a
145
236
=> Array a
237
+ -- ^ is input matrix
146
238
-> (Double ,Double )
239
+ -- ^ will contain the real and imaginary part of the determinant of in
147
240
det = (`infoFromArray2` af_det)
148
241
149
-
150
- -- | Calculates the 'norm' of 'Array'.
242
+ -- | Find the norm of the input matrix.
243
+ --
244
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__ops__func__norm.htm)
245
+ --
246
+ -- This function can return the norm using various metrics based on the type paramter.
247
+ --
151
248
norm
152
249
:: AFType a
153
250
=> Array a
251
+ -- ^ is the input matrix
154
252
-> NormType
253
+ -- ^ specifies the 'NormType'
155
254
-> Double
255
+ -- ^ specifies the value of P when type is one of AF_NORM_VECTOR_P, AF_NORM_MATRIX_L_PQ is used. It is ignored for other values of type
156
256
-> Double
257
+ -- ^ specifies the value of Q when type is AF_NORM_MATRIX_L_PQ. This parameter is ignored if type is anything else
157
258
-> Double
259
+ -- ^ will contain the norm of in
158
260
norm arr (fromNormType -> a) b c =
159
261
arr `infoFromArray` (\ w y -> af_norm w y a b c)
160
262
161
263
-- | Is LAPACK available
162
- isLAPACKAvailable :: Bool
264
+ --
265
+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__helper__func__available.htm)
266
+ isLAPACKAvailable
267
+ :: Bool
268
+ -- ^ Returns if LAPACK is available
163
269
isLAPACKAvailable =
164
270
toEnum . fromIntegral $ afCall1' af_is_lapack_available
0 commit comments