@@ -15,62 +15,101 @@ import ArrayFire.FFI
1515import ArrayFire.Types
1616import ArrayFire.Internal.Types
1717
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
2019--
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)
2221--
2322-- The arrayfire function only returns the non zero diagonal elements of S.
2423--
2524svd
2625 :: AFType a
2726 => Array a
28- -- ^ Input matrix
27+ -- ^ the input Matrix
2928 -> (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)
3530svd = (`op3p` af_svd)
3631
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+ --
3838svdInPlace
3939 :: AFType a
4040 => Array a
41+ -- ^ the input matrix
4142 -> (Array a , Array a , Array a )
43+ -- ^ Output 'Array' containing (U, diagonal values of sigma, V^H)
4244svdInPlace = (`op3p` af_svd_inplace)
4345
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+ --
4552lu
4653 :: AFType a
4754 => Array a
55+ -- ^ is the input matrix
4856 -> (Array a , Array a , Array a )
57+ -- ^ Returns the output 'Array's (lower, upper, pivot)
4958lu = (`op3p` af_lu)
5059
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+ --
5266luInPlace
5367 :: AFType a
5468 => Array a
69+ -- ^ contains the input on entry, the packed LU decomposition on exit.
5570 -> Bool
71+ -- ^ specifies if the pivot is returned in original LAPACK compliant format
5672 -> Array a
73+ -- ^ will contain the permutation indices to map the input to the decomposition
5774luInPlace a (fromIntegral . fromEnum -> b) = a `op1` (\ x y -> af_lu_inplace x y b)
5875
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+ --
6082qr
6183 :: AFType a
6284 => Array a
85+ -- ^ the input matrix
6386 -> (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/
6491qr = (`op3p` af_qr)
6592
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+ --
6799qrInPlace
68100 :: AFType a
69101 => Array a
102+ -- ^ is the input matrix on entry. It contains packed QR decomposition on exit
70103 -> Array a
104+ -- ^ will contain additional information needed for unpacking the data
71105qrInPlace = (`op1` af_qr_inplace)
72106
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+ --
74113cholesky
75114 :: AFType a
76115 => Array a
@@ -79,48 +118,87 @@ cholesky
79118 -- ^ a boolean determining if out is upper or lower triangular
80119 -> (Int , Array a )
81120 -- ^ 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.
82122cholesky a (fromIntegral . fromEnum -> b) = do
83123 let (x',y') = op1b a (\ x y z -> af_cholesky x y z b)
84124 (fromIntegral x', y')
85125
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+ --
87132choleskyInplace
88133 :: AFType a
89134 => Array a
135+ -- ^ is the input matrix on entry. It contains the triangular matrix on exit.
90136 -> Bool
137+ -- ^ a boolean determining if in is upper or lower triangular
91138 -> Int
139+ -- ^ is 0 if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.
92140choleskyInplace a (fromIntegral . fromEnum -> b) =
93141 fromIntegral $ infoFromArray a (\ x y -> af_cholesky_inplace x y b)
94142
143+ -- | Solve a system of equations
144+ --
145+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__solve__func__gen.htm)
146+ --
95147solve
96148 :: AFType a
97149 => Array a
150+ -- ^ is the coefficient matrix
98151 -> Array a
152+ -- ^ is the measured values
99153 -> MatProp
154+ -- ^ determining various properties of matrix a
100155 -> Array a
156+ -- ^ is the matrix of unknown variables
101157solve a b m =
102158 op2 a b (\ x y z -> af_solve x y z (toMatProp m))
103159
160+ -- | Solve a system of equations.
161+ --
162+ -- [ArrayFire Docs](http://arrayfire.org/docs/group__lapack__solve__lu__func__gen.htm)
163+ --
104164solveLU
105165 :: AFType a
106166 => Array a
167+ -- ^ is the output matrix from packed LU decomposition of the coefficient matrix
107168 -> Array a
169+ -- ^ is the pivot array from packed LU decomposition of the coefficient matrix
108170 -> Array a
171+ -- ^ is the matrix of measured values
109172 -> MatProp
173+ -- ^ determining various properties of matrix a
110174 -> Array a
175+ -- ^ will contain the matrix of unknown variables
111176solveLU a b c m =
112177 op3 a b c (\ x y z w -> af_solve_lu x y z w (toMatProp m))
113178
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+ --
114185inverse
115186 :: AFType a
116187 => Array a
188+ -- ^ is input matrix
117189 -> MatProp
190+ -- ^ determining various properties of matrix in
118191 -> Array a
192+ -- ^ will contain the inverse of matrix in
119193inverse a m =
120194 a `op1` (\ x y -> af_inverse x y (toMatProp m))
121195
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+ --
124202pinverse
125203 :: AFType a
126204 => Array a
@@ -130,35 +208,63 @@ pinverse
130208pinverse a d m =
131209 a `op1` (\ x y -> af_pinverse x y d (toMatProp m))
132210
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+ --
134217rank
135218 :: AFType a
136219 => Array a
220+ -- ^ is input matrix
137221 -> Double
222+ -- ^ is the tolerance value
138223 -> Int
224+ -- ^ will contain the rank of in
139225rank a b =
140226 fromIntegral (a `infoFromArray` (\ x y -> af_rank x y b))
141227
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+ --
143234det
144235 :: AFType a
145236 => Array a
237+ -- ^ is input matrix
146238 -> (Double ,Double )
239+ -- ^ will contain the real and imaginary part of the determinant of in
147240det = (`infoFromArray2` af_det)
148241
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+ --
151248norm
152249 :: AFType a
153250 => Array a
251+ -- ^ is the input matrix
154252 -> NormType
253+ -- ^ specifies the 'NormType'
155254 -> 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
156256 -> Double
257+ -- ^ specifies the value of Q when type is AF_NORM_MATRIX_L_PQ. This parameter is ignored if type is anything else
157258 -> Double
259+ -- ^ will contain the norm of in
158260norm arr (fromNormType -> a) b c =
159261 arr `infoFromArray` (\ w y -> af_norm w y a b c)
160262
161263-- | 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
163269isLAPACKAvailable =
164270 toEnum . fromIntegral $ afCall1' af_is_lapack_available
0 commit comments