Skip to content

Commit 0839d4d

Browse files
committed
Documentation for modules lapack, signal & statistics
1 parent 2178c03 commit 0839d4d

File tree

3 files changed

+414
-0
lines changed

3 files changed

+414
-0
lines changed

src/lapack/mod.rs

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ extern {
2626
fn af_norm(out: MutDouble, input: AfArray, ntype: uint8_t, p: c_double, q: c_double) -> c_int;
2727
}
2828

29+
/// Perform LU decomposition
30+
///
31+
/// # Parameters
32+
///
33+
/// - `input` is the input matrix
34+
///
35+
/// # Return Values
36+
///
37+
/// A triplet of Arrays.
38+
///
39+
/// The first Array will contain the lower triangular matrix of the LU decomposition.
40+
///
41+
/// The second Array will contain the lower triangular matrix of the LU decomposition.
42+
///
43+
/// The third Array will contain the permutation indices to map the input to the decomposition.
2944
#[allow(unused_mut)]
3045
pub fn lu(input: &Array) -> Result<(Array, Array, Array), AfError> {
3146
unsafe {
@@ -41,6 +56,17 @@ pub fn lu(input: &Array) -> Result<(Array, Array, Array), AfError> {
4156
}
4257
}
4358

59+
/// Perform inplace LU decomposition
60+
///
61+
/// # Parameters
62+
///
63+
/// - `input` is the input matrix
64+
/// - `is_lapack_pic` specified if the pivot is returned in original LAPACK compliant format
65+
///
66+
/// # Return Values
67+
///
68+
/// An Array with permutation indices to map the input to the decomposition. Since, the input
69+
/// matrix is modified in place, only pivot values are returned.
4470
#[allow(unused_mut)]
4571
pub fn lu_inplace(input: &mut Array, is_lapack_piv: bool) -> Result<Array, AfError> {
4672
unsafe {
@@ -54,6 +80,22 @@ pub fn lu_inplace(input: &mut Array, is_lapack_piv: bool) -> Result<Array, AfErr
5480
}
5581
}
5682

83+
/// Perform QR decomposition
84+
///
85+
/// # Parameters
86+
///
87+
/// - `input` is the input matrix
88+
///
89+
/// # Return Values
90+
///
91+
/// A triplet of Arrays.
92+
///
93+
/// The first Array is the orthogonal matrix from QR decomposition
94+
///
95+
/// The second Array is the upper triangular matrix from QR decomposition
96+
///
97+
/// The third Array will contain additional information needed for solving a least squares problem
98+
/// using q and r
5799
#[allow(unused_mut)]
58100
pub fn qr(input: &Array) -> Result<(Array, Array, Array), AfError> {
59101
unsafe {
@@ -69,6 +111,15 @@ pub fn qr(input: &Array) -> Result<(Array, Array, Array), AfError> {
69111
}
70112
}
71113

114+
/// Perform inplace QR decomposition
115+
///
116+
/// # Parameters
117+
///
118+
/// - `input` is the input matrix
119+
///
120+
/// # Return Values
121+
///
122+
/// An Array with additional information needed for unpacking the data.
72123
#[allow(unused_mut)]
73124
pub fn qr_inplace(input: &mut Array) -> Result<Array, AfError> {
74125
unsafe {
@@ -81,6 +132,21 @@ pub fn qr_inplace(input: &mut Array) -> Result<Array, AfError> {
81132
}
82133
}
83134

135+
/// Perform Cholesky decomposition
136+
///
137+
/// # Parameters
138+
///
139+
/// - `input` is the input matrix
140+
/// - `is_upper` is a boolean to indicate if the output has to be upper or lower triangular matrix
141+
///
142+
/// # Return Values
143+
///
144+
/// A tuple of an Array and signed 32-bit integer.
145+
///
146+
/// The Array contains the triangular matrix (multiply it with conjugate transpose to reproduce the input).
147+
///
148+
/// If the integer is 0, it means the cholesky decomposition passed. Otherwise, it will contain the rank at
149+
/// which the decomposition failed.
84150
#[allow(unused_mut)]
85151
pub fn cholesky(input: &Array, is_upper: bool) -> Result<(Array, i32), AfError> {
86152
unsafe {
@@ -95,6 +161,17 @@ pub fn cholesky(input: &Array, is_upper: bool) -> Result<(Array, i32), AfError>
95161
}
96162
}
97163

164+
/// Perform inplace Cholesky decomposition
165+
///
166+
/// # Parameters
167+
///
168+
/// - `input` is the input matrix
169+
/// - `is_upper` is a boolean to indicate if the output has to be upper or lower triangular matrix
170+
///
171+
/// # Return Values
172+
///
173+
/// A signed 32-bit integer. If the integer is 0, it means the cholesky decomposition passed. Otherwise,
174+
/// it will contain the rank at which the decomposition failed.
98175
#[allow(unused_mut)]
99176
pub fn cholesky_inplace(input: &mut Array, is_upper: bool) -> Result<i32, AfError> {
100177
unsafe {
@@ -108,6 +185,19 @@ pub fn cholesky_inplace(input: &mut Array, is_upper: bool) -> Result<i32, AfErro
108185
}
109186
}
110187

188+
/// Solve a system of equations
189+
///
190+
/// # Parameters
191+
///
192+
/// - `a` is the coefficient matrix
193+
/// - `b` has the measured values
194+
/// - `options` determine the various properties of matrix a
195+
///
196+
/// The `options` parameter currently needs to be either `NONE`, `LOWER` or `UPPER`, other values are not supported yet.
197+
///
198+
/// # Return Values
199+
///
200+
/// An Array which is the matrix of unknown variables
111201
#[allow(unused_mut)]
112202
pub fn solve(a: &Array, b: &Array, options: MatProp) -> Result<Array, AfError> {
113203
unsafe {
@@ -121,6 +211,20 @@ pub fn solve(a: &Array, b: &Array, options: MatProp) -> Result<Array, AfError> {
121211
}
122212
}
123213

214+
/// Solve a system of equations
215+
///
216+
/// # Parameters
217+
///
218+
/// - `a` is the output matrix from packed LU decomposition of the coefficient matrix
219+
/// - `piv` is the pivot array from packed LU decomposition of the coefficient matrix
220+
/// - `b` has the measured values
221+
/// - `options` determine the various properties of matrix a
222+
///
223+
/// The `options` parameter currently needs to be `NONE`, other values are not supported yet.
224+
///
225+
/// # Return Values
226+
///
227+
/// An Array which is the matrix of unknown variables
124228
#[allow(unused_mut)]
125229
pub fn solve_lu(a: &Array, piv: &Array, b: &Array,
126230
options: MatProp) -> Result<Array, AfError> {
@@ -135,6 +239,18 @@ pub fn solve_lu(a: &Array, piv: &Array, b: &Array,
135239
}
136240
}
137241

242+
/// Compute inverse of a matrix
243+
///
244+
/// # Parameters
245+
///
246+
/// - `input` is the input matrix
247+
/// - `options` determine various properties of input matrix
248+
///
249+
/// The parameter `options` currently take only the value `NONE`.
250+
///
251+
/// # Return Values
252+
///
253+
/// An Array with values of the inverse of input matrix.
138254
#[allow(unused_mut)]
139255
pub fn inverse(input: &Array, options: MatProp) -> Result<Array, AfError> {
140256
unsafe {
@@ -147,6 +263,16 @@ pub fn inverse(input: &Array, options: MatProp) -> Result<Array, AfError> {
147263
}
148264
}
149265

266+
/// Find rank of a matrix
267+
///
268+
/// # Parameters
269+
///
270+
/// - `input` is the input matrix
271+
/// - `tol` is the tolerance value
272+
///
273+
/// # Return Values
274+
///
275+
/// An unsigned 32-bit integer which is the rank of the input matrix.
150276
#[allow(unused_mut)]
151277
pub fn rank(input: &Array, tol: f64) -> Result<u32, AfError> {
152278
unsafe {
@@ -159,6 +285,17 @@ pub fn rank(input: &Array, tol: f64) -> Result<u32, AfError> {
159285
}
160286
}
161287

288+
/// Find the determinant of the matrix
289+
///
290+
/// # Parameters
291+
///
292+
/// - `input` is the input matrix
293+
///
294+
/// # Return Values
295+
///
296+
/// A tuple of 32-bit floating point values.
297+
///
298+
/// If the input matrix is non-complex type, only first values of tuple contains the result.
162299
#[allow(unused_mut)]
163300
pub fn det(input: &Array) -> Result<(f64, f64), AfError> {
164301
unsafe {
@@ -172,6 +309,20 @@ pub fn det(input: &Array) -> Result<(f64, f64), AfError> {
172309
}
173310
}
174311

312+
/// Find the norm of a matrix
313+
///
314+
/// # Parameters
315+
///
316+
/// - `input` is the input matrix
317+
/// - `ntype` is specifies the required norm type using enum [NormType](./enum.NormType.html)
318+
/// - `p` specifies the value of *P* when `ntype` is one of VECTOR_P, MATRIX_L_PQ. It is ignored
319+
/// for other values of `ntype`
320+
/// - `q` specifies the value of *Q* when `ntype` is MATRIX_L_PQ. This parameter is ignored if
321+
/// `ntype` is anything else.
322+
///
323+
/// # Return Values
324+
///
325+
/// A 64-bit floating point value that contains the norm of input matrix.
175326
#[allow(unused_mut)]
176327
pub fn norm(input: &Array, ntype: NormType, p: f64, q: f64) -> Result<f64, AfError> {
177328
unsafe {

0 commit comments

Comments
 (0)