@@ -111,7 +111,10 @@ impl<'f> Not for &'f Array {
111111}
112112
113113macro_rules! unary_func {
114- ( $fn_name: ident, $ffi_fn: ident) => (
114+ ( $doc_str: expr, $fn_name: ident, $ffi_fn: ident) => (
115+ #[ doc=$doc_str]
116+ ///
117+ /// This is an element wise unary operation.
115118 #[ allow( unused_mut) ]
116119 pub fn $fn_name( input: & Array ) -> Array {
117120 unsafe {
@@ -124,50 +127,53 @@ macro_rules! unary_func {
124127 )
125128}
126129
127- unary_func ! ( abs, af_abs) ;
128- unary_func ! ( arg, af_arg) ;
129- unary_func ! ( sign, af_sign) ;
130- unary_func ! ( round, af_round) ;
131- unary_func ! ( trunc, af_trunc) ;
132- unary_func ! ( floor, af_floor) ;
133- unary_func ! ( ceil, af_ceil) ;
134- unary_func ! ( sin, af_sin) ;
135- unary_func ! ( cos, af_cos) ;
136- unary_func ! ( tan, af_tan) ;
137- unary_func ! ( asin, af_asin) ;
138- unary_func ! ( acos, af_acos) ;
139- unary_func ! ( atan, af_atan) ;
140- unary_func ! ( cplx, af_cplx) ;
141- unary_func ! ( real, af_real) ;
142- unary_func ! ( imag, af_imag) ;
143- unary_func ! ( conjg, af_conjg) ;
144- unary_func ! ( sinh, af_sinh) ;
145- unary_func ! ( cosh, af_cosh) ;
146- unary_func ! ( tanh, af_tanh) ;
147- unary_func ! ( asinh, af_asinh) ;
148- unary_func ! ( acosh, af_acosh) ;
149- unary_func ! ( atanh, af_atanh) ;
150- unary_func ! ( pow2, af_pow2) ;
151- unary_func ! ( exp, af_exp) ;
152- unary_func ! ( sigmoid, af_sigmoid) ;
153- unary_func ! ( expm1, af_expm1) ;
154- unary_func ! ( erf, af_erf) ;
155- unary_func ! ( erfc, af_erfc) ;
156- unary_func ! ( log, af_log) ;
157- unary_func ! ( log1p, af_log1p) ;
158- unary_func ! ( log10, af_log10) ;
159- unary_func ! ( log2, af_log2) ;
160- unary_func ! ( sqrt, af_sqrt) ;
161- unary_func ! ( cbrt, af_cbrt) ;
162- unary_func ! ( factorial, af_factorial) ;
163- unary_func ! ( tgamma, af_tgamma) ;
164- unary_func ! ( lgamma, af_lgamma) ;
165- unary_func ! ( iszero, af_iszero) ;
166- unary_func ! ( isinf, af_isinf) ;
167- unary_func ! ( isnan, af_isnan) ;
130+ unary_func ! ( "Computes absolute value" , abs, af_abs) ;
131+ unary_func ! ( "Computes phase value" , arg, af_arg) ;
132+ unary_func ! ( "Computes the sign of input Array values" , sign, af_sign) ;
133+ unary_func ! ( "Round the values in an Array" , round, af_round) ;
134+ unary_func ! ( "Truncate the values in an Array" , trunc, af_trunc) ;
135+ unary_func ! ( "Floor the values in an Array" , floor, af_floor) ;
136+ unary_func ! ( "Ceil the values in an Array" , ceil, af_ceil) ;
137+ unary_func ! ( "Compute sin" , sin, af_sin) ;
138+ unary_func ! ( "Compute cos" , cos, af_cos) ;
139+ unary_func ! ( "Compute tan" , tan, af_tan) ;
140+ unary_func ! ( "Compute asin" , asin, af_asin) ;
141+ unary_func ! ( "Compute acos" , acos, af_acos) ;
142+ unary_func ! ( "Compute atan" , atan, af_atan) ;
143+ unary_func ! ( "Create a complex Array from real Array" , cplx, af_cplx) ;
144+ unary_func ! ( "Extract real values from a complex Array" , real, af_real) ;
145+ unary_func ! ( "Extract imaginary values from a complex Array" , imag, af_imag) ;
146+ unary_func ! ( "Compute the complex conjugate" , conjg, af_conjg) ;
147+ unary_func ! ( "Compute sinh" , sinh, af_sinh) ;
148+ unary_func ! ( "Compute cosh" , cosh, af_cosh) ;
149+ unary_func ! ( "Compute tanh" , tanh, af_tanh) ;
150+ unary_func ! ( "Compute asinh" , asinh, af_asinh) ;
151+ unary_func ! ( "Compute acosh" , acosh, af_acosh) ;
152+ unary_func ! ( "Compute atanh" , atanh, af_atanh) ;
153+ unary_func ! ( "Compute two raised to the power of value" , pow2, af_pow2) ;
154+ unary_func ! ( "Compute e raised to the power of value" , exp, af_exp) ;
155+ unary_func ! ( "Compute sigmoid function" , sigmoid, af_sigmoid) ;
156+ unary_func ! ( "Compute e raised to the power of value -1" , expm1, af_expm1) ;
157+ unary_func ! ( "Compute error function value" , erf, af_erf) ;
158+ unary_func ! ( "Compute the complementary error function value" , erfc, af_erfc) ;
159+ unary_func ! ( "Compute the natural logarithm" , log, af_log) ;
160+ unary_func ! ( "Compute the logarithm of input Array + 1" , log1p, af_log1p) ;
161+ unary_func ! ( "Compute logarithm base 10" , log10, af_log10) ;
162+ unary_func ! ( "Compute logarithm base 2" , log2, af_log2) ;
163+ unary_func ! ( "Compute the square root" , sqrt, af_sqrt) ;
164+ unary_func ! ( "Compute the cube root" , cbrt, af_cbrt) ;
165+ unary_func ! ( "Compute the factorial" , factorial, af_factorial) ;
166+ unary_func ! ( "Compute gamma function" , tgamma, af_tgamma) ;
167+ unary_func ! ( "Compute the logarithm of absolute values of gamma function" , lgamma, af_lgamma) ;
168+ unary_func ! ( "Check if values are zero" , iszero, af_iszero) ;
169+ unary_func ! ( "Check if values are infinity" , isinf, af_isinf) ;
170+ unary_func ! ( "Check if values are NaN" , isnan, af_isnan) ;
168171
169172macro_rules! binary_func {
170- ( $fn_name: ident, $ffi_fn: ident) => (
173+ ( $doc_str: expr, $fn_name: ident, $ffi_fn: ident) => (
174+ #[ doc=$doc_str]
175+ ///
176+ /// This is an element wise binary operation.
171177 #[ allow( unused_mut) ]
172178 pub fn $fn_name( lhs: & Array , rhs: & Array ) -> Array {
173179 unsafe {
@@ -182,15 +188,15 @@ macro_rules! binary_func {
182188 )
183189}
184190
185- binary_func ! ( bitand, af_bitand) ;
186- binary_func ! ( bitor, af_bitor) ;
187- binary_func ! ( bitxor, af_bitxor) ;
188- binary_func ! ( neq, af_neq) ;
189- binary_func ! ( and, af_and) ;
190- binary_func ! ( or, af_or) ;
191- binary_func ! ( minof, af_minof) ;
192- binary_func ! ( maxof, af_maxof) ;
193- binary_func ! ( hypot, af_hypot) ;
191+ binary_func ! ( "Elementwise AND(bit) operation of two Arrays" , bitand, af_bitand) ;
192+ binary_func ! ( "Elementwise OR(bit) operation of two Arrays" , bitor, af_bitor) ;
193+ binary_func ! ( "Elementwise XOR(bit) operation of two Arrays" , bitxor, af_bitxor) ;
194+ binary_func ! ( "Elementwise not equals comparison of two Arrays" , neq, af_neq) ;
195+ binary_func ! ( "Elementwise logical and operation of two Arrays" , and, af_and) ;
196+ binary_func ! ( "Elementwise logical or operation of two Arrays" , or, af_or) ;
197+ binary_func ! ( "Elementwise minimum operation of two Arrays" , minof, af_minof) ;
198+ binary_func ! ( "Elementwise maximum operation of two Arrays" , maxof, af_maxof) ;
199+ binary_func ! ( "Compute length of hypotenuse of two Arrays" , hypot, af_hypot) ;
194200
195201pub trait Convertable {
196202 fn convert ( & self ) -> Array ;
@@ -221,7 +227,7 @@ impl Convertable for Array {
221227}
222228
223229macro_rules! overloaded_binary_func {
224- ( $fn_name: ident, $help_name: ident, $ffi_name: ident) => (
230+ ( $doc_str : expr , $ fn_name: ident, $help_name: ident, $ffi_name: ident) => (
225231 fn $help_name( lhs: & Array , rhs: & Array , batch: bool ) -> Array {
226232 unsafe {
227233 let mut temp: i64 = 0 ;
@@ -233,6 +239,22 @@ macro_rules! overloaded_binary_func {
233239 }
234240 }
235241
242+ #[ doc=$doc_str]
243+ ///
244+ /// This is a binary elementwise operation.
245+ ///
246+ ///# Parameters
247+ ///
248+ /// - `arg1`is an argument that implements an internal trait `Convertable`.
249+ /// - `arg2`is an argument that implements an internal trait `Convertable`.
250+ /// - `batch` is an boolean that indicates if the current operation is an batch operation.
251+ ///
252+ /// Both parameters `arg1` and `arg2` can be either an Array or a value of rust integral
253+ /// type.
254+ ///
255+ ///# Return Values
256+ ///
257+ /// An Array with results of the binary operation.
236258 pub fn $fn_name<T , U > ( arg1: & T , arg2: & U , batch: bool ) -> Array where T : Convertable , U : Convertable {
237259 let lhs = arg1. convert( ) ;
238260 let rhs = arg2. convert( ) ;
@@ -253,23 +275,23 @@ macro_rules! overloaded_binary_func {
253275
254276// thanks to Umar Arshad for the idea on how to
255277// implement overloaded function
256- overloaded_binary_func ! ( add, add_helper, af_add) ;
257- overloaded_binary_func ! ( sub, sub_helper, af_sub) ;
258- overloaded_binary_func ! ( mul, mul_helper, af_mul) ;
259- overloaded_binary_func ! ( div, div_helper, af_div) ;
260- overloaded_binary_func ! ( rem, rem_helper, af_rem) ;
261- overloaded_binary_func ! ( shiftl, shiftl_helper, af_bitshiftl) ;
262- overloaded_binary_func ! ( shiftr, shiftr_helper, af_bitshiftr) ;
263- overloaded_binary_func ! ( lt, lt_helper, af_lt) ;
264- overloaded_binary_func ! ( gt, gt_helper, af_gt) ;
265- overloaded_binary_func ! ( le, le_helper, af_le) ;
266- overloaded_binary_func ! ( ge, ge_helper, af_ge) ;
267- overloaded_binary_func ! ( eq, eq_helper, af_eq) ;
268- overloaded_binary_func ! ( modulo, modulo_helper, af_mod) ;
269- overloaded_binary_func ! ( atan2, atan2_helper, af_atan2) ;
270- overloaded_binary_func ! ( cplx2, cplx2_helper, af_cplx2) ;
271- overloaded_binary_func ! ( root, root_helper, af_root) ;
272- overloaded_binary_func ! ( pow, pow_helper, af_pow) ;
278+ overloaded_binary_func ! ( "Addition of two Arrays" , add, add_helper, af_add) ;
279+ overloaded_binary_func ! ( "Subtraction of two Arrays" , sub, sub_helper, af_sub) ;
280+ overloaded_binary_func ! ( "Multiplication of two Arrays" , mul, mul_helper, af_mul) ;
281+ overloaded_binary_func ! ( "Division of two Arrays" , div, div_helper, af_div) ;
282+ overloaded_binary_func ! ( "Compute remainder from two Arrays" , rem, rem_helper, af_rem) ;
283+ overloaded_binary_func ! ( "Compute left shift" , shiftl, shiftl_helper, af_bitshiftl) ;
284+ overloaded_binary_func ! ( "Compute right shift" , shiftr, shiftr_helper, af_bitshiftr) ;
285+ overloaded_binary_func ! ( "Perform `less than` comparison operation" , lt, lt_helper, af_lt) ;
286+ overloaded_binary_func ! ( "Perform `greater than` comparison operation" , gt, gt_helper, af_gt) ;
287+ overloaded_binary_func ! ( "Perform `less than equals` comparison operation" , le, le_helper, af_le) ;
288+ overloaded_binary_func ! ( "Perform `greater than equals` comparison operation" , ge, ge_helper, af_ge) ;
289+ overloaded_binary_func ! ( "Perform `equals` comparison operation" , eq, eq_helper, af_eq) ;
290+ overloaded_binary_func ! ( "Compute modulo of two Arrays" , modulo, modulo_helper, af_mod) ;
291+ overloaded_binary_func ! ( "Calculate atan2 of two Arrays" , atan2, atan2_helper, af_atan2) ;
292+ overloaded_binary_func ! ( "Create complex array from two Arrays" , cplx2, cplx2_helper, af_cplx2) ;
293+ overloaded_binary_func ! ( "Compute root" , root, root_helper, af_root) ;
294+ overloaded_binary_func ! ( "Computer power" , pow, pow_helper, af_pow) ;
273295
274296macro_rules! arith_scalar_func {
275297 ( $rust_type: ty, $op_name: ident, $fn_name: ident, $ffi_fn: ident) => (
0 commit comments