arith.h
Go to the documentation of this file.
1 /*******************************************************
2  * Copyright (c) 2014, ArrayFire
3  * All rights reserved.
4  *
5  * This file is distributed under 3-clause BSD license.
6  * The complete license agreement can be obtained at:
7  * http://arrayfire.com/licenses/BSD-3-Clause
8  ********************************************************/
9 
10 #include <af/defines.h>
11 
12 #ifdef __cplusplus
13 namespace af
14 {
15  class array;
16 
25  AFAPI array min (const array &lhs, const array &rhs);
26 
28  AFAPI array min (const array &lhs, const double rhs);
29 
31  AFAPI array min (const double lhs, const array &rhs);
33 
41  AFAPI array max (const array &lhs, const array &rhs);
42 
44  AFAPI array max (const array &lhs, const double rhs);
45 
47  AFAPI array max (const double lhs, const array &rhs);
49 
58  AFAPI array rem (const array &lhs, const array &rhs);
59 
61  AFAPI array rem (const array &lhs, const double rhs);
62 
64  AFAPI array rem (const double lhs, const array &rhs);
66 
75  AFAPI array mod (const array &lhs, const array &rhs);
76 
78  AFAPI array mod (const array &lhs, const double rhs);
79 
81  AFAPI array mod (const double lhs, const array &rhs);
83 
90  AFAPI array abs (const array &in);
91 
100  AFAPI array arg (const array &in);
101 
112  AFAPI array sign (const array &in);
113 
122  AFAPI array round (const array &in);
123 
132  AFAPI array trunc (const array &in);
133 
134 
141  AFAPI array floor (const array &in);
142 
149  AFAPI array ceil (const array &in);
150 
161  AFAPI array hypot (const array &lhs, const array &rhs);
162 
164  AFAPI array hypot (const array &lhs, const double rhs);
165 
167  AFAPI array hypot (const double lhs, const array &rhs);
169 
176  AFAPI array sin (const array &in);
177 
184  AFAPI array cos (const array &in);
185 
192  AFAPI array tan (const array &in);
193 
200  AFAPI array asin (const array &in);
201 
208  AFAPI array acos (const array &in);
209 
216  AFAPI array atan (const array &in);
217 
225  AFAPI array atan2 (const array &lhs, const array &rhs);
226 
228  AFAPI array atan2 (const array &lhs, const double rhs);
229 
231  AFAPI array atan2 (const double lhs, const array &rhs);
233 
247  AFAPI array complex(const array &lhs, const array &rhs);
248 
251  AFAPI array complex(const array &lhs, const double rhs);
252 
255  AFAPI array complex(const double lhs, const array &rhs);
256 
263  AFAPI array complex(const array &in);
265 
272  AFAPI array real (const array &in);
273 
280  AFAPI array imag (const array &in);
281 
288  AFAPI array conjg (const array &in);
289 
296  AFAPI array sinh (const array &in);
297 
304  AFAPI array cosh (const array &in);
305 
312  AFAPI array tanh (const array &in);
313 
320  AFAPI array asinh (const array &in);
321 
328  AFAPI array acosh (const array &in);
329 
336  AFAPI array atanh (const array &in);
337 
345  AFAPI array root (const array &lhs, const array &rhs);
346 
354  AFAPI array root (const array &lhs, const double rhs);
355 
363  AFAPI array root (const double lhs, const array &rhs);
364 
365 
376  AFAPI array pow (const array &lhs, const array &rhs);
377 
379  AFAPI array pow (const array &lhs, const double rhs);
380 
382  AFAPI array pow (const double lhs, const array &rhs);
383 
389  AFAPI array pow2 (const array &in);
391 
392 #if AF_API_VERSION >= 31
393  AFAPI array sigmoid (const array &in);
400 #endif
401 
408  AFAPI array exp (const array &in);
409 
417  AFAPI array expm1 (const array &in);
418 
425  AFAPI array erf (const array &in);
426 
433  AFAPI array erfc (const array &in);
434 
441  AFAPI array log (const array &in);
442 
450  AFAPI array log1p (const array &in);
451 
458  AFAPI array log10 (const array &in);
459 
466  AFAPI array log2 (const array &in);
467 
474  AFAPI array sqrt (const array &in);
475 
482  AFAPI array cbrt (const array &in);
483 
491  AFAPI array factorial (const array &in);
492 
499  AFAPI array tgamma (const array &in);
500 
507  AFAPI array lgamma (const array &in);
508 
515  AFAPI array iszero (const array &in);
516 
523  AFAPI array isInf (const array &in);
524 
531  AFAPI array isNaN (const array &in);
532 }
533 #endif
534 
535 #ifdef __cplusplus
536 extern "C" {
537 #endif
538 
550  AFAPI af_err af_add (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
551 
563  AFAPI af_err af_sub (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
564 
576  AFAPI af_err af_mul (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
577 
589  AFAPI af_err af_div (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
590 
602  AFAPI af_err af_lt (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
603 
615  AFAPI af_err af_gt (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
616 
628  AFAPI af_err af_le (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
629 
641  AFAPI af_err af_ge (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
642 
654  AFAPI af_err af_eq (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
655 
667  AFAPI af_err af_neq (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
668 
680  AFAPI af_err af_and (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
681 
693  AFAPI af_err af_or (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
694 
704  AFAPI af_err af_not (af_array *out, const af_array in);
705 
717  AFAPI af_err af_bitand (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
718 
730  AFAPI af_err af_bitor (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
731 
743  AFAPI af_err af_bitxor (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
744 
756  AFAPI af_err af_bitshiftl(af_array *out, const af_array lhs, const af_array rhs, const bool batch);
757 
769  AFAPI af_err af_bitshiftr(af_array *out, const af_array lhs, const af_array rhs, const bool batch);
770 
781  AFAPI af_err af_cast (af_array *out, const af_array in, const af_dtype type);
782 
794  AFAPI af_err af_minof (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
795 
807  AFAPI af_err af_maxof (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
808 
820  AFAPI af_err af_rem (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
821 
833  AFAPI af_err af_mod (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
834 
844  AFAPI af_err af_abs (af_array *out, const af_array in);
845 
855  AFAPI af_err af_arg (af_array *out, const af_array in);
856 
868  AFAPI af_err af_sign (af_array *out, const af_array in);
869 
881  AFAPI af_err af_round (af_array *out, const af_array in);
882 
892  AFAPI af_err af_trunc (af_array *out, const af_array in);
893 
903  AFAPI af_err af_floor (af_array *out, const af_array in);
904 
914  AFAPI af_err af_ceil (af_array *out, const af_array in);
915 
927  AFAPI af_err af_hypot (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
928 
938  AFAPI af_err af_sin (af_array *out, const af_array in);
939 
949  AFAPI af_err af_cos (af_array *out, const af_array in);
950 
960  AFAPI af_err af_tan (af_array *out, const af_array in);
961 
971  AFAPI af_err af_asin (af_array *out, const af_array in);
972 
982  AFAPI af_err af_acos (af_array *out, const af_array in);
983 
993  AFAPI af_err af_atan (af_array *out, const af_array in);
994 
1006  AFAPI af_err af_atan2 (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
1007 
1019  AFAPI af_err af_cplx2 (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
1020 
1030  AFAPI af_err af_cplx (af_array *out, const af_array in);
1031 
1041  AFAPI af_err af_real (af_array *out, const af_array in);
1042 
1052  AFAPI af_err af_imag (af_array *out, const af_array in);
1053 
1063  AFAPI af_err af_conjg (af_array *out, const af_array in);
1064 
1074  AFAPI af_err af_sinh (af_array *out, const af_array in);
1075 
1085  AFAPI af_err af_cosh (af_array *out, const af_array in);
1086 
1096  AFAPI af_err af_tanh (af_array *out, const af_array in);
1097 
1107  AFAPI af_err af_asinh (af_array *out, const af_array in);
1108 
1118  AFAPI af_err af_acosh (af_array *out, const af_array in);
1119 
1129  AFAPI af_err af_atanh (af_array *out, const af_array in);
1130 
1142  AFAPI af_err af_root (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
1143 
1144 
1156  AFAPI af_err af_pow (af_array *out, const af_array lhs, const af_array rhs, const bool batch);
1157 
1167  AFAPI af_err af_pow2 (af_array *out, const af_array in);
1168 
1178  AFAPI af_err af_exp (af_array *out, const af_array in);
1179 
1180 #if AF_API_VERSION >= 31
1181 
1190  AFAPI af_err af_sigmoid (af_array *out, const af_array in);
1191 #endif
1192 
1202  AFAPI af_err af_expm1 (af_array *out, const af_array in);
1203 
1213  AFAPI af_err af_erf (af_array *out, const af_array in);
1214 
1224  AFAPI af_err af_erfc (af_array *out, const af_array in);
1225 
1235  AFAPI af_err af_log (af_array *out, const af_array in);
1236 
1246  AFAPI af_err af_log1p (af_array *out, const af_array in);
1247 
1257  AFAPI af_err af_log10 (af_array *out, const af_array in);
1258 
1268  AFAPI af_err af_log2 (af_array *out, const af_array in);
1269 
1279  AFAPI af_err af_sqrt (af_array *out, const af_array in);
1280 
1290  AFAPI af_err af_cbrt (af_array *out, const af_array in);
1291 
1301  AFAPI af_err af_factorial (af_array *out, const af_array in);
1302 
1312  AFAPI af_err af_tgamma (af_array *out, const af_array in);
1313 
1323  AFAPI af_err af_lgamma (af_array *out, const af_array in);
1324 
1334  AFAPI af_err af_iszero (af_array *out, const af_array in);
1335 
1345  AFAPI af_err af_isinf (af_array *out, const af_array in);
1346 
1356  AFAPI af_err af_isnan (af_array *out, const af_array in);
1357 
1358 #ifdef __cplusplus
1359 }
1360 #endif
AFAPI af_err af_log2(af_array *out, const af_array in)
C Interface for logarithm base 2.
AFAPI af_err af_bitshiftl(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for left shift on integer arrays.
AFAPI af_err af_isnan(af_array *out, const af_array in)
C Interface for checking if values are NaNs.
AFAPI array tgamma(const array &in)
C++ Interface for gamma function of input.
AFAPI array round(const array &in)
C++ Interface for rounding an array of numbers.
AFAPI array pow2(const array &in)
C++ Interface for power of 2.
AFAPI af_err af_mod(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for modulus.
AFAPI af_err af_cplx2(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for creating complex array from two input arrays.
AFAPI af_err af_bitshiftr(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for right shift on integer arrays.
Definition: algorithm.h:14
AFAPI af_err af_bitand(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for performing bitwise and on two arrays.
AFAPI array arg(const array &in)
C++ Interface for arg.
AFAPI array conjg(const array &in)
C++ Interface for getting the complex conjugate of input array.
AFAPI af_err af_log10(af_array *out, const af_array in)
C Interface for logarithm base 10.
AFAPI af_err af_floor(af_array *out, const af_array in)
C Interface for flooring an array of numbers.
AFAPI array log1p(const array &in)
C++ Interface for natural logarithm of 1 + input.
AFAPI af_err af_rem(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for remainder.
AFAPI array mod(const array &lhs, const array &rhs)
C++ Interface for modulus when dividend and divisor are arrays or one of them is scalar.
AFAPI array complex(const array &lhs, const array &rhs)
C++ Interface for creating complex array from two inputs.
AFAPI af_err af_ceil(af_array *out, const af_array in)
C Interface for ceiling an array of numbers.
AFAPI array root(const array &lhs, const array &rhs)
C++ Interface for nth root.
AFAPI af_err af_sqrt(af_array *out, const af_array in)
C Interface for square root.
AFAPI af_err af_imag(af_array *out, const af_array in)
C Interface for getting imaginary part from complex array.
AFAPI af_err af_add(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for adding arrays.
AFAPI array erfc(const array &in)
C++ Interface for complementary error function value.
AFAPI af_err af_and(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for performing logical and on two arrays.
AFAPI af_err af_pow(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for power.
AFAPI array acos(const array &in)
C++ Interface for arc cos (cos inverse)
AFAPI af_err af_asinh(af_array *out, const af_array in)
C Interface for asinh.
AFAPI af_err af_expm1(af_array *out, const af_array in)
C Interface for exponential of an array minus 1.
AFAPI array erf(const array &in)
C++ Interface for error function value.
AFAPI af_err af_le(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is less or equal to another.
AFAPI af_err af_sigmoid(af_array *out, const af_array in)
C Interface for calculating sigmoid function of an array.
AFAPI af_err af_mul(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for multiplying two arrays.
AFAPI array log10(const array &in)
C++ Interface for logarithm base 10.
AFAPI af_err af_bitxor(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for performing bitwise xor on two arrays.
AFAPI af_err af_sin(af_array *out, const af_array in)
C Interface for sin.
AFAPI af_err af_trunc(af_array *out, const af_array in)
C Interface for truncating an array of numbers.
AFAPI af_err af_sub(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for subtracting an array from another.
AFAPI array trunc(const array &in)
C++ Interface for truncating an array of numbers.
AFAPI array log2(const array &in)
C++ Interface for logarithm base 2.
AFAPI af_err af_arg(af_array *out, const af_array in)
C Interface for finding the phase.
AFAPI af_err af_round(af_array *out, const af_array in)
C Interface for rounding an array of numbers.
AFAPI array asin(const array &in)
C++ Interface for arc sin (sin inverse)
AFAPI af_err af_sinh(af_array *out, const af_array in)
C Interface for sinh.
AFAPI af_err af_exp(af_array *out, const af_array in)
C Interface for exponential of an array.
AFAPI af_err af_erfc(af_array *out, const af_array in)
C Interface for complementary error function value.
AFAPI af_err af_log(af_array *out, const af_array in)
C Interface for natural logarithm.
AFAPI af_err af_atan2(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for arc tan of two inputs.
AFAPI array hypot(const array &lhs, const array &rhs)
C++ Interface for getting length of hypotenuse of two inputs.
AFAPI af_err af_cplx(af_array *out, const af_array in)
C Interface for creating complex array from real array.
AFAPI array lgamma(const array &in)
C++ Interface for logarithm of absolute value of gamma function of input.
AFAPI af_err af_isinf(af_array *out, const af_array in)
C Interface for checking if values are infinities.
AFAPI af_err af_lt(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is less than another.
AFAPI af_err af_hypot(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for getting length of hypotenuse of two arrays.
static af::array array(af::dim4 idims, cl_mem buf, af::dtype type, bool retain=false)
Create an af::array object from an OpenCL cl_mem buffer.
Definition: opencl.h:329
AFAPI af_err af_acosh(af_array *out, const af_array in)
C Interface for acosh.
AFAPI array floor(const array &in)
C++ Interface for flooring an array of numbers.
AFAPI af_err af_div(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for dividing an array by another.
AFAPI array log(const array &in)
C++ Interface for natural logarithm.
AFAPI array expm1(const array &in)
C++ Interface for exponential of an array minus 1.
AFAPI array tan(const array &in)
C++ Interface for tan.
af_err
Definition: defines.h:63
AFAPI af_err af_ge(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is greater or equal to another.
AFAPI af_err af_sign(af_array *out, const af_array in)
C Interface for finding the sign of the input.
AFAPI af_err af_atan(af_array *out, const af_array in)
C Interface for arc tan.
AFAPI af_err af_eq(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is equal to another.
AFAPI af_err af_real(af_array *out, const af_array in)
C Interface for getting real part from complex array.
AFAPI af_err af_root(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for root.
AFAPI af_err af_factorial(af_array *out, const af_array in)
C Interface for the factorial.
AFAPI af_err af_neq(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is not equal to another.
AFAPI af_err af_cosh(af_array *out, const af_array in)
C Interface for cosh.
AFAPI array atan2(const array &lhs, const array &rhs)
C++ Interface for arc tan of two arrays.
AFAPI array cbrt(const array &in)
C++ Interface for cube root of input.
AFAPI af_err af_atanh(af_array *out, const af_array in)
C Interface for atanh.
AFAPI array atan(const array &in)
C++ Interface for arc tan (tan inverse)
AFAPI array max(const array &in, const int dim=-1)
C++ Interface for maximum values in an array.
AFAPI af_err af_log1p(af_array *out, const af_array in)
C Interface for logarithm of (in + 1)
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
AFAPI af_err af_lgamma(af_array *out, const af_array in)
C Interface for the logarithm of absolute values of gamma function.
AFAPI af_err af_erf(af_array *out, const af_array in)
C Interface for error function value.
AFAPI af_err af_asin(af_array *out, const af_array in)
C Interface for arc sin.
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
AFAPI af_err af_pow2(af_array *out, const af_array in)
C Interface for power of two.
AFAPI af_err af_iszero(af_array *out, const af_array in)
C Interface for checking if values are zero.
AFAPI af_err af_gt(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for checking if an array is greater than another.
#define AFAPI
Definition: defines.h:31
AFAPI array rem(const array &lhs, const array &rhs)
C++ Interface for remainder when array divides array, scalar divides array or array divides scalar...
AFAPI array isNaN(const array &in)
C++ Interface for checking if values are NaNs.
AFAPI array isInf(const array &in)
C++ Interface for checking if values are Infinities.
AFAPI array cos(const array &in)
C++ Interface for cos.
AFAPI array abs(const array &in)
C++ Interface for absolute value.
AFAPI array sign(const array &in)
C++ Interface for getting the sign of input.
AFAPI array sinh(const array &in)
C++ Interface for sinh.
AFAPI af_err af_tan(af_array *out, const af_array in)
C Interface for tan.
AFAPI array asinh(const array &in)
C++ Interface for sinh inverse.
AFAPI array exp(const array &in)
C++ Interface for exponential of an array.
AFAPI array factorial(const array &in)
C++ Interface for factorial of input.
AFAPI array cosh(const array &in)
C++ Interface for cosh.
AFAPI af_err af_acos(af_array *out, const af_array in)
C Interface for arc cos.
AFAPI af_err af_minof(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for min of two arrays.
AFAPI af_err af_conjg(af_array *out, const af_array in)
C Interface for getting the complex conjugate of input array.
AFAPI array sqrt(const array &in)
C++ Interface for square root of input.
AFAPI af_err af_bitor(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for performing bitwise or on two arrays.
AFAPI af_err af_tgamma(af_array *out, const af_array in)
C Interface for the gamma function.
AFAPI af_err af_cbrt(af_array *out, const af_array in)
C Interface for cube root.
void * af_array
Definition: defines.h:222
AFAPI af_err af_maxof(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for max of two arrays.
AFAPI af_err af_cos(af_array *out, const af_array in)
C Interface for cos.
AFAPI array min(const array &in, const int dim=-1)
C++ Interface for minimum values in an array.
AFAPI array acosh(const array &in)
C++ Interface for cosh inverse.
AFAPI array atanh(const array &in)
C++ Interface for tanh inverse.
AFAPI af_err af_cast(af_array *out, const af_array in, const af_dtype type)
C Interface for casting an array from one type to another.
AFAPI array tanh(const array &in)
C++ Interface for tanh.
AFAPI af_err af_tanh(af_array *out, const af_array in)
C Interface for tanh.
AFAPI array sigmoid(const array &in)
C++ Interface for calculating sigmoid function of an array.
AFAPI af_err af_abs(af_array *out, const af_array in)
C Interface for absolute value.
AFAPI af_err af_not(af_array *out, const af_array in)
C Interface for performing logical not on input.
af_dtype
Definition: defines.h:195
AFAPI array ceil(const array &in)
C++ Interface for ceiling an array of numbers.
AFAPI array pow(const array &lhs, const array &rhs)
C++ Interface for power.
AFAPI array sin(const array &in)
C++ Interface for sin.
AFAPI array iszero(const array &in)
C++ Interface for checking if values are zero.
AFAPI af_err af_or(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for performing logical or on two arrays.