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__ 58 # define HAVE_WIN_32 1 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) 107 # define TBCI_DLLEXPORT __declspec(dllexport) 109 # define TBCI_DLLEXPORT __declspec(dllimport) 111 # define TBCI_DLLLOCAL 113 # ifdef HAVE_VISIBILITY_ATTR 114 # define TBCI_DLLEXPORT __attribute__ ((visibility("default"))) 115 # define TBCI_DLLLOCAL __attribute__ ((visibility("hidden"))) 117 # define TBCI_DLLEXPORT 118 # define TBCI_DLLLOCAL 123 #if defined(HAVE_PRAGMA_IFACE_IMPL) && !defined(NO_PRAGMA_I) 128 #ifdef HAVE_NEED_FOR_EXPL_TMPLPARM 132 # define FGDTD <T,dims> 133 # define FGDDT <dims,T> 134 # define FGDCT <cplx<T> > 149 #if defined(__BORLANDC__) && defined(__linux__) 150 # define __BEGIN_NAMESPACE_STD 151 # define __END_NAMESPACE_STD 152 # define __USING_NAMESPACE_STD(name) 153 # define __BEGIN_NAMESPACE_C99 154 # define __END_NAMESPACE_C99 155 # define __USING_NAMESPACE_C99(name) 163 #ifndef HAVE_NO_NEW_HEADERS_BUG 185 #if defined(C_MEMALLOC) && defined(HAVE_MEMALIGN) 190 #ifdef HAVE_MINMAX_IN_SYS_PARAM_H 191 # include <sys/param.h> 195 #if !defined(HAVE_SSTREAM) || defined(HAVE_BUGGY_SSTREAM) 197 # define ISTRINGSTREAM istrstream 198 # define OSTRINGSTREAM ostrstream 199 # define STRINGSTREAM strstream 202 # define ISTRINGSTREAM istringstream 203 # define OSTRINGSTREAM ostringstream 204 # define STRINGSTREAM stringstream 209 #ifdef HAVE_LONG_DOUBLE 210 # define LONG_DOUBLE long double 212 # define LONG_DOUBLE double 214 #ifdef HAVE_LONG_LONG 215 # define LONG_LONG long long 217 # define LONG_LONG long 222 # define INST(x) _instantiate x 223 # define INST2(x,y) _instantiate x,y 224 # define INST3(x,y,z) _instantiate x,y,z 225 # define INST4(x,y,z,a) _instantiate x,y,z,a 226 # define INST5(x,y,z,a,b) _instantiate x,y,z,a,b 227 # define INST6(x,y,z,a,b,c) _instantiate x,y,z,a,b,c 228 # define NOINST _noinstantiate 229 # define INSTCTL(x) _instfile x 233 # define INST3(x,y,z) 234 # define INST4(x,y,z,a) 235 # define INST5(x,y,z,a,b) 236 # define INST6(x,y,z,a,b,c) 255 # define NAMESPACE_TBCI 256 # define NAMESPACE_STD 257 # define NAMESPACE_CSTD 258 # define NAMESPACE_GRID 259 # define NAMESPACE_CPLX 260 # define NAMESPACE_END 261 # define NAMESPACE_STD_END 262 # define NAMESPACE_CSTD_END 263 # define NAMESPACE_CPLX_END 269 # define FRIEND_TBCI__ 270 # define FRIEND_TBCI2__ 281 #elif defined(NO_NS_TBCI) 282 # define NAMESPACE_TBCI 283 # define NAMESPACE_STD namespace std { 284 # define NAMESPACE_CSTD namespace std { 285 # define NAMESPACE_CPLX namespace std { 286 # define NAMESPACE_GRID 287 # define NAMESPACE_FD 288 # define NAMESPACE_END ; 289 # define NAMESPACE_STD_END } 290 # define NAMESPACE_CSTD_END } 291 # define NAMESPACE_CPLX_END } 295 # define USING_END using namespace std; 296 # define USING_STD using namespace std; 299 # define FRIEND_TBCI__ 300 # define FRIEND_TCBI2__ 304 # define MATH__ std:: 305 # define CSTD__ std:: 306 # define CPLX__ std:: 310 # define NAMESPACE_TBCI namespace TBCI { 311 # define NAMESPACE_STD namespace std { 312 # define NAMESPACE_CSTD namespace std { 313 # define NAMESPACE_GRID namespace Grid { 314 # define NAMESPACE_FD namespace Finite_Difference { 315 # define NAMESPACE_CPLX namespace std { 316 # define NAMESPACE_END } 317 # define NAMESPACE_STD_END } 318 # define NAMESPACE_CSTD_END } 319 # define NAMESPACE_CPLX_END } 320 # define USING_TBCI using namespace TBCI; 321 # define USING_GRID using namespace Grid; 322 # define USING_FD using namespace Finite_Difference; 323 # define USING_END using namespace std; 324 # define USING_STD using namespace std; 325 # define TBCI__ TBCI:: 326 # define __TBCI__ ::TBCI:: 327 # define FRIEND_TBCI__ 328 # define FRIEND_TBCI2__ 329 # define GRID__ Grid:: 332 # define MATH__ std:: 333 # define CSTD__ std:: 334 # define CPLX__ std:: 346 # ifdef HAVE_LIBC_GLOBAL_NS_BUG 351 # undef NAMESPACE_CSTD 352 # define NAMESPACE_CSTD 353 # undef NAMESPACE_CSTD_END 354 # define NAMESPACE_CSTD_END 357 # ifdef HAVE_CPP_GLOBAL_NS_BUG 361 # define USING_STD using namespace; 362 # undef NAMESPACE_STD 363 # define NAMESPACE_STD 364 # undef NAMESPACE_STD_END 365 # define NAMESPACE_STD_END 368 # ifdef HAVE_CPLX_GLOBAL_NS_BUG 371 # undef NAMESPACE_CPLX 372 # define NAMESPACE_CPLX 373 # undef NAMESPACE_CPLX_END 374 # define NAMESPACE_CPLX_END 380 # if defined(HAVE_LIBC_GLOBAL_NS_BUG) && !defined(HAVE_CPP_GLOBAL_NS_BUG) 381 # define HAVE_LIBC_NEQ_CPP_BUG 383 # if defined(HAVE_LIBC_GLOBAL_NS_BUG) && !defined(HAVE_CPLX_GLOBAL_NS_BUG) 384 # define HAVE_LIBC_NEQ_CPLX_BUG 389 # if (HAVE_FRIEND_GLOBAL_NS_BUG || HAVE_NEED_FOR_FRIEND_SCOPE) && !defined(AUTO_DECL) && !defined(NO_NS_TBCI) 390 # undef FRIEND_TBCI__ 391 # define FRIEND_TBCI__ TBCI:: 392 # ifdef HAVE_FRIEND_GLOBAL_NS_BUG 393 # undef FRIEND_TBCI2__ 394 # define FRIEND_TBCI2__ TBCI:: 402 # define ABORT_RET(x) abort () 403 # define ABORT_RET_NR abort () 405 # define ABORT_RET(x) return x 406 # define ABORT_RET_NR do {} while (0) 417 # define MIN_ALIGN2 16 421 #if defined(HAVE_ALIGN_ATTR) || defined(HAVE_NEW_ALIGN_ATTR) 422 # ifdef HAVE_NEW_ALIGN_ATTR 423 # define ALIGN3(v,i,x) v __attribute__ ((aligned(x))) (i) 425 # define ALIGN3(v,i,x) v(i) __attribute__ ((aligned(x))) 427 # define ALIGN2(v,x) v __attribute__ ((aligned(x))) 428 # define ALIGN(x) __attribute__ ((aligned(x))) 430 # ifdef HAVE_DECLSPEC_ALIGN 431 # define ALIGN3(v,i,x) __declspec(align(x)) v(i) 432 # define ALIGN2(v,x) __declspec(align(x)) v 433 # define ALIGN(x) __attribute__ ((aligned(x))) 435 # define ALIGN3(v,i,x) v(i) 436 # define ALIGN2(v,x) v 440 #ifdef HAVE_TEMPL_ALIGN_ATTR 441 # define TALIGN(x) ALIGN(x) 446 #ifdef HAVE_CONST_ATTR 447 # define CONSTA __attribute__ ((const)) 448 # define TBCI_CONST(x) x __attribute__ ((const)); x 451 # define TBCI_CONST(x) x 453 #ifdef HAVE_REGPARM_ATTR 454 # define REGPARMA(n) __attribute__ ((regparm(n))) 455 # define REGPARM(n,x) x __attribute__ ((regparm(n))); x 458 # define REGPARM(n,x) x 461 #ifdef HAVE_UNUSED_ATTR 462 # define UNUSED __attribute__((unused)) 468 #ifdef HAVE_WEAK_ATTR 469 # define WEAKA __attribute__ ((weak)) 470 # define WEAK(x) x __attribute__ ((weak)); x 471 #ifdef __INTEL_COMPILER // Does not like that attr in templ specializations 474 # define TWEAK(x) x __attribute__ ((weak)); x 482 #if defined(HAVE_HOT_ATTR) && defined(USE_HOT) 483 # define HOT __attribute__ ((hot)) 484 # define COLD __attribute__ ((cold)) 485 # define HOTDECL(x) x __attribute__ ((hot)); x 486 # define COLDDECL(x) x __attribute__ ((cold)); x 490 # define HOTDECL(x) x 491 # define COLDDECL(x) x 496 #if !defined(NO_EXCEPT) && !defined(HAVE_BUGGY_EXCEPTIONS) 497 # include "tbci/except.h" 499 # define TBCI_DISABLE_EXCEPT 504 #ifndef HAVE_PRETTY_FUNCTION 505 # if defined(HAVE_FUNC) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) 506 # define __PRETTY_FUNCTION__ __func__ 508 # define __PRETTY_FUNCTION__ "<unknown>" 513 #define TBCIERRH1 __PRETTY_FUNCTION__ 514 #define TBCIERRM(cond,exc,txt,ind) \ 515 STD__ string(#exc) + " in " + TBCIERRH1 + ":\n " + #txt + " at "\ 516 + __FILE__ + ":" + TBCI__ ltoa(__LINE__) + ":\n (" + #cond \ 517 + ") == TRUE! (" + #ind + " = " + TBCI__ ltoa(ind) + ")" 518 #define TBCIERRS(cond,exc,txt,ind) \ 519 #exc << " in " << TBCIERRH1 << ":\n " << #txt << " at " \ 520 << __FILE__ << ":" << __LINE__ << ":\n (" << #cond \ 521 << ") == TRUE! (" << #ind << " = " << ind << ")" 524 #ifndef TBCI_NO_ERRCHECK 568 #define BCHK(cond,exc,txt,ind,rtval) \ 570 if (UNLIKELY(__TBCI__ do_errcheck() && (cond))) { \ 571 if (__TBCI__ do_except()) \ 572 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \ 574 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \ 575 if (__TBCI__ do_abort()) \ 579 #define BCHKNR(cond,exc,txt,ind) \ 580 if (UNLIKELY(__TBCI__ do_errcheck() && (cond))) { \ 581 if (__TBCI__ do_except()) \ 582 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \ 584 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \ 585 if (__TBCI__ do_abort()) \ 590 # warning Error checking disabled 592 # define BCHK(cond,exc,txt,ind,rtval) do {} while(0) 593 # define BCHKNR(cond,exc,txt,ind) do {} while(0) 598 #define EXPCHK(cond,exc,txt,ind,rtval) \ 600 if (UNLIKELY(__TBCI__ do_expcheck() && (cond) )) { \ 601 if (__TBCI__ do_except()) \ 602 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \ 604 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \ 605 if (__TBCI__ do_abort()) \ 609 #define EXPCHKNR(cond,exc,txt,ind) \ 610 if (UNLIKELY(__TBCI__ do_expcheck() && (cond) )) { \ 611 if (__TBCI__ do_except()) \ 612 throw exc ((TBCIERRM(cond,exc,txt,ind)).c_str(), ind); \ 614 STD__ cerr << TBCIERRS(cond,exc,txt,ind) << STD__ endl; \ 615 if (__TBCI__ do_abort()) \ 619 # warning Expensive error checking enabled 623 # define EXPCHK(cond,exc,txt,ind,rtval) do {} while(0) 624 # define EXPCHKNR(cond,exc,txt,ind) do {} while(0) 628 #if defined(HAVE_ALGORITHM) && defined(HAVE_STD_MINMAX) &&!defined(HAVE_GCC_MINMAX) 629 # include <algorithm> 637 # ifdef HAVE_GCC_MINMAX 638 # define MIN(a,b) ((a) <? (b)) 639 # define MAX(a,b) ((a) >? (b)) 640 # elif defined(HAVE_STD_MINMAX) 641 # define MIN(a,b) std::min(a,b) 642 # define MAX(a,b) std::max(a,b) 648 # define MIN(a,b) ((a) < (b)? (a) : (b)) 649 # define MAX(a,b) ((a) > (b)? (a) : (b)) 655 # define INFO(x) cout << x 663 #if defined(RETVAL_OPT) && defined(HAVE_NAMED_RETVAL) 664 # define RET(x) return(x); 672 #if defined(_MSC_VER) 673 # define _VOID (void*) 680 #ifndef HAVE_BCXX_TEMPL_INLINE_MFUNC_BUG 681 # define INLINE inline 688 #if defined(_OPENMP) && !defined(TBCI_NO_OMP) 691 # define OMP_FOR _Pragma("omp parallel for") 692 # define OMP_FOR_REDUCE_F2 _Pragma("omp parallel for reduction(+:f2)") 693 # define OMP_FOR_REDUCE_F1F2 _Pragma("omp parallel for reduction(+:f1,f2)") 695 # define NOSMP_VECVEC 697 # define NOSMP_MATVEC 702 # define OMP_FOR_REDUCE_F2 703 # define OMP_FOR_REDUCE_F1F2 714 #if defined(HAVE_BUILTIN_PREFETCH) && !defined(NO_PREFETCH) 715 # define PREFETCH_R(addr,loc) __builtin_prefetch(addr, 0, loc ) 716 # define PREFETCH_W(addr,loc) __builtin_prefetch(addr, 1, loc ) 717 # define USE_PREFETCH 1 726 # if defined(__alpha__) && defined(AXP_PREFETCH) && !defined(NO_PREFETCH) && defined(__GNUC__) 727 # define PREFETCH_R(addr,loc) asm (" lda $31,%0 \n" : : "m" (*(addr)) ) 728 # define PREFETCH_W(addr,loc) asm (" lda $31,%0 \n" : : "m" (*(addr)) ) 729 # define USE_PREFETCH 1 731 # if defined(__i386__) && defined(SSE_PREFETCH) && !defined(NO_PREFETCH) && (defined(__GNUC__) || defined(__INTEL_COMPILER)) 732 # define PREFETCH_R(addr,loc) asm (" prefetcht0 %0 \n" : : "m" (*(addr)) ) 733 # define PREFETCH_W(addr,loc) asm (" prefetcht0 %0 \n" : : "m" (*(addr)) ) 734 # define USE_PREFETCH 1 736 # if defined(__i386__) && defined(AMD_PREFETCH) && !defined(NO_PREFETCH) && (defined(__GNUC__) || defined(__INTEL_COMPILER)) 737 # define PREFETCH_R(addr,loc) asm (" prefetch %0 \n" : : "m" (*(addr)) ) 738 # define PREFETCH_W(addr,loc) asm (" prefetchw %0 \n" : : "m" (*(addr)) ) 739 # define USE_PREFETCH 1 741 # define PREFETCH_R(addr,loc) do {} while (0) 742 # define PREFETCH_W(addr,loc) do {} while (0) 751 # define THREAD__ __thread 752 #elif defined(HAVE_DTLS) 753 # define THREAD__ __declspec(thread) 762 # define MAIN_PID (getpid()) 763 # define num_threads (0) 765 # define ismainthread (1) 770 # define TBCI_SIMD_ALIGN 16 773 #ifdef USE_PLAIN_VEC_KERNELS 775 #elif defined(USE_UNR_VEC_KERNELS2) 793 template <
typename T>
809 # if defined(__GNUC__) && !defined(C_MEMALLOC_WE_KNOW_WHAT_WE_DO) 810 # warning "Don't define C_MEMALLOC if you use containers with elements which need intitalization" 811 # warning " or take care yourself ! (Read basics.h:690)" 813 # ifdef HAVE_MEMALIGN 814 # define NEW(t,s) (t*) memalign (sizeof(t)*MIN(4,s>>1), sizeof(t)*(s)) 816 # define NEW(t,s) (t*) CSTD__ malloc (sizeof(t)*s) 818 # define TBCIDELETE(t,v,sz) do { BCHKNR(!v,NumErr,free null ptr,0); CSTD__ free (v); v = 0; } while (0) 819 # define TBCIDELETE_RO(t,v,sz) do { BCHKNR(!v,NumErr,free null ptr,0); CSTD__ free (v); } while (0) 820 # define REALLOC(v,os,t,s) v = (t*) CSTD__ realloc ((v), sizeof(t)*(s)) 821 #elif !defined(NO_MALLOC_CACHE) //&& !defined(SMP) 823 # if defined(PRAGMA_I) && defined(PRAGMA_IMPL_MALLOC_CACHE) 824 # pragma implementation "malloc_cache.h" 829 # define NEW(t,s) new t[s] 830 # define TBCIDELETE(t,v,sz) do { BCHKNR(!v,NumErr,delete[] null ptr,0); delete[] _VOID v; v = 0; } while (0) 831 # define TBCIDELETE_RO(t,v,sz) do { BCHKNR(!v,NumErr,delete[] null ptr,0); delete[] _VOID v; } while (0) 833 # define REALLOC(v,os,t,s) do { \ 835 if (LIKELY(s)) (v) = new t[(s)]; else (v) = 0; \ 836 if (LIKELY(_tmp != (v) && _tmp && (v) && (os) && (s))) \ 837 CSTD__ memcpy ((v), _tmp, sizeof(t)*MIN((os),(s))); \ 838 if (LIKELY(_tmp)) delete[] (_tmp); \ 841 # define REALLOC(v,os,t,s) do { \ 843 if (LIKELY(s)) (v) = new t[(s)]; else (v) = 0; \ 844 if (LIKELY(_tmp != (v) && _tmp && (v) && (os) && (s))) { \ 845 for (register unsigned long _i = 0; _i < MIN((s),(os)); _i++) \ 846 (v)[_i] = _tmp[_i]; } \ 847 if (LIKELY(_tmp)) delete[] (_tmp); \ 862 #if defined(C_MEMALLOC) || defined(ALLOW_MEMCPY) 863 # if defined(__GNUC__) && !defined(C_MEMALLOC_WE_KNOW_WHAT_WE_DO) 864 # warning "Don't define C_MEMALLOC or ALLOW_MEMCPY if you use containers with elements which" 865 # warning " use dynamic memory allocation or handle with pointers somehow. Copying otherwise" 866 # warning " will break things. (Read basics.h:740)" 868 # define TBCICOPY(n,o,t,s) CSTD__ memcpy ((n),(o),(s)*sizeof(t)) 870 # define VEC_INLINE inline 871 # define COPY2(res,v1,f1,f2) res = v1 874 template <
typename T>
876 # define TBCICOPY(n,o,t,s) _par_copy < t > (s,n,o) 878 # define TBCICOPY(n,o,t,s) _tbci_copy < t > (s,n,o) 884 #if defined(C_MEMALLOC) || defined(ALLOW_MEMSET) 885 # define TBCICLEAR(n,t,s) CSTD__ memset ((n), 0, (s)*sizeof(t)) 888 # define FILL1(res,f1,f2) res = f2 891 template <
typename T>
892 void _par_fill (
const unsigned long,
T *
const,
typename tbci_traits<T>::loop_const_refval_type);
893 # define TBCIFILL(n,v,t,s) _par_fill < t > (s,n,v) 894 # define TBCICLEAR(n,t,s) _par_fill < t > (s,n,t(0)) 896 # define TBCIFILL(n,v,t,s) _tbci_fill < t > (s,n,v) 897 # define TBCICLEAR(n,t,s) _tbci_fill < t > (s,n,t(0)) 902 template <
typename T>
905 T (*fn)(
const unsigned long idx,
void* par);
910 template <
typename T>
913 for (
register unsigned long i = 0;
i < sz; ++
i)
914 vec[
i] = fn.
fn(
i, par);
925 #if defined(C_MEMALLOC) || defined(ALLOW_MEMCMP) 926 # define TBCICOMP(n,o,t,s) CSTD__ memcmp ((n),(o),(s)*sizeof(t)) 928 # define TBCIFILL(n,v,t,s) \ 929 do { for (register unsigned long _i = 0; _i < (s); _i++) \ 930 (n)[_i] = (t)(v); } while (0) 932 # if defined(__GNUG__) && !defined(PEDANTIC) 933 # define _TBCICOMP(n,o,t,s) ({ \ 934 register int _r; register unsigned long _i; \ 935 for (_r=0, _i=0; _i<(s) && !_r; _i++) { \ 936 _r = (int)((n)[_i] != (o)[_i]); \ 944 inline int _tbci_comp (
const unsigned long s,
T const *n,
T const *o))
947 for (
register unsigned long _i = 0; _i < (s); _i++)
948 if (
UNLIKELY((n)[_i] != (o)[_i]))
return 1;
951 # define TBCICOMP(n,o,t,s) _tbci_comp ((s),(n),(o)) 956 #define COMP2(r,v1,f1,f2) if (r != v1) { ++f2; i = sz; goto _fin; } 960 template <
typename T>
961 int _par_comp (
const unsigned long sz,
const T* v1,
const T* v2);
962 # define TBCICOMP(n,o,t,s) _par_comp< t > (s, n, o) 964 # define TBCICOMP(n,o,t,s) ({ long res; do_vv_comp<t>(s,n,o,res); res; }) 974 template <
typename T>
975 unsigned long _bin_search(
const T* vec,
T el,
unsigned long start,
unsigned long end)
977 if (end == start || end-1 == start)
978 return (
unsigned long)-1;
979 unsigned long half = (end+start)/2;
993 template <
typename T>
994 unsigned long bin_search(
const T* vec,
T el,
unsigned long start,
unsigned long end)
997 return (
unsigned long)-1;
998 if (vec[start] == el)
1000 else if (vec[end-1] == el)
1002 if (vec[start] > el)
1003 return (
unsigned long)-1;
1004 if (vec[end-1] < el)
1005 return (
unsigned long)-1;
1006 BCHK(vec[end-1] < vec[start],
NumErr, unsorted vector in
bin_search, end-1, (
unsigned long)-1);
1056 #ifdef HAVE_LONG_DOUBLE 1061 #ifdef HAVE_LONG_LONG 1069 #ifdef _INCLUDE_CPLX_H 1073 #ifdef _INCLUDE_STDCPLX_H 1077 #ifdef _INCLUDE_BUILTINCPLX_H 1085 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600) 1086 template <
typename T>
inline int sign (
const T&
x)
1132 #ifdef TEMPLATED_FABSSQR 1136 # define FABSSQR(T) \ 1137 TBCI_CONST(inline double fabssqr (const T a)) \ 1138 { return CPLX__ real(a * CPLX__ conj(a)); } 1144 # ifdef HAVE_LONG_DOUBLE 1147 # ifdef HAVE_LONG_LONG 1154 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600) 1155 template <
typename T>
inline T sqr (
const T& a)
1162 #if !defined(HAVE_WIN_32) && !defined (NO_NS) // Problems with other dot 1163 # if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600) 1164 template <
typename T>
inline T dot (
const T& a1,
const T& a2)
1178 {
return a<(
T)0?(
double)-a:(double)a; }
1184 TBCI_CONST(inline double fabs (const T a)) \ 1185 { return a<(T)0?(double)-a:(double)a; } 1188 TBCI_CONST(inline double sqrt (const T a)) \ 1189 { return MATH__ sqrt ((double)a); } 1191 # ifdef HAVE_LONG_DOUBLE 1192 # if defined(__GNUC__) && __GNUC__ == 2 && __GNUC_MINOR__ < 97 1201 # ifdef HAVE_LONG_LONG 1207 {
return (
double)
a; }
1218 {
return a<(
T)0?-a:a; }
1223 TBCI_CONST(inline T abs (const T a)) \ 1224 { return a<(T)0?-a:a; } 1226 # ifdef HAVE_MISS_CSTD_ABS_BUG 1227 # ifdef HAVE_LONG_DOUBLE 1232 # ifdef HAVE_LONG_LONG 1238 # if 1 //defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 600) 1246 #ifdef INLINE_VEC_KERNELS 1247 # define VEC_INLINE inline 1261 #ifndef _NO_INCLUDE_COST_H 1265 #if !defined(NO_NS) && defined (USING_STD_NS) 1274 using std::setprecision;
1277 using std::ifstream;
1278 using std::ofstream;
1280 # if defined(HAVE_SSTREAM) && !defined(HAVE_BUGGY_SSTREAM) 1281 using std::istringstream;
1282 using std::ostringstream;
1284 using std::istrstream;
1285 using std::ostrstream;
macros for composing unrolled prefetching loops over arrays.
int _par_comp(const unsigned long sz, const T *v1, const T *v2)
#define LIKELY(expr)
branch prediction note that we sometimes on purpose mark the unlikely possibility likely and vice ver...
void _tbci_fill(const unsigned long sz, T *const res, register typename tbci_traits< T >::loop_const_refval_type f2)
unsigned abs(const unsigned a)
Wrapper for GCC's builtin complex type plus compatibility features (helper class TBCI::hcplx) ...
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...
#define COMP2(r, v1, f1, f2)
Caches memory blocks to avoid calls to __builtin_free()/new() It performs very well for strictly recu...
exception base class for the TBCI NumLib
macros for composing plain loops over arrays.
#define COPY2(res, v1, f1, f2)
#define FILL1(res, f1, f2)
#define BCHK(cond, exc, txt, ind, rtval)
#define NAMESPACE_CSTD_END
T(* fn)(const unsigned long idx, void *par)
const Vector< T > const Vector< T > & x
Preprocessor macros for estimating the "cost" of operations.
void _par_copy(const unsigned long sz, T *v1, const T *v2)
#define VKERN_TEMPL_2V_T(FNAME, OP2, TYPE)
Operations of type TYPE = VEC OP VEC.
T arg(const TBCI__ cplx< T > &c)
void _par_fill(const unsigned long, T *const, typename tbci_traits< T >::loop_const_refval_type)
double conj(const double arg)
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...
#define VKERN_TEMPL_2V(FNAME, OP2)
Operations of type vec OP= vec.
cplx< T > sqr(const cplx< T > &c)
int sign(const T &x)
Signum.
void SWAP(T &a, T &b)
SWAP function Note: We could implement a swap function without temporaries: a -= b b += a a -= b a = ...
T dot(const T &a1, const T &a2)
#define VKERN_TEMPL_1V_C(FNAME, OP1)
Operations of type VEC OP= VAL.
#define NAMESPACE_CPLX_END
Wrapper for C++ std library complex type plus compatibility features.
double real(const double d)
double fabs(const unsigned int a)
Rich implementation of complex numbers TBCI::cplx.
_vararg
This is a helper type to identify and count varargs.
This provides some parameters that control the behavior of various functions in the TBCI library...
macros for composing unrolled prefetching loops over arrays.
double fabssqr(const unsigned a)
double imag(const double d)
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 _tbci_fill_fn(const unsigned long sz, T *vec, vec_fill_fn< T > fn, void *par)
void _tbci_copy(const unsigned long sz, T *const res, const T *const v1)