|
TBCI Numerical high perf. C++ Library 2.8.0
|
The TBCI Numerical Library is put into TBCI namespace, if the compiler supports it (egcs-1.1.x and later for example). More...
Classes | |
| class | vec_fill_fn |
Typedefs | |
| typedef enum _vararg | vararg |
Enumerations | |
| enum | _vararg { vag0 =0 , vag1 , vag2 , vag3 , vag4 , vag5 , vag6 , vag7 , vag8 , vag9 , vag10 , vag11 , vag12 , vag13 , vag14 , vag15 , vag16 , vag_max = 4294967295U } |
| This is a helper type to identify and count varargs. More... | |
Functions | |
| template<typename T> | |
| void | SWAP (T &a, T &b) |
| SWAP function Note: We could implement a swap function without temporaries: a -= b b += a a -= b a = -a That's four arithmetic operations to save one temporary and it can be only done for integers. | |
| template<typename T> | |
| void | _tbci_copy (const unsigned long sz, T *const res, const T *const v1) |
| template<typename T> | |
| void | _par_copy (const unsigned long sz, T *v1, const T *v2) |
| template<typename T> | |
| void | _tbci_fill (const unsigned long sz, T *const res, register typename tbci_traits< T >::loop_const_refval_typef2) |
| template<typename T> | |
| void | _par_fill (const unsigned long, T *const, typename tbci_traits< T >::loop_const_refval_type) |
| template<typename T> | |
| void | _tbci_fill_fn (const unsigned long sz, T *vec, vec_fill_fn< T > fn, void *par) |
| template<typename T> | |
| void | do_vv_comp (const unsigned long sz, const T *const v1, const T *const v2, volatile long &_f2) |
| f2 = number of differences vec, vec | |
| template<typename T> | |
| int | _par_comp (const unsigned long sz, const T *v1, const T *v2) |
| template<typename T> | |
| unsigned long | _bin_search (const T *vec, T el, unsigned long start, unsigned long end) |
| Search for an element el in a sorted vector between start and end-1, returns (unsigned long)-1 if element is not found. | |
| template<typename T> | |
| unsigned long | bin_search (const T *vec, T el, unsigned long start, unsigned long end) |
| Search for an element el in a sorted vector between start and end-1, returns (unsigned long)-1 if element is not found. | |
| template<typename T> | |
| int | sign (const T &x) |
| Signum. | |
| double | fabssqr (const double a) |
| double | fabssqr (const float a) |
| double | fabssqr (const int a) |
| double | fabssqr (const unsigned a) |
| template<typename T> | |
| T | sqr (const T &a) |
| template<typename T> | |
| T | dot (const T &a1, const T &a2) |
The TBCI Numerical Library is put into TBCI namespace, if the compiler supports it (egcs-1.1.x and later for example).
| typedef enum _vararg TBCI::vararg |
| enum TBCI::_vararg |
| unsigned long TBCI::_bin_search | ( | const T * | vec, |
| T | el, | ||
| unsigned long | start, | ||
| unsigned long | end ) |
Search for an element el in a sorted vector between start and end-1, returns (unsigned long)-1 if element is not found.
Bound checking (el in range) needs to be done before calling this, also need to make sure that the last element does not match.
Definition at line 994 of file basics.h.
References _bin_search(), end, and T.
Referenced by _bin_search(), and bin_search().
References _par_comp(), and T.
Referenced by _par_comp().
References _par_copy(), and T.
Referenced by _par_copy().
| void TBCI::_par_fill | ( | const unsigned long | , |
| T * const | , | ||
| typename tbci_traits< T >::loop_const_refval_type | ) |
References _par_fill(), and T.
Referenced by _par_fill().
|
inline |
Definition at line 891 of file basics.h.
References _tbci_copy(), and COPY2.
Referenced by _tbci_copy().
| void TBCI::_tbci_fill | ( | const unsigned long | sz, |
| T *const | res, | ||
| register typename tbci_traits< T >::loop_const_refval_typef2 | ) |
Definition at line 908 of file basics.h.
References _tbci_fill(), and FILL1.
Referenced by _tbci_fill().
| void TBCI::_tbci_fill_fn | ( | const unsigned long | sz, |
| T * | vec, | ||
| vec_fill_fn< T > | fn, | ||
| void * | par ) |
Definition at line 930 of file basics.h.
References _tbci_fill_fn(), TBCI::vec_fill_fn< T >::fn, i, REGISTER, and T.
Referenced by _tbci_fill_fn().
| unsigned long TBCI::bin_search | ( | const T * | vec, |
| T | el, | ||
| unsigned long | start, | ||
| unsigned long | end ) |
Search for an element el in a sorted vector between start and end-1, returns (unsigned long)-1 if element is not found.
Does all the necessary sanity checking.
Definition at line 1013 of file basics.h.
References _bin_search(), BCHK, bin_search(), end, and T.
Referenced by bin_search().
| void TBCI::do_vv_comp | ( | const unsigned long | sz, |
| const T *const | v1, | ||
| const T *const | v2, | ||
| volatile long & | _f2 ) |
f2 = number of differences vec, vec
Definition at line 977 of file basics.h.
References COMP2, and do_vv_comp().
Referenced by do_vv_comp().
|
inline |
Speaking of abs(), fabs() and fabssqr() : abs (T) returns type T, fabs() returns double and fabssqr() also a double (the sqr of fabs)
We want to be able to write templated code that can accept both std:: and TBCI:: types. Now, if such a routine uses functions like fabs() or abs(), we are in trouble: What namespace should the template author use for those? std:: or TBCI:: ?
Options are: (1) importing the pre-existing functions from std:: into TBCI:: (2) export the TBCI::functions to namespace std::
The answer may be different for each of those three types, as fabssqr() does not exist at all in std::, fabs() does exist, but only for doubles and abs() does exist for a number of builtin types as well as (std::complex)
In any case, the functions need to be completed, as no fabs() exists for non-double types, e.g. Additional complication is added by the fact that the whole thing should still work if compiled with NO_NS.
Solution (2) is the prefered one, as it does make users less dependent on TBCI. Unfortunately, this means that we may break backwards compatibility (on source level).
Note that the self-invented functions conj(), real(), imag() and fabssqr() remain in namespace TBCI. The same holds for sqr() and dot().
|
inline |
|
inline |
|
inline |
SWAP function Note: We could implement a swap function without temporaries: a -= b b += a a -= b a = -a That's four arithmetic operations to save one temporary and it can be only done for integers.
Unlikely that it's worth it.
Definition at line 813 of file basics.h.
References a, ALIGN, b, MIN_ALIGN, REGISTER, SWAP(), and T.
Referenced by SWAP().