TBCI Numerical high perf. C++ Library 2.8.0
TBCI Namespace Reference

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)

Detailed Description

The TBCI Numerical Library is put into TBCI namespace, if the compiler supports it (egcs-1.1.x and later for example).

Typedef Documentation

◆ vararg

typedef enum _vararg TBCI::vararg

Definition at line 1278 of file basics.h.

Enumeration Type Documentation

◆ _vararg

This is a helper type to identify and count varargs.

Enumerator
vag0 
vag1 
vag2 
vag3 
vag4 
vag5 
vag6 
vag7 
vag8 
vag9 
vag10 
vag11 
vag12 
vag13 
vag14 
vag15 
vag16 
vag_max 

Definition at line 1274 of file basics.h.

Function Documentation

◆ _bin_search()

template<typename T>
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().

◆ _par_comp()

template<typename T>
int TBCI::_par_comp ( const unsigned long sz,
const T * v1,
const T * v2 )

References _par_comp(), and T.

Referenced by _par_comp().

◆ _par_copy()

template<typename T>
void TBCI::_par_copy ( const unsigned long sz,
T * v1,
const T * v2 )

References _par_copy(), and T.

Referenced by _par_copy().

◆ _par_fill()

template<typename T>
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().

◆ _tbci_copy()

template<typename T>
void TBCI::_tbci_copy ( const unsigned long sz,
T *const res,
const T *const v1 )
inline

Definition at line 891 of file basics.h.

References _tbci_copy(), and COPY2.

Referenced by _tbci_copy().

◆ _tbci_fill()

template<typename T>
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().

◆ _tbci_fill_fn()

template<typename T>
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().

◆ bin_search()

template<typename T>
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().

◆ do_vv_comp()

template<typename T>
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().

◆ dot()

template<typename T>
T TBCI::dot ( const T & a1,
const T & a2 )
inline

Definition at line 1185 of file basics.h.

References conj(), dot(), and T.

Referenced by dot().

◆ fabssqr() [1/4]

double TBCI::fabssqr ( const double a)
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().

Definition at line 1159 of file basics.h.

◆ fabssqr() [2/4]

double TBCI::fabssqr ( const float a)
inline

Definition at line 1160 of file basics.h.

References FABSSQR.

◆ fabssqr() [3/4]

double TBCI::fabssqr ( const int a)
inline

Definition at line 1161 of file basics.h.

References FABSSQR.

◆ fabssqr() [4/4]

double TBCI::fabssqr ( const unsigned a)
inline

Definition at line 1162 of file basics.h.

References a, FABSSQR, and T.

◆ sign()

template<typename T>
int TBCI::sign ( const T & x)
inline

Signum.

Definition at line 1107 of file basics.h.

References LIKELY, real, sign(), T, and x.

Referenced by sign().

◆ sqr()

template<typename T>
T TBCI::sqr ( const T & a)
inline

Definition at line 1176 of file basics.h.

References a, sqr(), and T.

Referenced by sqr().

◆ SWAP()

template<typename T>
void TBCI::SWAP ( T & a,
T & b )
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().