Skip to content

Commit 81c50f7

Browse files
committed
Documentation update
1 parent 4477f59 commit 81c50f7

File tree

6 files changed

+128
-102
lines changed

6 files changed

+128
-102
lines changed

src/data/mod.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,16 @@ pub fn get_seed() -> u64 {
270270
}
271271

272272
macro_rules! data_gen_def {
273-
($fn_name:ident, $ffi_name: ident) => (
273+
($doc_str: expr, $fn_name:ident, $ffi_name: ident) => (
274+
#[doc=$doc_str]
275+
///
276+
///# Parameters
277+
///
278+
/// - `dims` is the output dimensions
279+
///
280+
///# Return Values
281+
///
282+
/// An Array with modified data.
274283
#[allow(unused_mut)]
275284
pub fn $fn_name<T: HasAfEnum>(dims: Dim4) -> Array {
276285
unsafe {
@@ -286,9 +295,9 @@ macro_rules! data_gen_def {
286295
)
287296
}
288297

289-
data_gen_def!(randu, af_randu);
290-
data_gen_def!(randn, af_randn);
291-
data_gen_def!(identity, af_identity);
298+
data_gen_def!("Create random numbers from uniform distribution", randu, af_randu);
299+
data_gen_def!("Create random numbers from normal distribution", randn, af_randn);
300+
data_gen_def!("Create an identity array with 1's in diagonal", identity, af_identity);
292301

293302
/// Create a diagonal matrix
294303
///
@@ -380,7 +389,17 @@ pub fn join_many(dim: i32, inputs: Vec<&Array>) -> Array {
380389
}
381390

382391
macro_rules! data_func_def {
383-
($fn_name:ident, $ffi_name: ident) => (
392+
($doc_str: expr, $fn_name:ident, $ffi_name: ident) => (
393+
#[doc=$doc_str]
394+
///
395+
///# Parameters
396+
///
397+
/// - `input` is the input Array
398+
/// - `dims` is the target(output) dimensions
399+
///
400+
///# Return Values
401+
///
402+
/// An Array with modified data.
384403
#[allow(unused_mut)]
385404
pub fn $fn_name(input: &Array, dims: Dim4) -> Array {
386405
unsafe {
@@ -395,9 +414,9 @@ macro_rules! data_func_def {
395414
)
396415
}
397416

398-
data_func_def!(tile, af_tile);
399-
data_func_def!(reorder, af_reorder);
400-
data_func_def!(shift, af_shift);
417+
data_func_def!("Tile the input array along specified dimension", tile, af_tile);
418+
data_func_def!("Reorder the array in specified order", reorder, af_reorder);
419+
data_func_def!("Circular shift of values along specified dimension", shift, af_shift);
401420

402421
/// Change the shape of the Array
403422
///
@@ -635,4 +654,4 @@ pub fn replace_scalar(a: &mut Array, cond: &Array, b: f64) {
635654
let err_val = af_replace_scalar(a.get() as AfArray, cond.get() as AfArray, b as c_double);
636655
HANDLE_ERROR(AfError::from(err_val));
637656
}
638-
}
657+
}

src/image/mod.rs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,19 @@ pub fn mean_shift(input: &Array, spatial_sigma: f32, chromatic_sigma: f32,
652652
}
653653

654654
macro_rules! filt_func_def {
655-
($fn_name: ident, $ffi_name: ident) => (
655+
($doc_str: expr, $fn_name: ident, $ffi_name: ident) => (
656+
#[doc=$doc_str]
657+
///
658+
///# Parameters
659+
///
660+
/// - `input` is the input image(Array)
661+
/// - `wlen` is the horizontal length of the filter
662+
/// - `hlen` is the vertical length of the filter
663+
/// - `etype` is enum of type [BorderType](./enum.BorderType.html)
664+
///
665+
///# Return Values
666+
///
667+
/// An Array with filtered image data.
656668
#[allow(unused_mut)]
657669
pub fn $fn_name(input: &Array, wlen: u64, wwid: u64,
658670
etype: BorderType) -> Array {
@@ -667,9 +679,9 @@ macro_rules! filt_func_def {
667679
)
668680
}
669681

670-
filt_func_def!(medfilt, af_medfilt);
671-
filt_func_def!(minfilt, af_minfilt);
672-
filt_func_def!(maxfilt, af_maxfilt);
682+
filt_func_def!("Median filter", medfilt, af_medfilt);
683+
filt_func_def!("Box filter with minimum as box operation", minfilt, af_minfilt);
684+
filt_func_def!("Box filter with maximum as box operation", maxfilt, af_maxfilt);
673685

674686
/// Creates a Gaussian Kernel.
675687
///
@@ -830,14 +842,18 @@ pub fn hist_equal(input: &Array, hist: &Array) -> Array {
830842
}
831843

832844
macro_rules! grayrgb_func_def {
833-
($fn_name: ident, $ffi_name: ident) => (
834-
/// Color space conversion functions
845+
($doc_str: expr, $fn_name: ident, $ffi_name: ident) => (
846+
#[doc=$doc_str]
835847
///
836-
/// # Parameters
848+
///# Parameters
837849
///
838850
/// - `r` is fraction of red channel to appear in output
839851
/// - `g` is fraction of green channel to appear in output
840852
/// - `b` is fraction of blue channel to appear in output
853+
///
854+
///#Return Values
855+
///
856+
///An Array with image data in target color space
841857
#[allow(unused_mut)]
842858
pub fn $fn_name(input: &Array, r: f32, g: f32, b: f32) -> Array {
843859
unsafe {
@@ -851,12 +867,12 @@ macro_rules! grayrgb_func_def {
851867
)
852868
}
853869

854-
grayrgb_func_def!(rgb2gray, af_rgb2gray);
855-
grayrgb_func_def!(gray2rgb, af_gray2rgb);
870+
grayrgb_func_def!("Color(RGB) to Grayscale conversion", rgb2gray, af_rgb2gray);
871+
grayrgb_func_def!("Grayscale to Color(RGB) conversion", gray2rgb, af_gray2rgb);
856872

857873
macro_rules! hsvrgb_func_def {
858-
($fn_name: ident, $ffi_name: ident) => (
859-
/// Color space conversion functions
874+
($doc_str: expr, $fn_name: ident, $ffi_name: ident) => (
875+
#[doc=$doc_str]
860876
#[allow(unused_mut)]
861877
pub fn $fn_name(input: &Array) -> Array {
862878
unsafe {
@@ -869,8 +885,8 @@ macro_rules! hsvrgb_func_def {
869885
)
870886
}
871887

872-
hsvrgb_func_def!(hsv2rgb, af_hsv2rgb);
873-
hsvrgb_func_def!(rgb2hsv, af_rgb2hsv);
888+
hsvrgb_func_def!("HSV to RGB color space conversion", hsv2rgb, af_hsv2rgb);
889+
hsvrgb_func_def!("RGB to HSV color space conversion", rgb2hsv, af_rgb2hsv);
874890

875891
/// Generate an array with image windows as columns
876892
///
@@ -1119,4 +1135,4 @@ pub fn transform_coords(tf: &Array, d0: f32, d1: f32) -> Array {
11191135
HANDLE_ERROR(AfError::from(err_val));
11201136
Array::from(temp)
11211137
}
1122-
}
1138+
}

src/index.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ pub fn row(input: &Array, row_num: u64) -> Array {
160160
}
161161

162162
#[allow(dead_code)]
163-
/// Set row `row_num` in `input` Array to a new Array `new_row`
163+
/// Set `row_num`^th row in `input` Array to a new Array `new_row`
164164
pub fn set_row(input: &Array, new_row: &Array, row_num: u64) -> Array {
165165
assign_seq(input,
166166
&[Seq::new(row_num as f64, row_num as f64, 1.0), Seq::default()],
167167
new_row)
168168
}
169169

170170
#[allow(dead_code)]
171-
/// Get all rows from `first` to `last` in the `input` Array
171+
/// Get an Array with all rows from `first` to `last` in the `input` Array
172172
pub fn rows(input: &Array, first: u64, last: u64) -> Array {
173173
index(input, &[Seq::new(first as f64, last as f64, 1.0), Seq::default()])
174174
}
@@ -197,7 +197,7 @@ pub fn col(input: &Array, col_num: u64) -> Array {
197197
}
198198

199199
#[allow(dead_code)]
200-
/// Set col `col_num` in `input` Array to a new Array `new_col`
200+
/// Set `col_num`^th col in `input` Array to a new Array `new_col`
201201
pub fn set_col(input: &Array, new_col: &Array, col_num: u64) -> Array {
202202
assign_seq(input,
203203
&[Seq::default(), Seq::new(col_num as f64, col_num as f64, 1.0)],
@@ -217,11 +217,11 @@ pub fn set_cols(input: &Array, new_cols: &Array, first: u64, last: u64) -> Array
217217
}
218218

219219
#[allow(dead_code)]
220-
/// Get slice `slice_num` from `input` Array
220+
/// Get `slice_num`^th slice from `input` Array
221221
///
222-
/// Slices indicate that the indexing is along 3rd dimension
222+
/// Note. Slices indicate that the indexing is along 3rd dimension
223223
pub fn slice(input: &Array, slice_num: u64) -> Array {
224-
index(input,
224+
index(input,
225225
&[Seq::default(), Seq::default(), Seq::new(slice_num as f64, slice_num as f64, 1.0)])
226226
}
227227

src/signal/mod.rs

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -270,28 +270,21 @@ pub fn ifft3(input: &Array, norm_factor: f64,
270270
}
271271

272272
macro_rules! conv_func_def {
273-
($fn_name:ident, $ffi_name: ident) => (
274-
/// Convolution
273+
($doc_str: expr, $fn_name:ident, $ffi_name: ident) => (
274+
#[doc=$doc_str]
275275
///
276-
/// The numeric suffix to the function name indicates the dimension in which the
277-
/// convolution operation is going to take place.
278-
///
279-
/// - 1 - Indicates 1d convolution
280-
/// - 2 - Indicates 2d convolution
281-
/// - 3 - Indicates 3d convolution
282-
///
283-
/// # Parameters
276+
///# Parameters
284277
///
285278
/// - `signal` is the input signal
286279
/// - `filter` is the signal that shall be flipped for convolution operation
287280
/// - `mode` indicates if the convolution should be expanded or not(where output size
288-
/// equals input)
281+
/// equals input). It takes a value of type [ConvMode](./enum.ConvMode.html)
289282
/// - `domain` indicates if the convolution should be performed in frequencey or spatial
290-
/// domain
283+
/// domain. It takes a value of type [ConvDomain](./enum.ConvDomain.html)
291284
///
292-
/// # Return Values
285+
///# Return Values
293286
///
294-
/// The convolved Array
287+
/// Convolved Array
295288
#[allow(unused_mut)]
296289
pub fn $fn_name(signal: &Array, filter: &Array,
297290
mode: ConvMode, domain: ConvDomain) -> Array {
@@ -307,9 +300,9 @@ macro_rules! conv_func_def {
307300
)
308301
}
309302

310-
conv_func_def!(convolve1, af_convolve1);
311-
conv_func_def!(convolve2, af_convolve2);
312-
conv_func_def!(convolve3, af_convolve3);
303+
conv_func_def!("1d convolution", convolve1, af_convolve1);
304+
conv_func_def!("2d convolution", convolve2, af_convolve2);
305+
conv_func_def!("3d convolution", convolve3, af_convolve3);
313306

314307
/// Separable convolution for 2d signals
315308
///
@@ -337,26 +330,19 @@ pub fn convolve2_sep(cfilt: &Array, rfilt: &Array, signal: &Array,
337330
}
338331

339332
macro_rules! fft_conv_func_def {
340-
($fn_name:ident, $ffi_name: ident) => (
341-
/// Convolution using Fast-fourier transform
342-
///
343-
/// The numeric suffix to the function name indicates the dimension in which the
344-
/// convolution operation is going to take place.
333+
($doc_str: expr, $fn_name:ident, $ffi_name: ident) => (
334+
#[doc=$doc_str]
345335
///
346-
/// - 1 - Indicates 1d convolution
347-
/// - 2 - Indicates 2d convolution
348-
/// - 3 - Indicates 3d convolution
349-
///
350-
/// # Parameters
336+
///# Parameters
351337
///
352338
/// - `signal` is the input signal
353339
/// - `filter` is the signal that shall be used for convolution operation
354340
/// - `mode` indicates if the convolution should be expanded or not(where output size
355-
/// equals input)
341+
/// equals input). It takes values of type [ConvMode](./enum.ConvMode.html)
356342
///
357-
/// # Return Values
343+
///# Return Values
358344
///
359-
/// The convolved Array
345+
/// Convolved Array
360346
#[allow(unused_mut)]
361347
pub fn $fn_name(signal: &Array, filter: &Array,
362348
mode: ConvMode) -> Array {
@@ -371,9 +357,9 @@ macro_rules! fft_conv_func_def {
371357
)
372358
}
373359

374-
fft_conv_func_def!(fft_convolve1, af_fft_convolve1);
375-
fft_conv_func_def!(fft_convolve2, af_fft_convolve2);
376-
fft_conv_func_def!(fft_convolve3, af_fft_convolve3);
360+
fft_conv_func_def!("1d convolution using fast-fourier transform", fft_convolve1, af_fft_convolve1);
361+
fft_conv_func_def!("2d convolution using fast-fourier transform", fft_convolve2, af_fft_convolve2);
362+
fft_conv_func_def!("3d convolution using fast-fourier transform", fft_convolve3, af_fft_convolve3);
377363

378364
/// Finite impulse filter
379365
///
@@ -623,4 +609,4 @@ pub fn fft3_c2r(input: &Array, norm_factor: f64, is_odd: bool) -> Array {
623609
HANDLE_ERROR(AfError::from(err_val));
624610
Array::from(temp)
625611
}
626-
}
612+
}

0 commit comments

Comments
 (0)