Changes in / [7f5683e:47e000c]


Ignore:
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    r7f5683e r47e000c  
    17971797}
    17981798
    1799 @article{Delisle20,
     1799@article{Delisle21,
    18001800    keywords    = {concurrency, Cforall},
    18011801    contributer = {pabuhr@plg},
    18021802    author      = {Thierry Delisle and Peter A. Buhr},
    18031803    title       = {Advanced Control-flow and Concurrency in \textsf{C}$\mathbf{\forall}$},
    1804     year        = 2020,
    18051804    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}},
    18091811}
    18101812
  • libcfa/prelude/builtins.c

    r7f5683e r47e000c  
    99// Author           : Peter A. Buhr
    1010// Created On       : Fri Jul 21 16:21:03 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Oct 27 14:42:00 2020
    13 // Update Count     : 111
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Tue Apr 13 17:26:32 2021
     13// Update Count     : 117
    1414//
    1515
     
    125125} // distribution
    126126
    127 #define __CFA_BASE_COMP_1__() if ( ep == 1 ) return 1
    128 #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)
    129129#define __CFA_EXP_OVERFLOW__() if ( y >= sizeof(y) * CHAR_BIT ) return 0
    130130
     
    134134        __CFA_BASE_COMP_2__();                                                          /* special case, positive shifting for integral types */ \
    135135        __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 */ \
    137137        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; \
    140140        } \
    141         return ep * op
     141        return x * op
    142142
    143143static 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__(); }
    146147        // 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__(); }
    149151} // distribution
    150152
     
    157159
    158160static 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__(); }
    161164} // distribution
    162165
     
    166169
    167170static inline {
     171        long int ?\=?( int & x, unsigned int y ) { x = x \ y; return x; }
    168172        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; }
    169175        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; }
    172177} // distribution
    173178
  • libcfa/src/iostream.cfa

    r7f5683e r47e000c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  2 14:51:30 2021
    13 // Update Count     : 1151
     12// Last Modified On : Tue Apr 13 13:05:24 2021
     13// Update Count     : 1324
    1414//
    1515
     
    195195                        int len = snprintf( buf, size, format, ##__VA_ARGS__, val ); \
    196196                        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 */ \
    198198                                for ( int i = 0;; i += 1 ) { \
    199199                                        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 ? */ \
    201201                                } /* for */ \
    202202                        } /* if */ \
     
    525525} // distribution
    526526
    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
     527IntegralFMTImpl( signed char, "     *hh ", "     *.*hh " )
     528IntegralFMTImpl( unsigned char, "     *hh ", "     *.*hh " )
     529IntegralFMTImpl( signed short int, "     *h ", "     *.*h " )
     530IntegralFMTImpl( unsigned short int, "     *h ", "     *.*h " )
     531IntegralFMTImpl( signed int, "     * ", "     *.* " )
     532IntegralFMTImpl( unsigned int, "     * ", "     *.* " )
     533IntegralFMTImpl( signed long int, "     *l ", "     *.*l " )
     534IntegralFMTImpl( unsigned long int, "     *l ", "     *.*l " )
     535IntegralFMTImpl( signed long long int, "     *ll ", "     *.*ll " )
     536IntegralFMTImpl( unsigned long long int, "     *ll ", "     *.*ll " )
     537
     538
    659539#if defined( __SIZEOF_INT128__ )
    660540// Default prefix for non-decimal prints is 0b, 0, 0x.
     
    746626IntegralFMTImpl128( unsigned int128 )
    747627#endif // __SIZEOF_INT128__
    748 #endif // 0
    749628
    750629// *********************************** floating point ***********************************
    751630
    752 #define PrintWithDP2( os, format, val, ... ) \
     631static 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, ... ) \
    753639        { \
    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 */ \
    767653                                } /* if */ \
    768654                        } /* 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] = ' '; \
    769674                } /* if */ \
    770675                fmt( os, "%s", &buf[bufbeg] ); \
     
    773678#define FloatingPointFMTImpl( T, DFMTNP, DFMTP ) \
    774679forall( 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\
    775688        ostype & ?|?( ostype & os, _Ostream_Manip(T) f ) { \
     689                enum { size = 48 }; \
     690                char buf[size]; \
     691                int bufbeg = 0, i, len; \
     692\
    776693                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' */ \
    778695                if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \
    779696                else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \
     
    789706                        fmtstr[sizeof(DFMTNP)-2] = f.base;                      /* sizeof includes '\0' */ \
    790707                        /* 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 ) \
    792709                } else {                                                                                /* precision */ \
    793710                        fmtstr[sizeof(DFMTP)-2] = f.base;                       /* sizeof includes '\0' */ \
    794711                        /* 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 ) \
    796713                } /* if */ \
    797714                return os; \
     
    801718} // distribution
    802719
    803 FloatingPointFMTImpl( double, "%    * ", "%    *.* " )
    804 FloatingPointFMTImpl( long double, "%    *L ", "%    *.*L " )
     720FloatingPointFMTImpl( double, "     * ", "     *.* " )
     721FloatingPointFMTImpl( long double, "     *L ", "     *.*L " )
    805722
    806723// *********************************** character ***********************************
  • libcfa/src/iostream.hfa

    r7f5683e r47e000c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  2 14:05:08 2021
    13 // Update Count     : 369
     12// Last Modified On : Tue Apr 13 13:05:11 2021
     13// Update Count     : 384
    1414//
    1515
     
    158158struct _Ostream_Manip {
    159159        T val;                                                                                          // polymorphic base-type
    160         unsigned int wd, pc;                                                            // width, precision
     160        int wd, pc;                                                                                     // width, precision
    161161        char base;                                                                                      // numeric base / floating-point style
    162162        union {
    163163                unsigned char all;
    164164                struct {
     165                        unsigned char eng:1;                                            // engineering notation
    165166                        unsigned char neg:1;                                            // val is negative
    166167                        unsigned char pc:1;                                                     // precision specified
     
    222223        _Ostream_Manip(T) hex( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'a', { .all : 0 } }; } \
    223224        _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 } }; } \
    225227        _Ostream_Manip(T) wd( unsigned int w, unsigned char pc, T val ) { return (_Ostream_Manip(T))@{ val, w, pc, 'f', { .flags.pc : true } }; } \
    226228        _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; } \
    229232        _Ostream_Manip(T) & left( _Ostream_Manip(T) & fmt ) { fmt.flags.left = true; return fmt; } \
    230233        _Ostream_Manip(T) upcase( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'G', { .all : 0 } }; } \
     
    235238        _Ostream_Manip(T) nodp( T val ) { return (_Ostream_Manip(T))@{ val, 1, 0, 'g', { .flags.nobsdp : true } }; } \
    236239        _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; } \
    237242} /* distribution */ \
    238243forall( ostype & | ostream( ostype ) ) { \
  • libcfa/src/math.hfa

    r7f5683e r47e000c  
    1010// Created On       : Mon Apr 18 23:37:04 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug 24 08:56:20 2020
    13 // Update Count     : 126
     12// Last Modified On : Mon Apr 12 18:35:39 2021
     13// Update Count     : 131
    1414//
    1515
     
    100100        long double _Complex log( long double _Complex x ) { return clogl( x ); }
    101101
     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 ); }
    102107        float log2( float x ) { return log2f( x ); }
    103108        // extern "C" { double log2( double ); }
  • tests/.expect/KRfunctions.nast.x64.txt

    r7f5683e r47e000c  
    104104    signed int _X1bi_2;
    105105    {
    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)));
     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)));
    108108    }
    109109
  • tests/.expect/declarationSpecifier.x64.txt

    r7f5683e r47e000c  
    11471147
    11481148    {
    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)) /* ?{} */);
     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)) /* ?{} */);
    11511151    }
    11521152
  • tests/.expect/extension.x64.txt

    r7f5683e r47e000c  
    457457
    458458    {
    459         signed int _tmp_cp_ret4;
    460         ((void)(((void)(_tmp_cp_ret4=__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));
    461461    }
    462462
  • tests/.expect/gccExtensions.x64.txt

    r7f5683e r47e000c  
    339339
    340340    {
    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)) /* ?{} */);
     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)) /* ?{} */);
    343343    }
    344344
  • tests/.expect/math.nast.x64.txt

    r7f5683e r47e000c  
    17174 16
    1818log:0. 0. 0. 0.346574+0.785398i 0.346573590279973+0.785398163397448i 0.346573590279972655+0.78539816339744831i
     19log2:10 17 23
     20log2:10 17 23
     21log2:10 17 23
     22log2:10. 17. 23.
    1923log2:3. 3. 3.
    2024log10:2. 2. 2.
  • tests/io/.expect/manipulatorsOutput1.x64.txt

    r7f5683e r47e000c  
    2929float
    30300         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        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
     310.       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
    3232double
    33 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
     33       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
     340.       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
    3535long double
    36 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
     36       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
     370.       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
    3838
    3939char
  • tests/io/.expect/manipulatorsOutput2.x64.txt

    r7f5683e r47e000c  
    99-0x1.b8p+4 -0x1.b8p+4 -0xd.cp+1
    10100.000000e+00 2.750000e+01 -2.750000e+01
     110e0 27.5e0 -27.5e0
    11120B11011 0X1B 2.75E-09 0X1.B8P+4
    121311011 33 1b
    13140. 0 27. 27 27.5
    14 +27 -27 +27 -27 +27.5 -27.5
     15+27 -27 +27. -27. +27.5 -27.5
    1516  34  34 34
    16   4.000000  4.000000 4.000000
     17        4.        4.       4.
    1718  ab  ab ab
    181934567 34567 34567
    19 3456.000000 3456.000000 3456.000000
     203456. 3456. 3456.
    2021abcde abcde abcde
    2122 034     0034 0000000034
     
    242527.500     27.5      28. 27.50000000
    252627.000 27.500     27.5      28. 27.50000000
    26 27   27.000000  27.500000  027  27.500   
     2727   27.        27.5       027  27.500   
    2728234.567 234.57  234.6   235.
    2829234567. 2.3457e+05 2.346e+05 2.35e+05
  • tests/io/manipulatorsOutput1.cfa

    r7f5683e r47e000c  
    77// Created On       : Sat Jun  8 18:04:11 2019
    88// Last Modified By : Peter A. Buhr
    9 // Last Modified On : Fri May  1 11:51:44 2020
    10 // Update Count     : 9
     9// Last Modified On : Sat Apr 10 08:42:15 2021
     10// Update Count     : 18
    1111//
    1212
     
    8585        sout | "double";
    8686        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)));
    9192
    9293        sout | "long double";
    9394        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(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 
     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)));
    99100
    100101        sout | nl | "char";
     
    117118// Local Variables: //
    118119// tab-width: 4 //
    119 // compile-command: "cfa -Wall -Wextra amanipulatorsOutput1.cfa" //
     120// compile-command: "cfa -Wall -Wextra manipulatorsOutput1.cfa" //
    120121// End: //
  • tests/io/manipulatorsOutput2.cfa

    r7f5683e r47e000c  
    77// Created On       : Sat Jun  8 18:04:11 2019
    88// Last Modified By : Peter A. Buhr
    9 // Last Modified On : Sun Nov 15 08:11:53 2020
    10 // Update Count     : 9
     9// Last Modified On : Sat Apr 10 09:16:09 2021
     10// Update Count     : 11
    1111//
    1212
     
    2424    sout | hex(-27.5F) | hex(-27.5) | hex(-27.5L);
    2525        sout | sci(0.0) | sci(27.5) | sci(-27.5);
     26        sout | eng(0.0) | eng(27.5) | eng(-27.5);
    2627        sout | upcase(bin(27)) | upcase(hex(27)) | upcase(27.5e-10) | upcase(hex(27.5));
    2728        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
    113#include <fstream.hfa>
    214
  • tests/math.cfa

    r7f5683e r47e000c  
    1010// Created On       : Fri Apr 22 14:59:21 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Feb 20 18:00:48 2021
    13 // Update Count     : 115
     12// Last Modified On : Tue Apr 13 17:28:58 2021
     13// Update Count     : 122
    1414//
    1515
     
    6969        sout | "log:" | log( 1.0F ) | log( 1.0D ) | log( 1.0L ) | nonl;
    7070        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 );
    7175        sout | "log2:" | log2( 8.0F ) | log2( 8.0D ) | log2( 8.0L );
    7276        sout | "log10:" | log10( 100.0F ) | log10( 100.0D ) | log10( 100.0L );
  • tests/vector_math/.expect/vec4_float.txt

    r7f5683e r47e000c  
    66zero-assign:<0.,0.,0.,0.>
    77fill-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>
    1111?+?:<2.3,2.45,-9.2,-12.5>
    1212?+=?:<2.3,2.45,-9.2,-12.5>
Note: See TracChangeset for help on using the changeset viewer.