Changes in / [7f5683e:47e000c]
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/pl.bib
r7f5683e r47e000c 1797 1797 } 1798 1798 1799 @article{Delisle2 0,1799 @article{Delisle21, 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,1805 1804 journal = spe, 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 = {}, 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}}, 1809 1811 } 1810 1812 -
libcfa/prelude/builtins.c
r7f5683e r47e000c 9 9 // Author : Peter A. Buhr 10 10 // Created On : Fri Jul 21 16:21:03 2017 11 // Last Modified By : Andrew Beach12 // Last Modified On : Tue Oct 27 14:42:00 202013 // Update Count : 11 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Apr 13 17:26:32 2021 13 // Update Count : 117 14 14 // 15 15 … … 125 125 } // distribution 126 126 127 #define __CFA_BASE_COMP_1__() if ( ep== 1 ) return 1128 #define __CFA_BASE_COMP_2__() if ( ep == 2 ) return ep<< (y - 1)127 #define __CFA_BASE_COMP_1__() if ( x == 1 ) return 1 128 #define __CFA_BASE_COMP_2__() if ( x == 2 ) return x << (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( ep) op = 1; /* accumulate odd product */ \136 typeof(x) op = 1; /* accumulate odd product */ \ 137 137 for ( ; y > 1; y >>= 1 ) { /* squaring exponentiation, O(log2 y) */ \ 138 if ( (y & 1) == 1 ) op = op * ep; /* odd ? */ \139 ep = ep * ep; \138 if ( (y & 1) == 1 ) op = op * x; /* odd ? */ \ 139 x = x * x; \ 140 140 } \ 141 return ep* op141 return x * op 142 142 143 143 static inline { 144 long int ?\?( int ep, unsigned int y ) { __CFA_EXP__(); } 145 long int ?\?( long int ep, unsigned long int y ) { __CFA_EXP__(); } 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__(); } 146 147 // unsigned computation may be faster and larger 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__(); } 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__(); } 149 151 } // distribution 150 152 … … 157 159 158 160 static inline forall( OT | { void ?{}( OT & this, one_t ); OT ?*?( OT, OT ); } ) { 159 OT ?\?( OT ep, unsigned int y ) { __CFA_EXP__(); } 160 OT ?\?( OT ep, unsigned long int y ) { __CFA_EXP__(); } 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__(); } 161 164 } // distribution 162 165 … … 166 169 167 170 static inline { 171 long int ?\=?( int & x, unsigned int y ) { x = x \ y; return x; } 168 172 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; } 169 175 unsigned long int ?\=?( unsigned long int & x, unsigned 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; } 176 unsigned long long int ?\=?( unsigned long long int & x, unsigned long long int y ) { x = x \ y; return x; } 172 177 } // distribution 173 178 -
libcfa/src/iostream.cfa
r7f5683e r47e000c 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 2 14:51:30202113 // Update Count : 1 15112 // Last Modified On : Tue Apr 13 13:05:24 2021 13 // Update Count : 1324 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, always print decimal point */ \197 if ( isfinite( val ) ) { /* if number, print decimal point when no fraction or exponent */ \ 198 198 for ( int i = 0;; i += 1 ) { \ 199 199 if ( i == len ) { fmt( os, "." ); break; } \ 200 if ( buf[i] == '.' ) break;\200 if ( buf[i] == '.' || buf[i] == 'e' || buf[i] == 'E' ) break; /* decimal point or scientific ? */ \ 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 #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 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 659 539 #if defined( __SIZEOF_INT128__ ) 660 540 // Default prefix for non-decimal prints is 0b, 0, 0x. … … 746 626 IntegralFMTImpl128( unsigned int128 ) 747 627 #endif // __SIZEOF_INT128__ 748 #endif // 0749 628 750 629 // *********************************** floating point *********************************** 751 630 752 #define PrintWithDP2( os, format, val, ... ) \ 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, ... ) \ 753 639 { \ 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';\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 */ \ 767 653 } /* if */ \ 768 654 } /* 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] = ' '; \ 769 674 } /* if */ \ 770 675 fmt( os, "%s", &buf[bufbeg] ); \ … … 773 678 #define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \ 774 679 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 \ 775 688 ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \ 689 enum { size = 48 }; \ 690 char buf[size]; \ 691 int bufbeg = 0, i, len; \ 692 \ 776 693 if ( $sepPrt( os ) ) fmt( os, "%s", $sepGetCur( os ) ); \ 777 char fmtstr[sizeof(DFMTP) ];/* sizeof includes '\0' */ \694 char fmtstr[sizeof(DFMTP) + 8]; /* sizeof includes '\0' */ \ 778 695 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ 779 696 else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \ … … 789 706 fmtstr[sizeof(DFMTNP)-2] = f.base; /* sizeof includes '\0' */ \ 790 707 /* printf( "%g %d %s\n", f.val, f.wd, &fmtstr[star]); */ \ 791 PrintWithDP2( os, &fmtstr[star], f. val, f.wd) \708 PrintWithDP2( os, &fmtstr[star], f.wd, f.val ) \ 792 709 } else { /* precision */ \ 793 710 fmtstr[sizeof(DFMTP)-2] = f.base; /* sizeof includes '\0' */ \ 794 711 /* printf( "%g %d %d %s\n", f.val, f.wd, f.pc, &fmtstr[star] ); */ \ 795 PrintWithDP2( os, &fmtstr[star], f. val, f.wd, f.pc) \712 PrintWithDP2( os, &fmtstr[star], f.wd, f.pc, f.val ) \ 796 713 } /* if */ \ 797 714 return os; \ … … 801 718 } // distribution 802 719 803 FloatingPointFMTImpl( double, " % * ", "%*.* " )804 FloatingPointFMTImpl( long double, " % *L ", "%*.*L " )720 FloatingPointFMTImpl( double, " * ", " *.* " ) 721 FloatingPointFMTImpl( long double, " *L ", " *.*L " ) 805 722 806 723 // *********************************** character *********************************** -
libcfa/src/iostream.hfa
r7f5683e r47e000c 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 2 14:05:08202113 // Update Count : 3 6912 // Last Modified On : Tue Apr 13 13:05:11 2021 13 // Update Count : 384 14 14 // 15 15 … … 158 158 struct _Ostream_Manip { 159 159 T val; // polymorphic base-type 160 unsigned int wd, pc;// width, precision160 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 notation 165 166 unsigned char neg:1; // val is negative 166 167 unsigned char pc:1; // precision specified … … 222 223 _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \ 223 224 _Ostream_Manip(T) sci( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'e', { .all : 0 } }; } \ 224 _Ostream_Manip(T) wd( unsigned int w, T val ) { return (_Ostream_Manip(T))@{ val, w, 0, 'f', { .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 } }; } \ 225 227 _Ostream_Manip(T) wd( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \ 226 228 _Ostream_Manip(T) ws( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'g', { .flags.pc : true } }; } \ 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; } \ 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; } \ 229 232 _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \ 230 233 _Ostream_Manip(T) upcase( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'G', { .all : 0 } }; } \ … … 235 238 _Ostream_Manip(T) nodp( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \ 236 239 _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; } \ 237 242 } /* distribution */ \ 238 243 forall( ostype & | ostream( ostype ) ) { \ -
libcfa/src/math.hfa
r7f5683e r47e000c 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 ug 24 08:56:20 202013 // Update Count : 1 2612 // Last Modified On : Mon Apr 12 18:35:39 2021 13 // Update Count : 131 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 most 103 // 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 ); } 102 107 float log2( float x ) { return log2f( x ); } 103 108 // extern "C" { double log2( double ); } -
tests/.expect/KRfunctions.nast.x64.txt
r7f5683e r47e000c 104 104 signed int _X1bi_2; 105 105 { 106 signed int *(*_tmp_cp_ret 4)(signed int __param_0, signed int __param_1);107 ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret 4=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret4)));106 signed int *(*_tmp_cp_ret6)(signed int __param_0, signed int __param_1); 107 ((void)(_X1xFPi_ii__2=(((void)(_tmp_cp_ret6=_X3f10FFPi_ii__iPiPid__1(3, (&_X1ai_2), (&_X1bi_2), 3.5))) , _tmp_cp_ret6))); 108 108 } 109 109 -
tests/.expect/declarationSpecifier.x64.txt
r7f5683e r47e000c 1147 1147 1148 1148 { 1149 signed int _tmp_cp_ret 4;1150 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret 4=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret4)) /* ?{} */);1149 signed int _tmp_cp_ret6; 1150 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */); 1151 1151 } 1152 1152 -
tests/.expect/extension.x64.txt
r7f5683e r47e000c 457 457 458 458 { 459 signed int _tmp_cp_ret 4;460 ((void)(((void)(_tmp_cp_ret 4=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret4));459 signed int _tmp_cp_ret6; 460 ((void)(((void)(_tmp_cp_ret6=__extension__ _X4fredFi_i__1(3))) , _tmp_cp_ret6)); 461 461 } 462 462 -
tests/.expect/gccExtensions.x64.txt
r7f5683e r47e000c 339 339 340 340 { 341 signed int _tmp_cp_ret 4;342 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret 4=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret4)) /* ?{} */);341 signed int _tmp_cp_ret6; 342 ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */); 343 343 } 344 344 -
tests/.expect/math.nast.x64.txt
r7f5683e r47e000c 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 23 20 log2:10 17 23 21 log2:10 17 23 22 log2:10. 17. 23. 19 23 log2:3. 3. 3. 20 24 log10:2. 2. 2. -
tests/io/.expect/manipulatorsOutput1.x64.txt
r7f5683e r47e000c 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.000000 3.000000 3.537 3.537000 44 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. 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+00 32 32 double 33 0 3.000000 3.537 3.537000 4. 4 3.54 3.54 +3.54 00003.543.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+0034 0. 3.000000 3.537 3.537000 4 4. 3.54 3.54 +3.54 00003.543.54E+00 0x1.c5p+1 0X1.C5P+1 3.54e+0033 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 34 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+00 35 35 long double 36 0 3.000000 3.537 3.537000 4. 4 3.54 3.54 +3.54 00003.543.54E+00 0xe.26p-2 0XE.26P-2 3.54e+0037 0. 3.000000 3.53699999999999992 3.537000 4 4. 3.54 3.54 +3.54 00003.543.54E+00 0xe.26p-2 0XE.26P-2 3.54e+0036 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 0xe.26p-2 0XE.26P-2 3.54e+00 37 0. 3. 3 3.53699999999999992 3.537 4. 4 3.5 3.5 3. 3.5 3.5 +3.5 +3.5 000003.5 3.54E+00 0xe.26p-2 0XE.26P-2 3.54e+00 38 38 39 39 char -
tests/io/.expect/manipulatorsOutput2.x64.txt
r7f5683e r47e000c 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.5e0 11 12 0B11011 0X1B 2.75E-09 0X1.B8P+4 12 13 11011 33 1b 13 14 0. 0 27. 27 27.5 14 +27 -27 +27 -27+27.5 -27.515 +27 -27 +27. -27. +27.5 -27.5 15 16 34 34 34 16 4.000000 4.000000 4.00000017 4. 4. 4. 17 18 ab ab ab 18 19 34567 34567 34567 19 3456. 000000 3456.000000 3456.00000020 3456. 3456. 3456. 20 21 abcde abcde abcde 21 22 034 0034 0000000034 … … 24 25 27.500 27.5 28. 27.50000000 25 26 27.000 27.500 27.5 28. 27.50000000 26 27 27. 000000 27.500000027 27.50027 27 27. 27.5 027 27.500 27 28 234.567 234.57 234.6 235. 28 29 234567. 2.3457e+05 2.346e+05 2.35e+05 -
tests/io/manipulatorsOutput1.cfa
r7f5683e r47e000c 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Fri May 1 11:51:44 202010 // Update Count : 99 // Last Modified On : Sat Apr 10 08:42:15 2021 10 // Update Count : 18 11 11 // 12 12 … … 85 85 sout | "double"; 86 86 double d = 3.537; 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)); 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))); 91 92 92 93 sout | "long double"; 93 94 long double ld = 3.537; 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(w d(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 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(ws(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))); 99 100 100 101 sout | nl | "char"; … … 117 118 // Local Variables: // 118 119 // tab-width: 4 // 119 // compile-command: "cfa -Wall -Wextra amanipulatorsOutput1.cfa" //120 // compile-command: "cfa -Wall -Wextra manipulatorsOutput1.cfa" // 120 121 // End: // -
tests/io/manipulatorsOutput2.cfa
r7f5683e r47e000c 7 7 // Created On : Sat Jun 8 18:04:11 2019 8 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : S un Nov 15 08:11:53 202010 // Update Count : 99 // Last Modified On : Sat Apr 10 09:16:09 2021 10 // Update Count : 11 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); 26 27 sout | upcase(bin(27)) | upcase(hex(27)) | upcase(27.5e-10) | upcase(hex(27.5)); 27 28 sout | nobase(bin(27)) | nobase(oct(27)) | nobase(hex(27)); -
tests/io/manipulatorsOutput3.cfa
r7f5683e r47e000c 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo 3 // 4 // manipulatorsOutput3.cfa -- 5 // 6 // Author : Peter A. Buhr 7 // Created On : Tue Apr 13 17:54:23 2021 8 // Last Modified By : Peter A. Buhr 9 // Last Modified On : Tue Apr 13 17:54:48 2021 10 // Update Count : 1 11 // 12 1 13 #include <fstream.hfa> 2 14 -
tests/math.cfa
r7f5683e r47e000c 10 10 // Created On : Fri Apr 22 14:59:21 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Feb 20 18:00:48 202113 // Update Count : 1 1512 // Last Modified On : Tue Apr 13 17:28:58 2021 13 // Update Count : 122 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 ); 71 75 sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L ); 72 76 sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L ); -
tests/vector_math/.expect/vec4_float.txt
r7f5683e r47e000c 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.