Changeset d3261710 for libcfa/src
- Timestamp:
- Jan 20, 2022, 11:18:15 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 224916b
- Parents:
- 6117fc0 (diff), 6a33e40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- libcfa/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/random.hfa
r6117fc0 rd3261710 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // random.hfa -- 8 // 9 // Author : Peter A. Buhr 10 // Created On : Fri Jan 14 07:18:11 2022 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 14 07:18:58 2022 13 // Update Count : 1 14 // 15 1 16 #pragma once 2 17 3 18 #include <stdint.h> 4 19 5 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, return the current value, and compute6 // and store the nextvalue.20 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned 21 // (copied), and then compute and store the next random value. 7 22 23 #if defined(__SIZEOF_INT128__) 8 24 //-------------------------------------------------- 9 #if defined(__SIZEOF_INT128__)10 25 static inline uint64_t lehmer64( __uint128_t & state ) { 11 26 __uint128_t ret = state; … … 50 65 } xorwow__state_t; 51 66 52 / * The state array must be initialized to not be all zero in the first four words */67 // The state array must be initialized to not be all zero in the first four words. 53 68 static inline uint32_t xorwow( xorwow__state_t & state ) { 54 / * Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs" */69 // Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs". 55 70 uint32_t ret = state.a + state.counter; 56 71 uint32_t t = state.d; … … 84 99 #define D (16_l64u) 85 100 101 // Bi-directional LCG random-number generator 86 102 static inline uint32_t LCGBI_fwd( uint64_t & state ) { 87 103 state = (A * state + C) & (M - 1); -
libcfa/src/iostream.cfa
r6117fc0 rd3261710 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 17 16:38:32202213 // Update Count : 13 4912 // Last Modified On : Wed Jan 19 08:15:53 2022 13 // Update Count : 1352 14 14 // 15 15 … … 205 205 ostype & ?|?( ostype & os, float f ) { 206 206 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 207 PrintWithDP( os, "% g", f );207 PrintWithDP( os, "%'g", f ); 208 208 return os; 209 209 } // ?|? … … 214 214 ostype & ?|?( ostype & os, double d ) { 215 215 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 216 PrintWithDP( os, "% .*lg", d, DBL_DIG );216 PrintWithDP( os, "%'.*lg", d, DBL_DIG ); 217 217 return os; 218 218 } // ?|? … … 223 223 ostype & ?|?( ostype & os, long double ld ) { 224 224 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 225 PrintWithDP( os, "% .*Lg", ld, LDBL_DIG );225 PrintWithDP( os, "%'.*Lg", ld, LDBL_DIG ); 226 226 return os; 227 227 } // ?|? … … 233 233 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 234 234 // os | crealf( fc ) | nonl; 235 PrintWithDP( os, "% g", crealf( fc ) );236 PrintWithDP( os, "% +g", cimagf( fc ) );235 PrintWithDP( os, "%'g", crealf( fc ) ); 236 PrintWithDP( os, "%'+g", cimagf( fc ) ); 237 237 fmt( os, "i" ); 238 238 return os; … … 245 245 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 246 246 // os | creal( dc ) | nonl; 247 PrintWithDP( os, "% .*lg", creal( dc ), DBL_DIG );248 PrintWithDP( os, "% +.*lg", cimag( dc ), DBL_DIG );247 PrintWithDP( os, "%'.*lg", creal( dc ), DBL_DIG ); 248 PrintWithDP( os, "%'+.*lg", cimag( dc ), DBL_DIG ); 249 249 fmt( os, "i" ); 250 250 return os; … … 257 257 if ( sepPrt$( os ) ) fmt( os, "%s", sepGetCur$( os ) ); 258 258 // os | creall( ldc ) || nonl; 259 PrintWithDP( os, "% .*Lg", creall( ldc ), LDBL_DIG );260 PrintWithDP( os, "% +.*Lg", cimagl( ldc ), LDBL_DIG );259 PrintWithDP( os, "%'.*Lg", creall( ldc ), LDBL_DIG ); 260 PrintWithDP( os, "%'+.*Lg", cimagl( ldc ), LDBL_DIG ); 261 261 fmt( os, "i" ); 262 262 return os; … … 282 282 }; // mask 283 283 284 if ( s == 0p ) { fmt( os, "%s", "0p" ); return os; } // null pointer 284 285 if ( s[0] == '\0' ) { sepOff( os ); return os; } // null string => no separator 285 286 … … 693 694 if ( ! f.flags.pc ) memcpy( &fmtstr, DFMTNP, sizeof(DFMTNP) ); \ 694 695 else memcpy( &fmtstr, DFMTP, sizeof(DFMTP) ); \ 695 int star = 4; /* position before first '*' */ \696 int star = 5; /* position before first '*' */ \ 696 697 \ 697 698 /* Insert flags into spaces before '*', from right to left. */ \ … … 699 700 if ( f.flags.sign ) { fmtstr[star] = '+'; star -= 1; } \ 700 701 if ( f.flags.pad0 ) { fmtstr[star] = '0'; star -= 1; } \ 702 fmtstr[star] = '\''; star -= 1; /* locale */ \ 701 703 fmtstr[star] = '%'; \ 702 704 \ … … 716 718 } // distribution 717 719 718 FloatingPointFMTImpl( double, " * ", "*.* " )719 FloatingPointFMTImpl( long double, " *L ", "*.*L " )720 FloatingPointFMTImpl( double, " * ", " *.* " ) 721 FloatingPointFMTImpl( long double, " *L ", " *.*L " ) 720 722 721 723 // *********************************** character ***********************************
Note: See TracChangeset
for help on using the changeset viewer.