All of the functions described in this section are element-wise. For example, this code–
Array<float,2> A, B; // A = sin(B);
results in A(i,j) = sin(B(i,j))
for all (i,j).
These math functions are available on all platforms:
abs()
acos()
arg()
atan2(Im,Re)
).
asin()
atan()
atan2()
in section
Math functions 2.
ceil()
cexp()
exp()
.
conj()
cos()
complex<T>
.
cosh()
complex<T>
.
csqrt()
sqrt()
.
exp()
complex<T>
.
fabs()
abs()
.
floor()
log()
complex<T>
.
log10()
complex<T>
.
pow2(), pow3(), pow4(), pow5(), pow6(), pow7(), pow8()
sin()
complex<T>
.
sinh()
complex<T>
.
sqr()
pow2()
. Computes x*x
. Works for complex<T>
.
sqrt()
complex<T>
.
tan()
complex<T>
.
tanh()
complex<T>
.
These functions are only available on platforms which provide the IEEE Math library (libm.a) and/or System V Math Library (libmsaa.a). Apparently not all platforms provide all of these functions, so what you can use on your platform may be a subset of these. If you choose to use one of these functions, be aware that you may be limiting the portability of your code.
On some platforms, the preprocessor symbols _XOPEN_SOURCE
and/or
_XOPEN_SOURCE_EXTENDED
need to be defined to use these functions.
These symbols can be enabled by compiling with
-DBZ_ENABLE_XOPEN_SOURCE
. (In previous version of Blitz++,
_XOPEN_SOURCE
and _XOPEN_SOURCE_EXTENDED
were declared by
default. This was found to cause too many problems, so users must manually
enable them with -DBZ_ENABLE_XOPEN_SOURCE
.).
In the current version, Blitz++ divides these functions into two groups: IEEE and System V. This distinction is probably artificial. If one of the functions in a group is missing, Blitz++ won't allow you to use any of them. You can see the division of these functions in the files Blitz++/compiler/ieeemath.cpp and Blitz++/compiler/sysvmath.cpp. This arrangement is unsatisfactory and will probably change in a future version.
You may have to link with -lm
and/or -lmsaa
to use these
functions.
None of these functions are available for complex<T>
.
acosh()
asinh()
atanh()
_class()
FP_PLUS_NORM
FP_MINUS_NORM
FP_PLUS_DENORM
FP_MINUS_DENORM
FP_PLUS_ZERO
FP_MINUS_ZERO
FP_PLUS_INF
FP_MINUS_INF
FP_NANS
FP_NANQ
cbrt()
expm1()
erf()
Note that for large values of the parameter, calculating can result in
extreme loss of accuracy. Instead, use erfc()
.
erfc()
finite()
ilogb()
blitz_isnan()
itrunc()
j0()
j1()
lgamma()
logb()
log1p()
nearest()
rint()
rint()
rounds up or down or to the nearest integer depends on the
current floating-point rounding mode. If you haven't altered the rounding
mode, rint()
should be equivalent to nearest()
. If rounding
mode is set to round towards +INF, rint()
is equivalent to
ceil()
. If the mode is round toward -INF, rint()
is
equivalent to floor()
. If the mode is round toward zero,
rint()
is equivalent to trunc()
.
rsqrt()
uitrunc()
y0()
y1()
There may be better descriptions of these functions in your system man pages.