Changes in / [47e000c:7f5683e]
- Files:
-
- 2 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/pl.bib
r47e000c r7f5683e 1797 1797 } 1798 1798 1799 @article{Delisle2 1,1799 @article{Delisle20, 1800 1800 keywords = {concurrency, Cforall}, 1801 1801 contributer = {pabuhr@plg}, 1802 1802 author = {Thierry Delisle and Peter A. Buhr}, 1803 1803 title = {Advanced Control-flow and Concurrency in \textsf{C}$\mathbf{\forall}$}, 1804 year = 2020, 1804 1805 journal = spe, 1805 month = may, 1806 year = 2021, 1807 volume = 51, 1808 number = 5, 1809 pages = {1005-1042}, 1810 note = {\href{https://onlinelibrary.wiley.com/doi/10.1002/spe.2925}{https://\-onlinelibrary.wiley.com/\-doi/\-10.1002/\-spe.2925}}, 1806 pages = {1-38}, 1807 note = {\href{https://doi-org.proxy.lib.uwaterloo.ca/10.1002/spe.2925}{https://\-doi-org.proxy.lib.uwaterloo.ca/\-10.1002/\-spe.2925}}, 1808 note = {}, 1811 1809 } 1812 1810 -
libcfa/prelude/builtins.c
r47e000c r7f5683e 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Tue Apr 13 17:26:32 202113 // Update Count : 11 711 // Last Modified By : Andrew Beach 12 // Last Modified On : Tue Oct 27 14:42:00 2020 13 // Update Count : 111 14 14 // 15 15 … … 125 125 } // distribution 126 126 127 #define __CFA_BASE_COMP_1__() if ( x== 1 ) return 1128 #define __CFA_BASE_COMP_2__() if ( x == 2 ) return x<< (y - 1)127 #define __CFA_BASE_COMP_1__() if ( ep == 1 ) return 1 128 #define __CFA_BASE_COMP_2__() if ( ep == 2 ) return ep << (y - 1) 129 129 #define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * CHAR_BIT ) return 0 130 130 … … 134 134 __CFA_BASE_COMP_2__(); /* special case, positive shifting for integral types */ \ 135 135 __CFA_EXP_OVERFLOW__(); /* immediate overflow, negative exponent > 2^size-1 */ \ 136 typeof( x) op = 1; /* accumulate odd product */ \136 typeof(ep) op = 1; /* accumulate odd product */ \ 137 137 for ( ; y > 1; y >>= 1 ) { /* squaring exponentiation, O(log2 y) */ \ 138 if ( (y & 1) == 1 ) op = op * x; /* odd ? */ \139 x = x * x; \138 if ( (y & 1) == 1 ) op = op * ep; /* odd ? */ \ 139 ep = ep * ep; \ 140 140 } \ 141 return x* op141 return ep * op 142 142 143 143 static inline { 144 long int ?\?( int x, unsigned int y ) { __CFA_EXP__(); } 145 long int ?\?( long int x, unsigned long int y ) { __CFA_EXP__(); } 146 long long int ?\?( long long int x, unsigned long long int y ) { __CFA_EXP__(); } 144 long int ?\?( int ep, unsigned int y ) { __CFA_EXP__(); } 145 long int ?\?( long int ep, unsigned long int y ) { __CFA_EXP__(); } 147 146 // unsigned computation may be faster and larger 148 unsigned long int ?\?( unsigned int x, unsigned int y ) { __CFA_EXP__(); } 149 unsigned long int ?\?( unsigned long int x, unsigned long int y ) { __CFA_EXP__(); } 150 unsigned long long int ?\?( unsigned long long int x, unsigned long long int y ) { __CFA_EXP__(); } 147 unsigned long int ?\?( unsigned int ep, unsigned int y ) { __CFA_EXP__(); } 148 unsigned long int ?\?( unsigned long int ep, unsigned long int y ) { __CFA_EXP__(); } 151 149 } // distribution 152 150 … … 159 157 160 158 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) { 161 OT ?\?( OT x, unsigned int y ) { __CFA_EXP__(); } 162 OT ?\?( OT x, unsigned long int y ) { __CFA_EXP__(); } 163 OT ?\?( OT x, unsigned long long int y ) { __CFA_EXP__(); } 159 OT ?\?( OT ep, unsigned int y ) { __CFA_EXP__(); } 160 OT ?\?( OT ep, unsigned long int y ) { __CFA_EXP__(); } 164 161 } // distribution 165 162 … … 169 166 170 167 static inline { 171 long int ?\=?( int & x, unsigned int y ) { x = x \ y; return x; }172 168 long int ?\=?( long int & x, unsigned long int y ) { x = x \ y; return x; } 173 long long int ?\=?( long long int & x, unsigned long long int y ) { x = x \ y; return x; }174 unsigned long int ?\=?( unsigned int & x, unsigned int y ) { x = x \ y; return x; }175 169 unsigned long int ?\=?( unsigned long int & x, unsigned long int y ) { x = x \ y; return x; } 176 unsigned long long int ?\=?( unsigned long long int & x, unsigned long long int y ) { x = x \ y; return x; } 170 int ?\=?( int & x, unsigned long int y ) { x = x \ y; return x; } 171 unsigned int ?\=?( unsigned int & x, unsigned long int y ) { x = x \ y; return x; } 177 172 } // distribution 178 173 -
libcfa/src/iostream.cfa
r47e000c r7f5683e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 13 13:05:24202113 // Update Count : 1 32412 // Last Modified On : Tue Mar 2 14:51:30 2021 13 // Update Count : 1151 14 14 // 15 15 … … 195 195 int len = snprintf( buf, size, format, ##__VA_ARGS__, val ); \ 196 196 fmt( os, "%s", buf ); \ 197 if ( isfinite( val ) ) { /* if number, print decimal point when no fraction or exponent */ \197 if ( isfinite( val ) ) { /* if number, always print decimal point */ \ 198 198 for ( int i = 0;; i += 1 ) { \ 199 199 if ( i == len ) { fmt( os, "." ); break; } \ 200 if ( buf[i] == '.' || buf[i] == 'e' || buf[i] == 'E' ) break; /* decimal point or scientific ? */\200 if ( buf[i] == '.' ) break; \ 201 201 } /* for */ \ 202 202 } /* if */ \ … … 525 525 } // distribution 526 526 527 IntegralFMTImpl( signed char, " *hh ", " *.*hh " ) 528 IntegralFMTImpl( unsigned char, " *hh ", " *.*hh " ) 529 IntegralFMTImpl( signed short int, " *h ", " *.*h " ) 530 IntegralFMTImpl( unsigned short int, " *h ", " *.*h " ) 531 IntegralFMTImpl( signed int, " * ", " *.* " ) 532 IntegralFMTImpl( unsigned int, " * ", " *.* " ) 533 IntegralFMTImpl( signed long int, " *l ", " *.*l " ) 534 IntegralFMTImpl( unsigned long int, " *l ", " *.*l " ) 535 IntegralFMTImpl( signed long long int, " *ll ", " *.*ll " ) 536 IntegralFMTImpl( unsigned long long int, " *ll ", " *.*ll " ) 537 538 527 IntegralFMTImpl( signed char, "% *hh ", "% *.*hh " ) 528 IntegralFMTImpl( unsigned char, "% *hh ", "% *.*hh " ) 529 IntegralFMTImpl( signed short int, "% *h ", "% *.*h " ) 530 IntegralFMTImpl( unsigned short int, "% *h ", "% *.*h " ) 531 IntegralFMTImpl( signed int, "% * ", "% *.* " ) 532 IntegralFMTImpl( unsigned int, "% * ", "% *.* " ) 533 IntegralFMTImpl( signed long int, "% *l ", "% *.*l " ) 534 IntegralFMTImpl( unsigned long int, "% *l ", "% *.*l " ) 535 IntegralFMTImpl( signed long long int, "% *ll ", "% *.*ll " ) 536 IntegralFMTImpl( unsigned long long int, "% *ll ", "% *.*ll " ) 537 538 #if 0 539 #if defined( __SIZEOF_INT128__ ) 540 // Default prefix for non-decimal prints is 0b, 0, 0x. 541 #define IntegralFMTImpl128( T, SIGNED, CODE, IFMTNP, IFMTP ) \ 542 forall( ostype & | ostream( ostype ) ) \ 543 static void base10_128( ostype & os, _Ostream_Manip(T) f ) { \ 544 if ( f.val > UINT64_MAX ) { \ 545 unsigned long long int lsig = f.val % P10_UINT64; \ 546 f.val /= P10_UINT64; /* msig */ \ 547 base10_128( os, f ); /* recursion */ \ 548 _Ostream_Manip(unsigned long long int) fmt @= { lsig, 0, 19, 'u', { .all : 0 } }; \ 549 fmt.flags.nobsdp = true; \ 550 /* printf( "fmt1 %c %lld %d\n", fmt.base, fmt.val, fmt.all ); */ \ 551 sepOff( os ); \ 552 (ostype &)(os | fmt); \ 553 } else { \ 554 /* printf( "fmt2 %c %lld %d\n", f.base, (unsigned long long int)f.val, f.all ); */ \ 555 _Ostream_Manip(SIGNED long long int) fmt @= { (SIGNED long long int)f.val, f.wd, f.pc, f.base, { .all : f.all } }; \ 556 (ostype &)(os | fmt); \ 557 } /* if */ \ 558 } /* base10_128 */ \ 559 forall( ostype & | ostream( ostype ) ) { \ 560 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 561 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 562 \ 563 if ( f.base == 'b' | f.base == 'B' | f.base == 'o' | f.base == 'x' | f.base == 'X' ) { \ 564 unsigned long long int msig = (unsigned long long int)(f.val >> 64); \ 565 unsigned long long int lsig = (unsigned long long int)(f.val); \ 566 _Ostream_Manip(SIGNED long long int) fmt @= { msig, f.wd, f.pc, f.base, { .all : f.all } }; \ 567 _Ostream_Manip(unsigned long long int) fmt2 @= { lsig, 0, 0, f.base, { .all : 0 } }; \ 568 if ( msig == 0 ) { \ 569 fmt.val = lsig; \ 570 (ostype &)(os | fmt); \ 571 } else { \ 572 fmt2.flags.pad0 = fmt2.flags.nobsdp = true; \ 573 if ( f.base == 'b' | f.base == 'B' ) { \ 574 if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; else { fmt.flags.pc = false; fmt.pc = 0; } \ 575 if ( fmt.flags.left ) { \ 576 fmt.flags.left = false; \ 577 fmt.wd = 0; \ 578 /* printf( "L %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \ 579 fmt2.flags.left = true; \ 580 int msigd = high1( msig ); \ 581 fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \ 582 if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; /* compensate for 0b base specifier */ \ 583 if ( (int)fmt2.wd < 64 ) fmt2.wd = 64; /* cast deals with negative value */ \ 584 fmt2.flags.pc = true; fmt2.pc = 64; \ 585 } else { \ 586 if ( fmt.wd > 64 ) fmt.wd -= 64; \ 587 else fmt.wd = 1; \ 588 /* printf( "R %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \ 589 fmt2.wd = 64; \ 590 } /* if */ \ 591 /* printf( "C %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \ 592 (ostype &)(os | fmt | "" | fmt2); \ 593 } else if ( f.base == 'o' ) { \ 594 if ( fmt.flags.pc && fmt.pc > 22 ) fmt.pc -= 22; else { fmt.flags.pc = false; fmt.pc = 0; } \ 595 fmt.val = (unsigned long long int)fmt.val >> 2; \ 596 fmt2.val = ((msig & 0x3) << 1) + ((lsig & 0x8000000000000000U) != 0); \ 597 if ( fmt.flags.left ) { \ 598 fmt.flags.left = false; \ 599 fmt.wd = 0; \ 600 /* printf( "L %llo %llo %llo %d %d '%c' %x %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all, fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \ 601 (ostype &)(os | fmt | "" | fmt2); \ 602 sepOff( os ); \ 603 fmt2.flags.left = true; \ 604 int msigd = ceiling_div( high1( fmt.val ), 3 ); \ 605 fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \ 606 if ( ! fmt.flags.nobsdp ) fmt2.wd -= 1; /* compensate for 0 base specifier */ \ 607 if ( (int)fmt2.wd < 21 ) fmt2.wd = 21; /* cast deals with negative value */ \ 608 fmt2.flags.pc = true; fmt2.pc = 21; \ 609 } else { \ 610 if ( fmt.wd > 22 ) fmt.wd -= 22; \ 611 else fmt.wd = 1; \ 612 /* printf( "R %llo %llo %llo %d %d '%c' %x %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all, fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \ 613 (ostype &)(os | fmt | "" | fmt2); \ 614 sepOff( os ); \ 615 fmt2.wd = 21; \ 616 } /* if */ \ 617 fmt2.val = lsig & 0x7fffffffffffffffU; \ 618 /* printf( "\nC %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \ 619 (ostype &)(os | fmt2); \ 620 } else { /* f.base == 'x' | f.base == 'X' */ \ 621 if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; else { fmt.flags.pc = false; fmt.pc = 0; } \ 622 if ( fmt.flags.left ) { \ 623 fmt.flags.left = false; \ 624 fmt.wd = 0; \ 625 /* printf( "L %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \ 626 fmt2.flags.left = true; \ 627 int msigd = high1( msig ); \ 628 fmt2.wd = f.wd - (fmt.pc > msigd ? fmt.pc : msigd); \ 629 if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; /* compensate for 0x base specifier */ \ 630 if ( (int)fmt2.wd < 16 ) fmt2.wd = 16; /* cast deals with negative value */ \ 631 fmt2.flags.pc = true; fmt2.pc = 16; \ 632 } else { \ 633 if ( fmt.wd > 16 ) fmt.wd -= 16; \ 634 else fmt.wd = 1; \ 635 /* printf( "R %llo %llo %llo %d %d '%c' %x\n", msig, lsig, fmt.val, fmt.wd, fmt.pc, fmt.base, fmt.all ); */ \ 636 fmt2.wd = 16; \ 637 } /* if */ \ 638 /* printf( "C %llo %d %d '%c' %x\n", fmt2.val, fmt2.wd, fmt2.pc, fmt2.base, fmt2.all ); */ \ 639 (ostype &)(os | fmt | "" | fmt2); \ 640 } /* if */ \ 641 } /* if */ \ 642 } else { \ 643 if ( CODE == 'd' ) { \ 644 if ( f.val < 0 ) { fmt( os, "-" ); sepOff( os ); f.val = -f.val; f.flags.sign = false; } \ 645 } /* if */ \ 646 base10_128( os, f ); \ 647 } /* if */ \ 648 return os; \ 649 } /* ?|? */ \ 650 void ?|?( ostype & os, _Ostream_Manip(T) f ) { (ostype &)(os | f); ends( os ); } \ 651 } // distribution 652 653 IntegralFMTImpl128( int128, signed, 'd', "% *ll ", "% *.*ll " ) 654 IntegralFMTImpl128( unsigned int128, unsigned, 'u', "% *ll ", "% *.*ll " ) 655 #endif // __SIZEOF_INT128__ 656 #endif // 0 657 658 #if 1 539 659 #if defined( __SIZEOF_INT128__ ) 540 660 // Default prefix for non-decimal prints is 0b, 0, 0x. … … 626 746 IntegralFMTImpl128( unsigned int128 ) 627 747 #endif // __SIZEOF_INT128__ 748 #endif // 0 628 749 629 750 // *********************************** floating point *********************************** 630 751 631 static const char *suffixes[] = { 632 "y", "z", "a", "f", "p", "n", "u", "m", "", 633 "K", "M", "G", "T", "P", "E", "Z", "Y" 634 }; 635 #define SUFFIXES_START (-24) /* Smallest power for which there is a suffix defined. */ 636 #define SUFFIXES_END (SUFFIXES_START + (int)((sizeof(suffixes) / sizeof(char *) - 1) * 3)) 637 638 #define PrintWithDP2( os, format, ... ) \ 752 #define PrintWithDP2( os, format, val, ... ) \ 639 753 { \ 640 if ( ! f.flags.eng ) {\641 len = snprintf( buf, size, format, ##__VA_ARGS__ ); \642 if ( isfinite( f.val ) && ( f.pc != 0 || ! f.flags.nobsdp ) ) { /* if number, print decimal point when no fraction or exponent */\643 for ( i = 0; i < len && buf[i] != '.' && buf[i] != 'e' && buf[i] != 'E'; i += 1 ); /* decimal point or scientific ?*/ \644 if ( i == len ) {\645 if ( ! f.flags.left) { \646 buf[i] = '.'; buf[i + 1] = '\0';\647 if ( buf[0] == ' ' ) bufbeg = 1; /* decimal point within width */\648 } else {\649 for ( i = 0; i < len && buf[i] != ' '; i += 1 ); /* trailing blank ? */\650 buf[i] = '.';\651 if ( i == len ) buf[i + 1] = '\0'; \652 } /* if */\754 enum { size = 48 }; \ 755 char buf[size]; \ 756 int bufbeg = 0, i, len = snprintf( buf, size, format, ##__VA_ARGS__, val ); \ 757 if ( isfinite( val ) && (f.base != 'g' || f.pc != 0) ) { /* if number, print decimal point */ \ 758 for ( i = 0; i < len && buf[i] != '.' && buf[i] != 'e' && buf[i] != 'E'; i += 1 ); /* decimal point or scientific ? */ \ 759 if ( i == len && ! f.flags.nobsdp ) { \ 760 if ( ! f.flags.left ) { \ 761 buf[i] = '.'; buf[i + 1] = '\0'; \ 762 if ( buf[0] == ' ' ) bufbeg = 1; /* decimal point within width */ \ 763 } else { \ 764 for ( i = 0; i < len && buf[i] != ' '; i += 1 ); /* trailing blank ? */ \ 765 buf[i] = '.'; \ 766 if ( i == len ) buf[i + 1] = '\0'; \ 653 767 } /* if */ \ 654 768 } /* if */ \ 655 } else { \656 int exp10, len2; \657 eng( f.val, f.pc, exp10 ); /* changes arguments */ \658 if ( ! f.flags.left && f.wd > 1 ) { \659 /* Exponent size (number of digits, 'e', optional minus sign) */ \660 f.wd -= lrint( floor( log10( abs( exp10 ) ) ) ) + 1 + 1 + (exp10 < 0 ? 1 : 0); \661 if ( f.wd < 1 ) f.wd = 1; \662 } /* if */ \663 len = snprintf( buf, size, format, ##__VA_ARGS__ ); \664 if ( f.flags.left ) { \665 for ( len -= 1; len > 0 && buf[len] == ' '; len -= 1 ); \666 len += 1; \667 } /* if */ \668 if ( ! f.flags.nobsdp || (exp10 < SUFFIXES_START) || (exp10 > SUFFIXES_END) ) { \669 len2 = snprintf( &buf[len], size - len, "e%d", exp10 ); \670 } else { \671 len2 = snprintf( &buf[len], size - len, "%s", suffixes[(exp10 - SUFFIXES_START) / 3] ); \672 } /* if */ \673 if ( f.flags.left && len + len2 < f.wd ) buf[len + len2] = ' '; \674 769 } /* if */ \ 675 770 fmt( os, "%s", &buf[bufbeg] ); \ … … 678 773 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \ 679 774 forall( ostype & | ostream( ostype ) ) { \ 680 static void eng( T &value, int & pc, int & exp10 ) { \681 exp10 = lrint( floor( log10( abs( value ) ) ) ); /* round to desired precision */ \682 if ( exp10 < 0 ) exp10 -= 2; \683 exp10 = floor( exp10, 3 ); \684 value *= pow( 10.0, -exp10 ); \685 if ( pc <= 3 ) pc = 3; \686 } /* eng */ \687 \688 775 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 689 enum { size = 48 }; \690 char buf[size]; \691 int bufbeg = 0, i, len; \692 \693 776 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 694 char fmtstr[sizeof(DFMTP) + 8];/* sizeof includes '\0' */ \777 char fmtstr[sizeof(DFMTP)]; /* sizeof includes '\0' */ \ 695 778 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ 696 779 else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \ … … 706 789 fmtstr[sizeof(DFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 707 790 /* printf( "%g %d %s\n", f.val, f.wd, &fmtstr[star]); */ \ 708 PrintWithDP2( os, &fmtstr[star], f. wd, f.val) \791 PrintWithDP2( os, &fmtstr[star], f.val, f.wd ) \ 709 792 } else { /* precision */ \ 710 793 fmtstr[sizeof(DFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 711 794 /* printf( "%g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \ 712 PrintWithDP2( os, &fmtstr[star], f. wd, f.pc, f.val) \795 PrintWithDP2( os, &fmtstr[star], f.val, f.wd, f.pc ) \ 713 796 } /* if */ \ 714 797 return os; \ … … 718 801 } // distribution 719 802 720 FloatingPointFMTImpl( double, " * ", "*.* " )721 FloatingPointFMTImpl( long double, " *L ", "*.*L " )803 FloatingPointFMTImpl( double, "% * ", "% *.* " ) 804 FloatingPointFMTImpl( long double, "% *L ", "% *.*L " ) 722 805 723 806 // *********************************** character *********************************** -
libcfa/src/iostream.hfa
r47e000c r7f5683e 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 13 13:05:11202113 // Update Count : 3 8412 // Last Modified On : Tue Mar 2 14:05:08 2021 13 // Update Count : 369 14 14 // 15 15 … … 158 158 struct _Ostream_Manip { 159 159 T val; // polymorphic base-type 160 int wd, pc;// width, precision160 unsigned int wd, pc; // width, precision 161 161 char base; // numeric base / floating-point style 162 162 union { 163 163 unsigned char all; 164 164 struct { 165 unsigned char eng:1; // engineering notation166 165 unsigned char neg:1; // val is negative 167 166 unsigned char pc:1; // precision specified … … 223 222 _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \ 224 223 _Ostream_Manip(T) sci( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'e', { .all : 0 } }; } \ 225 _Ostream_Manip(T) eng( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.eng : true } }; } \ 226 _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'g', { .all : 0 } }; } \ 224 _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'f', { .all : 0 } }; } \ 227 225 _Ostream_Manip(T) wd( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \ 228 226 _Ostream_Manip(T) ws( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'g', { .flags.pc : true } }; } \ 229 _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; return fmt; } \ 230 _Ostream_Manip(T) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { if ( fmt.flags.eng ) fmt.base = 'f'; fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \ 231 _Ostream_Manip(T) & ws( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \ 227 _Ostream_Manip(T) & wd( unsigned int w, _Ostream_Manip(T) & fmt ) { fmt.wd = w; return fmt; } \ 228 _Ostream_Manip(T) & wd( unsigned int w, unsigned char pc, _Ostream_Manip(T) & fmt ) { fmt.wd = w; fmt.pc = pc; fmt.flags.pc = true; return fmt; } \ 232 229 _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \ 233 230 _Ostream_Manip(T) upcase( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'G', { .all : 0 } }; } \ … … 238 235 _Ostream_Manip(T) nodp( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \ 239 236 _Ostream_Manip(T) & nodp( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \ 240 _Ostream_Manip(T) unit( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \241 _Ostream_Manip(T) & unit( _Ostream_Manip(T) & fmt ) { fmt.flags.nobsdp = true; return fmt; } \242 237 } /* distribution */ \ 243 238 forall( ostype & | ostream( ostype ) ) { \ -
libcfa/src/math.hfa
r47e000c r7f5683e 10 10 // Created On : Mon Apr 18 23:37:04 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon A pr 12 18:35:39 202113 // Update Count : 1 3112 // Last Modified On : Mon Aug 24 08:56:20 2020 13 // Update Count : 126 14 14 // 15 15 … … 100 100 long double _Complex log( long double _Complex x ) { return clogl( x ); } 101 101 102 // O(1) polymorphic integer log2, using clz, which returns the number of leading 0-bits, starting at the most103 // significant bit (single instruction on x86)104 int log2( unsigned int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clz( n ); }105 long int log2( unsigned long int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clzl( n ); }106 long long int log2( unsigned long long int n ) { return n == 0 ? -1 : sizeof(n) * __CHAR_BIT__ - 1 - __builtin_clzl( n ); }107 102 float log2( float x ) { return log2f( x ); } 108 103 // extern "C" { double log2( double ); } -
tests/.expect/KRfunctions.nast.x64.txt
r47e000c r7f5683e 104 104 signed int _X1bi_2; 105 105 { 106 signed int *(*_tmp_cp_ret 6)(signed int __param_0, signed int __param_1);107 ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret 6=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret6)));106 signed int *(*_tmp_cp_ret4)(signed int __param_0, signed int __param_1); 107 ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret4=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret4))); 108 108 } 109 109 -
tests/.expect/declarationSpecifier.x64.txt
r47e000c r7f5683e 1147 1147 1148 1148 { 1149 signed int _tmp_cp_ret 6;1150 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret 6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);1149 signed int _tmp_cp_ret4; 1150 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret4=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret4)) /* ?{} */); 1151 1151 } 1152 1152 -
tests/.expect/extension.x64.txt
r47e000c r7f5683e 457 457 458 458 { 459 signed int _tmp_cp_ret 6;460 ((void)(((void)(_tmp_cp_ret 6=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret6));459 signed int _tmp_cp_ret4; 460 ((void)(((void)(_tmp_cp_ret4=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret4)); 461 461 } 462 462 -
tests/.expect/gccExtensions.x64.txt
r47e000c r7f5683e 339 339 340 340 { 341 signed int _tmp_cp_ret 6;342 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret 6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);341 signed int _tmp_cp_ret4; 342 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret4=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret4)) /* ?{} */); 343 343 } 344 344 -
tests/.expect/math.nast.x64.txt
r47e000c r7f5683e 17 17 4 16 18 18 log:0. 0. 0. 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i 19 log2:10 17 2320 log2:10 17 2321 log2:10 17 2322 log2:10. 17. 23.23 19 log2:3. 3. 3. 24 20 log10:2. 2. 2. -
tests/io/.expect/manipulatorsOutput1.x64.txt
r47e000c r7f5683e 29 29 float 30 30 0 3 3.00000 3.537 3.537 4 4. 3.5 3.5 3 3.5 3.5 +3.5 +3.5 000003.5 3.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+00 31 0. 3. 3 3.537 3.537 4.4 3.5 3.5 3. 3.5 3.5 +3.5 +3.5 000003.5 3.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+0031 0. 3.000000 3.000000 3.537 3.537000 4 4 3.5 3.5 3. 3.5 3.5 +3.5 +3.5 000003.5 3.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+00 32 32 double 33 0 3 3.00000 3.537 3.537 4 4. 3.5 3.5 3 3.5 3.5 +3.5 +3.5 000003.53.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+0034 0. 3. 3 3.537 3.537 4. 4 3.5 3.5 3. 3.5 3.5 +3.5 +3.5 000003.53.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+0033 0 3.000000 3.537 3.537000 4. 4 3.54 3.54 +3.54 00003.54 3.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+00 34 0. 3.000000 3.537 3.537000 4 4. 3.54 3.54 +3.54 00003.54 3.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+00 35 35 long double 36 0 3 3.00000 3.537 3.537 4 4. 3.5 3.5 3 3.5 3.5 +3.5 +3.5 000003.53.54E+00 0xe.26p-2 0XE.26P-2 3.54e+0037 0. 3. 3 3.53699999999999992 3.537 4. 4 3.5 3.5 3. 3.5 3.5 +3.5 +3.5 000003.53.54E+00 0xe.26p-2 0XE.26P-2 3.54e+0036 0 3.000000 3.537 3.537000 4. 4 3.54 3.54 +3.54 00003.54 3.54E+00 0xe.26p-2 0XE.26P-2 3.54e+00 37 0. 3.000000 3.53699999999999992 3.537000 4 4. 3.54 3.54 +3.54 00003.54 3.54E+00 0xe.26p-2 0XE.26P-2 3.54e+00 38 38 39 39 char -
tests/io/.expect/manipulatorsOutput2.x64.txt
r47e000c r7f5683e 9 9 -0x1.b8p+4 -0x1.b8p+4 -0xd.cp+1 10 10 0.000000e+00 2.750000e+01 -2.750000e+01 11 0e0 27.5e0 -27.5e012 11 0B11011 0X1B 2.75E-09 0X1.B8P+4 13 12 11011 33 1b 14 13 0. 0 27. 27 27.5 15 +27 -27 +27 . -27.+27.5 -27.514 +27 -27 +27 -27 +27.5 -27.5 16 15 34 34 34 17 4. 4. 4.16 4.000000 4.000000 4.000000 18 17 ab ab ab 19 18 34567 34567 34567 20 3456. 3456. 3456.19 3456.000000 3456.000000 3456.000000 21 20 abcde abcde abcde 22 21 034 0034 0000000034 … … 25 24 27.500 27.5 28. 27.50000000 26 25 27.000 27.500 27.5 28. 27.50000000 27 27 27. 27.5027 27.50026 27 27.000000 27.500000 027 27.500 28 27 234.567 234.57 234.6 235. 29 28 234567. 2.3457e+05 2.346e+05 2.35e+05 -
tests/io/manipulatorsOutput1.cfa
r47e000c r7f5683e 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Sat Apr 10 08:42:15 202110 // Update Count : 189 // Last Modified On : Fri May 1 11:51:44 2020 10 // Update Count : 9 11 11 // 12 12 … … 85 85 sout | "double"; 86 86 double d = 3.537; 87 printf( "%g %8g %#8g %g %8g %8.0g %#8.0g %8.2g %#8.2g %-8.2g %-8.2g %-#8.2g %-+8.2g %-+#8.2g %08.2g %8.2E %8.2a %#8.2A %#8.2e\n", 88 0.0, 3.0, 3.0, d, d, d, d, d, d, 3.0, d, d, d, d, d, d, d, d, d ); 89 sout | 0.0 | wd(8, 3.0) | nodp(wd(8, 3.0)) | d | wd(8, d) | ws(8,0, d) | nodp(ws(8,0, d)) | ws(8,2, d) | nodp(ws(8,2, d)) | nonl; 90 sout | left(ws(8,2, 3.0)) | left(ws(8,2, d)) | left(nodp(ws(8,2, d))) | left(sign(ws(8,2, d))) | left(sign(nodp(ws(8,2, d)))) | nonl; 91 sout | pad0(ws(8,2, d)) | upcase(wd(8,2, sci(d))) | wd(8,2, hex(d)) | upcase(wd(8,2, hex(d))) | nodp(wd(8,2, sci(d))); 87 printf( "%g %#8f %g %8f %#8.0f %8.0f %8.2f %-8.2f %-+#8.2f %08.2F %8.2E %8.2a %8.2A %8.2e\n", 88 0.0, 3.0, d, d, d, d, d, d, d, d, d, d, d, d ); 89 sout | 0.0 | wd(8, 3.0) | d | wd(8, d) | nodp(wd(8,0, d)) | wd(8,0, d) | wd(8,2, d) | nonl; 90 sout | left(wd(8,2, d)) | left(sign(wd(8,2, d))) | pad0(upcase(wd(8,2, d))) | upcase(wd(8,2, sci(d))) | wd(8,2, hex(d)) | upcase(wd(8,2, hex(d))) | wd(8,2, sci(d)); 92 91 93 92 sout | "long double"; 94 93 long double ld = 3.537; 95 printf( "%Lg % 8Lg %#8Lg %Lg %8Lg %8.0Lg %#8.0Lg %8.2Lg %#8.2Lg %-8.2Lg %-8.2Lg %-#8.2Lg %-+8.2Lg %-+#8.2Lg %08.2Lg %8.2LE %8.2La %#8.2LA %#8.2Le\n",96 0.0L, 3.0L, 3.0L, ld, ld, ld, ld, ld, ld, 3.0L, ld, ld, ld, ld, ld, ld, ld, ld,ld );97 sout | 0.0L | wd(8, 3.0L) | nodp(wd(8, 3.0L)) | ld | wd(8, ld) | ws(8,0, ld) | nodp(ws(8,0, ld)) | ws(8,2, ld) | nodp(ws(8,2, ld)) | nonl;98 sout | left(w s(8,2, 3.0L)) | left(ws(8,2, ld)) | left(nodp(ws(8,2, ld))) | left(sign(ws(8,2, ld))) | left(sign(nodp(ws(8,2, ld)))) | nonl;99 sout | pad0(ws(8,2, ld)) | upcase(wd(8,2, sci(ld))) | wd(8,2, hex(ld)) | upcase(wd(8,2, hex(ld))) | nodp(wd(8,2, sci(ld))); 94 printf( "%Lg %#8Lf %Lg %8Lf %#8.0Lf %8.0Lf %8.2Lf %-8.2Lf %-+#8.2Lf %08.2LF %8.2LE %8.2La %8.2LA %8.2Le\n", 95 0.0L, 3.0L, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld, ld ); 96 sout | 0.0L | wd(8, 3.0L) | ld | wd(8, ld) | nodp(wd(8,0, ld)) | wd(8,0, ld) | wd(8,2, ld) | nonl; 97 sout | left(wd(8,2, ld)) | left(sign(wd(8,2, ld))) | pad0(upcase(wd(8,2, ld))) | upcase(wd(8,2, sci(ld))) | wd(8,2, hex(ld)) | upcase(wd(8,2, hex(ld))) | wd(8,2, sci(ld)); 98 100 99 101 100 sout | nl | "char"; … … 118 117 // Local Variables: // 119 118 // tab-width: 4 // 120 // compile-command: "cfa -Wall -Wextra manipulatorsOutput1.cfa" //119 // compile-command: "cfa -Wall -Wextra amanipulatorsOutput1.cfa" // 121 120 // End: // -
tests/io/manipulatorsOutput2.cfa
r47e000c r7f5683e 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : S at Apr 10 09:16:09 202110 // Update Count : 119 // Last Modified On : Sun Nov 15 08:11:53 2020 10 // Update Count : 9 11 11 // 12 12 … … 24 24 sout | hex(-27.5F) | hex(-27.5) | hex(-27.5L); 25 25 sout | sci(0.0) | sci(27.5) | sci(-27.5); 26 sout | eng(0.0) | eng(27.5) | eng(-27.5);27 26 sout | upcase(bin(27)) | upcase(hex(27)) | upcase(27.5e-10) | upcase(hex(27.5)); 28 27 sout | nobase(bin(27)) | nobase(oct(27)) | nobase(hex(27)); -
tests/io/manipulatorsOutput3.cfa
r47e000c r7f5683e 1 //2 // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo3 //4 // manipulatorsOutput3.cfa --5 //6 // Author : Peter A. Buhr7 // Created On : Tue Apr 13 17:54:23 20218 // Last Modified By : Peter A. Buhr9 // Last Modified On : Tue Apr 13 17:54:48 202110 // Update Count : 111 //12 13 1 #include <fstream.hfa> 14 2 -
tests/math.cfa
r47e000c r7f5683e 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 13 17:28:58 202113 // Update Count : 1 2212 // Last Modified On : Sat Feb 20 18:00:48 2021 13 // Update Count : 115 14 14 // 15 15 … … 69 69 sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | nonl; 70 70 sout | log( 1.0F+1.0FI ) | log( 1.0D+1.0DI ) | log( 1.0DL+1.0LI ); 71 sout | "log2:" | log2( 1024 ) | log2( 2 \ 17u ) | log2( 2 \ 23u );72 sout | "log2:" | log2( 1024l ) | log2( 2l \ 17u ) | log2( 2l \ 23u );73 sout | "log2:" | log2( 1024ll ) | log2( 2ll \ 17u ) | log2( 2ll \ 23u );74 sout | "log2:" | log2( 1024l128 ) | log2( 2l128 \ 17u ) | log2( 2l128 \ 23u );75 71 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ); 76 72 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ); -
tests/vector_math/.expect/vec4_float.txt
r47e000c r7f5683e 6 6 zero-assign:<0.,0.,0.,0.> 7 7 fill-ctor:<1.23,1.23,1.23,1.23> 8 ?-?:<0.02,0.43,-0.999998,-1e-06 >9 ?-=?:<0.02,0.43,-0.999998,-1e-06 >10 -?:<-0.02,-0.43,0.999998,1e-06 >8 ?-?:<0.02,0.43,-0.999998,-1e-06.> 9 ?-=?:<0.02,0.43,-0.999998,-1e-06.> 10 -?:<-0.02,-0.43,0.999998,1e-06.> 11 11 ?+?:<2.3,2.45,-9.2,-12.5> 12 12 ?+=?:<2.3,2.45,-9.2,-12.5>
Note: See TracChangeset
for help on using the changeset viewer.