arith.h Source File

- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

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
af_log2
AFAPI af_err af_log2(af_array *out, const af_array in)
C Interface for logarithm base 2.
af_bitshiftl
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.
af_isnan
AFAPI af_err af_isnan(af_array *out, const af_array in)
C Interface for checking if values are NaNs.
af::tgamma
AFAPI array tgamma(const array &in)
C++ Interface for gamma function of input.
af::round
AFAPI array round(const array &in)
C++ Interface for rounding an array of numbers.
af::pow2
AFAPI array pow2(const array &in)
C++ Interface for power of 2.
af_mod
AFAPI af_err af_mod(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for modulus.
af_cplx2
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.
af_bitshiftr
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.
af
Definition: algorithm.h:14
af_bitand
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.
af::arg
AFAPI array arg(const array &in)
C++ Interface for arg.
af::conjg
AFAPI array conjg(const array &in)
C++ Interface for getting the complex conjugate of input array.
af_log10
AFAPI af_err af_log10(af_array *out, const af_array in)
C Interface for logarithm base 10.
af_floor
AFAPI af_err af_floor(af_array *out, const af_array in)
C Interface for flooring an array of numbers.
af::log1p
AFAPI array log1p(const array &in)
C++ Interface for natural logarithm of 1 + input.
af_rem
AFAPI af_err af_rem(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for remainder.
af::mod
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.
af::complex
AFAPI array complex(const array &lhs, const array &rhs)
C++ Interface for creating complex array from two inputs.
af_ceil
AFAPI af_err af_ceil(af_array *out, const af_array in)
C Interface for ceiling an array of numbers.
af::root
AFAPI array root(const array &lhs, const array &rhs)
C++ Interface for nth root.
af_sqrt
AFAPI af_err af_sqrt(af_array *out, const af_array in)
C Interface for square root.
af_imag
AFAPI af_err af_imag(af_array *out, const af_array in)
C Interface for getting imaginary part from complex array.
af_add
AFAPI af_err af_add(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for adding arrays.
af::erfc
AFAPI array erfc(const array &in)
C++ Interface for complementary error function value.
af_and
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.
af_pow
AFAPI af_err af_pow(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for power.
af::acos
AFAPI array acos(const array &in)
C++ Interface for arc cos (cos inverse)
af_asinh
AFAPI af_err af_asinh(af_array *out, const af_array in)
C Interface for asinh.
af_expm1
AFAPI af_err af_expm1(af_array *out, const af_array in)
C Interface for exponential of an array minus 1.
af::erf
AFAPI array erf(const array &in)
C++ Interface for error function value.
af_le
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.
af_sigmoid
AFAPI af_err af_sigmoid(af_array *out, const af_array in)
C Interface for calculating sigmoid function of an array.
af_mul
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.
af::log10
AFAPI array log10(const array &in)
C++ Interface for logarithm base 10.
af_bitxor
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.
af_sin
AFAPI af_err af_sin(af_array *out, const af_array in)
C Interface for sin.
af_trunc
AFAPI af_err af_trunc(af_array *out, const af_array in)
C Interface for truncating an array of numbers.
af_sub
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.
af::trunc
AFAPI array trunc(const array &in)
C++ Interface for truncating an array of numbers.
af::log2
AFAPI array log2(const array &in)
C++ Interface for logarithm base 2.
af_arg
AFAPI af_err af_arg(af_array *out, const af_array in)
C Interface for finding the phase.
af_round
AFAPI af_err af_round(af_array *out, const af_array in)
C Interface for rounding an array of numbers.
af::asin
AFAPI array asin(const array &in)
C++ Interface for arc sin (sin inverse)
af_sinh
AFAPI af_err af_sinh(af_array *out, const af_array in)
C Interface for sinh.
af_exp
AFAPI af_err af_exp(af_array *out, const af_array in)
C Interface for exponential of an array.
af_erfc
AFAPI af_err af_erfc(af_array *out, const af_array in)
C Interface for complementary error function value.
af_log
AFAPI af_err af_log(af_array *out, const af_array in)
C Interface for natural logarithm.
af_atan2
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.
af::hypot
AFAPI array hypot(const array &lhs, const array &rhs)
C++ Interface for getting length of hypotenuse of two inputs.
af_cplx
AFAPI af_err af_cplx(af_array *out, const af_array in)
C Interface for creating complex array from real array.
af::lgamma
AFAPI array lgamma(const array &in)
C++ Interface for logarithm of absolute value of gamma function of input.
af_isinf
AFAPI af_err af_isinf(af_array *out, const af_array in)
C Interface for checking if values are infinities.
af_lt
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.
af_hypot
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.
afcl::array
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:337
af_acosh
AFAPI af_err af_acosh(af_array *out, const af_array in)
C Interface for acosh.
af::floor
AFAPI array floor(const array &in)
C++ Interface for flooring an array of numbers.
af_div
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.
af::log
AFAPI array log(const array &in)
C++ Interface for natural logarithm.
af::expm1
AFAPI array expm1(const array &in)
C++ Interface for exponential of an array minus 1.
af::tan
AFAPI array tan(const array &in)
C++ Interface for tan.
af_err
af_err
Definition: defines.h:67
af_ge
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.
af_sign
AFAPI af_err af_sign(af_array *out, const af_array in)
C Interface for finding the sign of the input.
af_atan
AFAPI af_err af_atan(af_array *out, const af_array in)
C Interface for arc tan.
defines.h
af_eq
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.
af_real
AFAPI af_err af_real(af_array *out, const af_array in)
C Interface for getting real part from complex array.
af_root
AFAPI af_err af_root(af_array *out, const af_array lhs, const af_array rhs, const bool batch)
C Interface for root.
af_factorial
AFAPI af_err af_factorial(af_array *out, const af_array in)
C Interface for the factorial.
af_neq
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.
af_cosh
AFAPI af_err af_cosh(af_array *out, const af_array in)
C Interface for cosh.
af::atan2
AFAPI array atan2(const array &lhs, const array &rhs)
C++ Interface for arc tan of two arrays.
af::cbrt
AFAPI array cbrt(const array &in)
C++ Interface for cube root of input.
af_atanh
AFAPI af_err af_atanh(af_array *out, const af_array in)
C Interface for atanh.
af::atan
AFAPI array atan(const array &in)
C++ Interface for arc tan (tan inverse)
af::max
AFAPI array max(const array &in, const int dim=-1)
C++ Interface for maximum values in an array.
af_log1p
AFAPI af_err af_log1p(af_array *out, const af_array in)
C Interface for logarithm of (in + 1)
af::imag
AFAPI array imag(const array &in)
C++ Interface for getting imaginary part from complex array.
af_lgamma
AFAPI af_err af_lgamma(af_array *out, const af_array in)
C Interface for the logarithm of absolute values of gamma function.
af_erf
AFAPI af_err af_erf(af_array *out, const af_array in)
C Interface for error function value.
af_asin
AFAPI af_err af_asin(af_array *out, const af_array in)
C Interface for arc sin.
af::real
AFAPI array real(const array &in)
C++ Interface for getting real part from complex array.
af_pow2
AFAPI af_err af_pow2(af_array *out, const af_array in)
C Interface for power of two.
af_iszero
AFAPI af_err af_iszero(af_array *out, const af_array in)
C Interface for checking if values are zero.
af_gt
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.
AFAPI
#define AFAPI
Definition: defines.h:31
af::rem
AFAPI array rem(const array &lhs, const array &rhs)
C++ Interface for remainder when array divides array, scalar divides array or array divides scalar...
af::isNaN
AFAPI array isNaN(const array &in)
C++ Interface for checking if values are NaNs.
af::isInf
AFAPI array isInf(const array &in)
C++ Interface for checking if values are Infinities.
af::cos
AFAPI array cos(const array &in)
C++ Interface for cos.
af::abs
AFAPI array abs(const array &in)
C++ Interface for absolute value.
af::sign
AFAPI array sign(const array &in)
C++ Interface for getting the sign of input.
af::sinh
AFAPI array sinh(const array &in)
C++ Interface for sinh.
af_tan
AFAPI af_err af_tan(af_array *out, const af_array in)
C Interface for tan.
af::asinh
AFAPI array asinh(const array &in)
C++ Interface for sinh inverse.
af::exp
AFAPI array exp(const array &in)
C++ Interface for exponential of an array.
af::factorial
AFAPI array factorial(const array &in)
C++ Interface for factorial of input.
af::cosh
AFAPI array cosh(const array &in)
C++ Interface for cosh.
af_acos
AFAPI af_err af_acos(af_array *out, const af_array in)
C Interface for arc cos.
af_minof
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.
af_conjg
AFAPI af_err af_conjg(af_array *out, const af_array in)
C Interface for getting the complex conjugate of input array.
af::sqrt
AFAPI array sqrt(const array &in)
C++ Interface for square root of input.
af_bitor
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.
af_tgamma
AFAPI af_err af_tgamma(af_array *out, const af_array in)
C Interface for the gamma function.
af_cbrt
AFAPI af_err af_cbrt(af_array *out, const af_array in)
C Interface for cube root.
af_array
void * af_array
Definition: defines.h:226
af_maxof
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.
af_cos
AFAPI af_err af_cos(af_array *out, const af_array in)
C Interface for cos.
af::min
AFAPI array min(const array &in, const int dim=-1)
C++ Interface for minimum values in an array.
af::acosh
AFAPI array acosh(const array &in)
C++ Interface for cosh inverse.
af::atanh
AFAPI array atanh(const array &in)
C++ Interface for tanh inverse.
af_cast
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.
af::tanh
AFAPI array tanh(const array &in)
C++ Interface for tanh.
af_tanh
AFAPI af_err af_tanh(af_array *out, const af_array in)
C Interface for tanh.
af::sigmoid
AFAPI array sigmoid(const array &in)
C++ Interface for calculating sigmoid function of an array.
af_abs
AFAPI af_err af_abs(af_array *out, const af_array in)
C Interface for absolute value.
af_not
AFAPI af_err af_not(af_array *out, const af_array in)
C Interface for performing logical not on input.
af_dtype
af_dtype
Definition: defines.h:199
af::ceil
AFAPI array ceil(const array &in)
C++ Interface for ceiling an array of numbers.
af::pow
AFAPI array pow(const array &lhs, const array &rhs)
C++ Interface for power.
af::sin
AFAPI array sin(const array &in)
C++ Interface for sin.
af::iszero
AFAPI array iszero(const array &in)
C++ Interface for checking if values are zero.
af_or
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.