35#include "tbci/tbci_version.h"
37#ifdef HAVE_TBCICONFIG_H
38# include "tbci/tbciconfig.h"
40# include "tbci/config_manual.h"
44#if !defined(__GNUC_PATCHLEVEL__) && defined(__GNUC__SUBVER__)
45# define __GNUC_PATCHLEVEL__ __GNUC_SUBVER__
60# pragma warning(disable: 4003)
64#if defined(USE_SMP) && !defined(SMP)
69#if !defined(NO_NS) && !defined(HAVE_BUGGY_NAMESPACE)
78# define SIGNATURE signature
80# define SIGNATURE class
84#if defined(HAVE_RESTRICT) && !defined(NO_RESTRICT)
85# define RESTRICT restrict
86#elif defined (HAVE___RESTRICT__) && !defined(NO_RESTRICT)
87# define RESTRICT __restrict__
96#if defined(HAVE_BUILTIN_EXPECT) && !defined(NO_EXPECT)
97# define LIKELY(expr) __builtin_expect((expr) != 0, 1)
98# define UNLIKELY(expr) __builtin_expect((expr) != 0, 0)
100# define LIKELY(expr) (expr)
101# define UNLIKELY(expr) (expr)
105#if defined(__cplusplus) && __cplusplus >= 201703L
108# define REGISTER register
114# define TBCI_DLLEXPORT __declspec(dllexport)
116# define TBCI_DLLEXPORT __declspec(dllimport)
118# define TBCI_DLLLOCAL
120# ifdef HAVE_VISIBILITY_ATTR
121# define TBCI_DLLEXPORT __attribute__ ((visibility("default")))
122# define TBCI_DLLLOCAL __attribute__ ((visibility("hidden")))
124# define TBCI_DLLEXPORT
125# define TBCI_DLLLOCAL
130#if defined(HAVE_PRAGMA_IFACE_IMPL) && !defined(NO_PRAGMA_I)
135#ifdef HAVE_NEED_FOR_EXPL_TMPLPARM
139# define FGDTD <T,dims>
140# define FGDDT <dims,T>
141# define FGDCT <cplx<T> >
156#if defined(__BORLANDC__) && defined(__linux__)
157# define __BEGIN_NAMESPACE_STD
158# define __END_NAMESPACE_STD
159# define __USING_NAMESPACE_STD(name)
160# define __BEGIN_NAMESPACE_C99
161# define __END_NAMESPACE_C99
162# define __USING_NAMESPACE_C99(name)
170#ifndef HAVE_NO_NEW_HEADERS_BUG
192#if defined(C_MEMALLOC) && defined(HAVE_MEMALIGN)
197#ifdef HAVE_MINMAX_IN_SYS_PARAM_H
198# include <sys/param.h>
202#if !defined(HAVE_SSTREAM) || defined(HAVE_BUGGY_SSTREAM)
204# define ISTRINGSTREAM istrstream
205# define OSTRINGSTREAM ostrstream
206# define STRINGSTREAM strstream
209# define ISTRINGSTREAM istringstream
210# define OSTRINGSTREAM ostringstream
211# define STRINGSTREAM stringstream
216#ifdef HAVE_LONG_DOUBLE
217# define LONG_DOUBLE long double
219# define LONG_DOUBLE double
222# define LONG_LONG long long
224# define LONG_LONG long
229# define INST(x) _instantiate x
230# define INST2(x,y) _instantiate x,y
231# define INST3(x,y,z) _instantiate x,y,z
232# define INST4(x,y,z,a) _instantiate x,y,z,a
233# define INST5(x,y,z,a,b) _instantiate x,y,z,a,b
234# define INST6(x,y,z,a,b,c) _instantiate x,y,z,a,b,c
235# define NOINST _noinstantiate
236# define INSTCTL(x) _instfile x
241# define INST4(x,y,z,a)
242# define INST5(x,y,z,a,b)
243# define INST6(x,y,z,a,b,c)
262# define NAMESPACE_TBCI
263# define NAMESPACE_STD
264# define NAMESPACE_CSTD
265# define NAMESPACE_GRID
266# define NAMESPACE_CPLX
267# define NAMESPACE_END
268# define NAMESPACE_STD_END
269# define NAMESPACE_CSTD_END
270# define NAMESPACE_CPLX_END
276# define FRIEND_TBCI__
277# define FRIEND_TBCI2__
288#elif defined(NO_NS_TBCI)
289# define NAMESPACE_TBCI
290# define NAMESPACE_STD namespace std {
291# define NAMESPACE_CSTD namespace std {
292# define NAMESPACE_CPLX namespace std {
293# define NAMESPACE_GRID
295# define NAMESPACE_END ;
296# define NAMESPACE_STD_END }
297# define NAMESPACE_CSTD_END }
298# define NAMESPACE_CPLX_END }
302# define USING_END using namespace std;
303# define USING_STD using namespace std;
306# define FRIEND_TBCI__
307# define FRIEND_TCBI2__
317# define NAMESPACE_TBCI namespace TBCI {
318# define NAMESPACE_STD namespace std {
319# define NAMESPACE_CSTD namespace std {
320# define NAMESPACE_GRID namespace Grid {
321# define NAMESPACE_FD namespace Finite_Difference {
322# define NAMESPACE_CPLX namespace std {
323# define NAMESPACE_END }
324# define NAMESPACE_STD_END }
325# define NAMESPACE_CSTD_END }
326# define NAMESPACE_CPLX_END }
327# define USING_TBCI using namespace TBCI;
328# define USING_GRID using namespace Grid;
329# define USING_FD using namespace Finite_Difference;
330# define USING_END using namespace std;
331# define USING_STD using namespace std;
332# define TBCI__ TBCI::
333# define __TBCI__ ::TBCI::
334# define FRIEND_TBCI__
335# define FRIEND_TBCI2__
336# define GRID__ Grid::
353# ifdef HAVE_LIBC_GLOBAL_NS_BUG
358# undef NAMESPACE_CSTD
359# define NAMESPACE_CSTD
360# undef NAMESPACE_CSTD_END
361# define NAMESPACE_CSTD_END
364# ifdef HAVE_CPP_GLOBAL_NS_BUG
368# define USING_STD using namespace;
370# define NAMESPACE_STD
371# undef NAMESPACE_STD_END
372# define NAMESPACE_STD_END
375# ifdef HAVE_CPLX_GLOBAL_NS_BUG
378# undef NAMESPACE_CPLX
379# define NAMESPACE_CPLX
380# undef NAMESPACE_CPLX_END
381# define NAMESPACE_CPLX_END
387# if defined(HAVE_LIBC_GLOBAL_NS_BUG) && !defined(HAVE_CPP_GLOBAL_NS_BUG)
388# define HAVE_LIBC_NEQ_CPP_BUG
390# if defined(HAVE_LIBC_GLOBAL_NS_BUG) && !defined(HAVE_CPLX_GLOBAL_NS_BUG)
391# define HAVE_LIBC_NEQ_CPLX_BUG
396# if (HAVE_FRIEND_GLOBAL_NS_BUG || HAVE_NEED_FOR_FRIEND_SCOPE) && !defined(AUTO_DECL) && !defined(NO_NS_TBCI)
398# define FRIEND_TBCI__ TBCI::
399# ifdef HAVE_FRIEND_GLOBAL_NS_BUG
400# undef FRIEND_TBCI2__
401# define FRIEND_TBCI2__ TBCI::
409# define ABORT_RET(x) abort ()
410# define ABORT_RET_NR abort ()
412# define ABORT_RET(x) return x
413# define ABORT_RET_NR do {} while (0)
424# define MIN_ALIGN2 16
428#if defined(HAVE_ALIGN_ATTR) || defined(HAVE_NEW_ALIGN_ATTR)
429# ifdef HAVE_NEW_ALIGN_ATTR
430# define ALIGN3(v,i,x) v __attribute__ ((aligned(x))) (i)
432# define ALIGN3(v,i,x) v(i) __attribute__ ((aligned(x)))
434# define ALIGN2(v,x) v __attribute__ ((aligned(x)))
435# define ALIGN(x) __attribute__ ((aligned(x)))
437# ifdef HAVE_DECLSPEC_ALIGN
438# define ALIGN3(v,i,x) __declspec(align(x)) v(i)
439# define ALIGN2(v,x) __declspec(align(x)) v
440# define ALIGN(x) __attribute__ ((aligned(x)))
442# define ALIGN3(v,i,x) v(i)
443# define ALIGN2(v,x) v
447#ifdef HAVE_TEMPL_ALIGN_ATTR
448# define TALIGN(x) ALIGN(x)
453#ifdef HAVE_CONST_ATTR
454# define CONSTA __attribute__ ((const))
455# define TBCI_CONST(x) x __attribute__ ((const)); x
458# define TBCI_CONST(x) x
460#ifdef HAVE_REGPARM_ATTR
461# define REGPARMA(n) __attribute__ ((regparm(n)))
462# define REGPARM(n,x) x __attribute__ ((regparm(n))); x
465# define REGPARM(n,x) x
468#ifdef HAVE_UNUSED_ATTR
469# define UNUSED __attribute__((unused))
476# define WEAKA __attribute__ ((weak))
477# define WEAK(x) x __attribute__ ((weak)); x
478#ifdef __INTEL_COMPILER
481# define TWEAK(x) x __attribute__ ((weak)); x
489#if defined(HAVE_HOT_ATTR) && defined(USE_HOT)
490# define HOT __attribute__ ((hot))
491# define COLD __attribute__ ((cold))
492# define HOTDECL(x) x __attribute__ ((hot)); x
493# define COLDDECL(x) x __attribute__ ((cold)); x
498# define COLDDECL(x) x
503#if !defined(NO_EXCEPT) && !defined(HAVE_BUGGY_EXCEPTIONS)
504# include "tbci/except.h"
506# define TBCI_DISABLE_EXCEPT
511#ifndef HAVE_PRETTY_FUNCTION
512# if defined(HAVE_FUNC) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
513# define __PRETTY_FUNCTION__ __func__
515# define __PRETTY_FUNCTION__ "<unknown>"
520#define TBCIERRH1 __PRETTY_FUNCTION__
521#define TBCIERRM(cond,exc,txt,ind) \
522 STD__ string(#exc) + " in " + TBCIERRH1 + ":\n " + #txt + " at "\
523 + __FILE__ + ":" + TBCI__ ltoa(__LINE__) + ":\n (" + #cond \
524 + ") == TRUE! (" + #ind + " = " + TBCI__ ltoa(ind) + ")"
525#define TBCIERRS(cond,exc,txt,ind) \
526 #exc << " in " << TBCIERRH1 << ":\n " << #txt << " at " \
527 << __FILE__ << ":" << __LINE__ << ":\n (" << #cond \
528 << ") == TRUE! (" << #ind << " = " << ind << ")"
531#ifndef TBCI_NO_ERRCHECK
575#define BCHK(cond,exc,txt,ind,rtval) \
577 if (UNLIKELY(__TBCI__ do_errcheck() && (cond))) { \
578 if (__TBCI__ do_except()) \
579 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \
581 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \
582 if (__TBCI__ do_abort()) \
586#define BCHKNR(cond,exc,txt,ind) \
587 if (UNLIKELY(__TBCI__ do_errcheck() && (cond))) { \
588 if (__TBCI__ do_except()) \
589 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \
591 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \
592 if (__TBCI__ do_abort()) \
597# warning Error checking disabled
599# define BCHK(cond,exc,txt,ind,rtval) do {} while(0)
600# define BCHKNR(cond,exc,txt,ind) do {} while(0)
605#define EXPCHK(cond,exc,txt,ind,rtval) \
607 if (UNLIKELY(__TBCI__ do_expcheck() && (cond) )) { \
608 if (__TBCI__ do_except()) \
609 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \
611 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \
612 if (__TBCI__ do_abort()) \
616#define EXPCHKNR(cond,exc,txt,ind) \
617 if (UNLIKELY(__TBCI__ do_expcheck() && (cond) )) { \
618 if (__TBCI__ do_except()) \
619 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \
621 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \
622 if (__TBCI__ do_abort()) \
626# warning Expensive error checking enabled
630# define EXPCHK(cond,exc,txt,ind,rtval) do {} while(0)
631# define EXPCHKNR(cond,exc,txt,ind) do {} while(0)
635#if defined(HAVE_ALGORITHM) && defined(HAVE_STD_MINMAX) &&!defined(HAVE_GCC_MINMAX)
644# ifdef HAVE_GCC_MINMAX
645# define MIN(a,b) ((a) <? (b))
646# define MAX(a,b) ((a) >? (b))
647# elif defined(HAVE_STD_MINMAX)
648# define MIN(a,b) std::min(a,b)
649# define MAX(a,b) std::max(a,b)
655# define MIN(a,b) ((a) < (b)? (a) : (b))
656# define MAX(a,b) ((a) > (b)? (a) : (b))
662# define INFO(x) cout << x
670#if defined(RETVAL_OPT) && defined(HAVE_NAMED_RETVAL)
671# define RET(x) return(x);
680# define _VOID (void*)
687#ifndef HAVE_BCXX_TEMPL_INLINE_MFUNC_BUG
688# define INLINE inline
695#if defined(_OPENMP) && !defined(TBCI_NO_OMP)
698# define OMP_FOR _Pragma("omp parallel for")
699# define OMP_FOR_REDUCE_F2 _Pragma("omp parallel for reduction(+:f2)")
700# define OMP_FOR_REDUCE_F1F2 _Pragma("omp parallel for reduction(+:f1,f2)")
709# define OMP_FOR_REDUCE_F2
710# define OMP_FOR_REDUCE_F1F2
721#if defined(HAVE_BUILTIN_PREFETCH) && !defined(NO_PREFETCH)
722# define PREFETCH_R(addr,loc) __builtin_prefetch(addr, 0, loc )
723# define PREFETCH_W(addr,loc) __builtin_prefetch(addr, 1, loc )
724# define USE_PREFETCH 1
733# if defined(__alpha__) && defined(AXP_PREFETCH) && !defined(NO_PREFETCH) && defined(__GNUC__)
734# define PREFETCH_R(addr,loc) asm (" lda $31,%0 \n" : : "m" (*(addr)) )
735# define PREFETCH_W(addr,loc) asm (" lda $31,%0 \n" : : "m" (*(addr)) )
736# define USE_PREFETCH 1
738# if defined(__i386__) && defined(SSE_PREFETCH) && !defined(NO_PREFETCH) && (defined(__GNUC__) || defined(__INTEL_COMPILER))
739# define PREFETCH_R(addr,loc) asm (" prefetcht0 %0 \n" : : "m" (*(addr)) )
740# define PREFETCH_W(addr,loc) asm (" prefetcht0 %0 \n" : : "m" (*(addr)) )
741# define USE_PREFETCH 1
743# if defined(__i386__) && defined(AMD_PREFETCH) && !defined(NO_PREFETCH) && (defined(__GNUC__) || defined(__INTEL_COMPILER))
744# define PREFETCH_R(addr,loc) asm (" prefetch %0 \n" : : "m" (*(addr)) )
745# define PREFETCH_W(addr,loc) asm (" prefetchw %0 \n" : : "m" (*(addr)) )
746# define USE_PREFETCH 1
748# define PREFETCH_R(addr,loc) do {} while (0)
749# define PREFETCH_W(addr,loc) do {} while (0)
757# define PREFETCH_R_MANY(addr,loc) \
758 for (char* _prefaddr = (char*)addr; _prefaddr < (char*)addr+CACHELINE_SZ*PREFETCH_AHEAD; _prefaddr += CACHELINE_SZ) \
759 PREFETCH_R(_prefaddr,loc)
760# define PREFETCH_W_MANY(addr,loc) \
761 for (char* _prefaddr = (char*)addr; _prefaddr < (char*)addr+CACHELINE_SZ*PREFETCH_AHEAD; _prefaddr += CACHELINE_SZ) \
762 PREFETCH_W(_prefaddr,loc)
764# define PREFETCH_R_MANY(addr,loc) do {} while(0)
765# define PREFETCH_W_MANY(addr,loc) do {} while(0)
770# define THREAD__ __thread
771#elif defined(HAVE_DTLS)
772# define THREAD__ __declspec(thread)
781# define MAIN_PID (getpid())
782# define num_threads (0)
784# define ismainthread (1)
789# define TBCI_SIMD_ALIGN 16
792#ifdef USE_PLAIN_VEC_KERNELS
794#elif defined(USE_UNR_VEC_KERNELS2)
828# if defined(__GNUC__) && !defined(C_MEMALLOC_WE_KNOW_WHAT_WE_DO)
829# warning "Don't define C_MEMALLOC if you use containers with elements which need intitalization"
830# warning " or take care yourself ! (Read basics.h:690)"
833# define NEW(t,s) (t*) memalign (sizeof(t)*MIN(4,s>>1), sizeof(t)*(s))
835# define NEW(t,s) (t*) CSTD__ malloc (sizeof(t)*s)
837# define TBCIDELETE(t,v,sz) do { BCHKNR(!v,NumErr,free null ptr,0); CSTD__ free (v); v = 0; } while (0)
838# define TBCIDELETE_RO(t,v,sz) do { BCHKNR(!v,NumErr,free null ptr,0); CSTD__ free (v); } while (0)
839# define REALLOC(v,os,t,s) v = (t*) CSTD__ realloc ((v), sizeof(t)*(s))
840#elif !defined(NO_MALLOC_CACHE)
842# if defined(PRAGMA_I) && defined(PRAGMA_IMPL_MALLOC_CACHE)
843# pragma implementation "malloc_cache.h"
848# define NEW(t,s) new t[s]
849# define TBCIDELETE(t,v,sz) do { BCHKNR(!v,NumErr,delete[] null ptr,0); delete[] _VOID v; v = 0; } while (0)
850# define TBCIDELETE_RO(t,v,sz) do { BCHKNR(!v,NumErr,delete[] null ptr,0); delete[] _VOID v; } while (0)
852# define REALLOC(v,os,t,s) do { \
854 if (LIKELY(s)) (v) = new t[(s)]; else (v) = 0; \
855 if (LIKELY(_tmp != (v) && _tmp && (v) && (os) && (s))) \
856 CSTD__ memcpy ((v), _tmp, sizeof(t)*MIN((os),(s))); \
857 if (LIKELY(_tmp)) delete[] (_tmp); \
860# define REALLOC(v,os,t,s) do { \
862 if (LIKELY(s)) (v) = new t[(s)]; else (v) = 0; \
863 if (LIKELY(_tmp != (v) && _tmp && (v) && (os) && (s))) { \
864 for (REGISTER unsigned long _i = 0; _i < MIN((s),(os)); _i++) \
865 (v)[_i] = _tmp[_i]; } \
866 if (LIKELY(_tmp)) delete[] (_tmp); \
881#if defined(C_MEMALLOC) || defined(ALLOW_MEMCPY)
882# if defined(__GNUC__) && !defined(C_MEMALLOC_WE_KNOW_WHAT_WE_DO)
883# warning "Don't define C_MEMALLOC or ALLOW_MEMCPY if you use containers with elements which"
884# warning " use dynamic memory allocation or handle with pointers somehow. Copying otherwise"
885# warning " will break things. (Read basics.h:740)"
887# define TBCICOPY(n,o,t,s) CSTD__ memcpy ((n),(o),(s)*sizeof(t))
889# define VEC_INLINE inline
890# define COPY2(res,v1,f1,f2) res = v1
895# define TBCICOPY(n,o,t,s) _par_copy < t > (s,n,o)
897# define TBCICOPY(n,o,t,s) _tbci_copy < t > (s,n,o)
903#if defined(C_MEMALLOC) || defined(ALLOW_MEMSET)
904# define TBCICLEAR(n,t,s) CSTD__ memset ((n), 0, (s)*sizeof(t))
907# define FILL1(res,f1,f2) res = f2
911void _par_fill (
const unsigned long,
T *
const,
typename tbci_traits<T>::loop_const_refval_type);
912# define TBCIFILL(n,v,t,s) _par_fill < t > (s,n,v)
913# define TBCICLEAR(n,t,s) _par_fill < t > (s,n,t(0))
915# define TBCIFILL(n,v,t,s) _tbci_fill < t > (s,n,v)
916# define TBCICLEAR(n,t,s) _tbci_fill < t > (s,n,t(0))
924 T (*
fn)(
const unsigned long idx,
void* par);
933 vec[
i] = fn.
fn(
i, par);
944#if defined(C_MEMALLOC) || defined(ALLOW_MEMCMP)
945# define TBCICOMP(n,o,t,s) CSTD__ memcmp ((n),(o),(s)*sizeof(t))
947# define TBCIFILL(n,v,t,s) \
948 do { for (REGISTER unsigned long _i = 0; _i < (s); _i++) \
949 (n)[_i] = (t)(v); } while (0)
951# if defined(__GNUG__) && !defined(PEDANTIC)
952# define _TBCICOMP(n,o,t,s) ({ \
953 REGISTER int _r; REGISTER unsigned long _i; \
954 for (_r=0, _i=0; _i<(s) && !_r; _i++) { \
955 _r = (int)((n)[_i] != (o)[_i]); \
963inline int _tbci_comp (
const unsigned long s,
T const *n,
T const *o))
966 for (
REGISTER unsigned long _i = 0; _i < (s); _i++)
967 if (
UNLIKELY((n)[_i] != (o)[_i]))
return 1;
970# define TBCICOMP(n,o,t,s) _tbci_comp ((s),(n),(o))
975#define COMP2(r,v1,f1,f2) if (r != v1) { ++f2; i = sz; goto _fin; }
981# define TBCICOMP(n,o,t,s) _par_comp< t > (s, n, o)
983# define TBCICOMP(n,o,t,s) ({ long res; do_vv_comp<t>(s,n,o,res); res; })
996 if (
end == start ||
end-1 == start)
997 return (
unsigned long)-1;
998 unsigned long half = (
end+start)/2;
1012template <
typename T>
1016 return (
unsigned long)-1;
1017 if (vec[start] == el)
1019 else if (vec[
end-1] == el)
1021 if (vec[start] > el)
1022 return (
unsigned long)-1;
1023 if (vec[
end-1] < el)
1024 return (
unsigned long)-1;
1075#ifdef HAVE_LONG_DOUBLE
1080#ifdef HAVE_LONG_LONG
1088#ifdef _INCLUDE_CPLX_H
1092#ifdef _INCLUDE_STDCPLX_H
1096#ifdef _INCLUDE_BUILTINCPLX_H
1104#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600)
1105template <
typename T>
inline int sign (
const T&
x)
1151#ifdef TEMPLATED_FABSSQR
1155# define FABSSQR(T) \
1156TBCI_CONST(inline double fabssqr (const T a)) \
1157{ return CPLX__ real(a * CPLX__ conj(a)); }
1163# ifdef HAVE_LONG_DOUBLE
1166# ifdef HAVE_LONG_LONG
1173#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600)
1174template <
typename T>
inline T sqr (
const T&
a)
1181#if !defined(HAVE_WIN_32) && !defined (NO_NS)
1182# if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600)
1183template <
typename T>
inline T dot (
const T& a1,
const T& a2)
1197{
return a<(
T)0?(
double)-
a:(double)
a; }
1203TBCI_CONST(inline double fabs (const T a)) \
1204{ return a<(T)0?(double)-a:(double)a; }
1207TBCI_CONST(inline double sqrt (const T a)) \
1208{ return MATH__ sqrt ((double)a); }
1210# ifdef HAVE_LONG_DOUBLE
1211# if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 97
1220# ifdef HAVE_LONG_LONG
1226{
return (
double)
a; }
1237{
return a<(
T)0?-
a:
a; }
1242TBCI_CONST(inline T abs (const T a)) \
1243{ return a<(T)0?-a:a; }
1245# ifdef HAVE_MISS_CSTD_ABS_BUG
1246# ifdef HAVE_LONG_DOUBLE
1251# ifdef HAVE_LONG_LONG
1265#ifdef INLINE_VEC_KERNELS
1266# define VEC_INLINE inline
1282#ifndef _NO_INCLUDE_COST_H
1286#if !defined(NO_NS) && defined (USING_STD_NS)
1295using std::setprecision;
1301# if defined(HAVE_SSTREAM) && !defined(HAVE_BUGGY_SSTREAM)
1302using std::istringstream;
1303using std::ostringstream;
1305using std::istrstream;
1306using std::ostrstream;
const Vector< T > const Vector< T > & x
#define BCHK(cond, exc, txt, ind, rtval)
#define LIKELY(expr)
branch prediction note that we sometimes on purpose mark the unlikely possibility likely and vice ver...
#define NAMESPACE_CPLX_END
#define NAMESPACE_CSTD_END
#define COPY2(res, v1, f1, f2)
#define FILL1(res, f1, f2)
#define COMP2(r, v1, f1, f2)
Wrapper for GCC's builtin complex type plus compatibility features (helper class TBCI::hcplx).
exception base class for the TBCI NumLib
vec_fill_fn(T(*f)(const unsigned long, void *))
T(* fn)(const unsigned long idx, void *par)
Preprocessor macros for estimating the "cost" of operations.
Rich implementation of complex numbers TBCI::cplx.
T imag(const TBCI__ cplx< T > &z)
double fabs(const TBCI__ cplx< T > &c)
T arg(const TBCI__ cplx< T > &c)
cplx< T > dot(const cplx< T > &a, const cplx< T > &b)
double fabssqr(const cplx< T > &c)
cplx< T > sqr(const cplx< T > &c)
NAMESPACE_END NAMESPACE_CPLX TBCI__ cplx< T > conj(const TBCI__ cplx< T > &c)
Caches memory blocks to avoid calls to __builtin_free()/new() It performs very well for strictly recu...
const unsigned TMatrix< T > const Matrix< T > * a
void _tbci_fill_fn(const unsigned long sz, T *vec, vec_fill_fn< T > fn, void *par)
T dot(const T &a1, const T &a2)
int _par_comp(const unsigned long sz, const T *v1, const T *v2)
_vararg
This is a helper type to identify and count varargs.
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 ele...
int sign(const T &x)
Signum.
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
void _par_fill(const unsigned long, T *const, typename tbci_traits< T >::loop_const_refval_type)
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 ele...
void _tbci_copy(const unsigned long sz, T *const res, const T *const v1)
void _par_copy(const unsigned long sz, T *v1, const T *v2)
void _tbci_fill(const unsigned long sz, T *const res, register typename tbci_traits< T >::loop_const_refval_typef2)
void SWAP(T &a, T &b)
SWAP function Note: We could implement a swap function without temporaries: a -= b b += a a -= b a = ...
int conj(const int arg)
conj for elementary types
macros for composing plain loops over arrays.
#define VKERN_TEMPL_1V_C(FNAME, OP1)
Operations of type VEC OP= VAL.
#define VKERN_TEMPL_2V(FNAME, OP2)
Operations of type vec OP= vec.
#define VKERN_TEMPL_2V_T(FNAME, OP2, TYPE)
Operations of type TYPE = VEC OP VEC.
Wrapper for C++ std library complex type plus compatibility features.
This provides some parameters that control the behavior of various functions in the TBCI library.
macros for composing unrolled prefetching loops over arrays.
macros for composing unrolled prefetching loops over arrays.