- Timestamp:
- Dec 7, 2024, 6:48:26 PM (11 days ago)
- Branches:
- master
- Children:
- 9f7285e
- Parents:
- 0b98381
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r0b98381 r6503ef4 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Aug 15 22:23:30202414 %% Update Count : 69 5713 %% Last Modified On : Sat Dec 7 16:53:37 2024 14 %% Update Count : 6970 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 454 454 The majority of these flags are used by \CFA developers, but some are occasionally useful to programmers. 455 455 Each option must be escaped with \Indexc{-XCFA}\index{transpiler option!-XCFA@{©-XCFA©}} to direct it to the \CFA compilation step, similar to the ©-Xlinker© flag for the linker, \eg: 456 \begin{lstlisting}[language=sh ]456 \begin{lstlisting}[language=sh,escapechar=§] 457 457 cfa §test§.cfa -CFA -XCFA -p # print translated code without printing the standard prelude 458 458 cfa §test§.cfa -XCFA -P -XCFA parse -XCFA -n # show program parse without prelude … … 607 607 C, \CC, and Java (and other programming languages) have \emph{no} exponentiation operator\index{exponentiation!operator}\index{operator!exponentiation}, \ie $x^y$, and instead use a routine, like \Indexc{pow(x,y)}, to perform the exponentiation operation. 608 608 \CFA extends the basic operators with the exponentiation operator ©?©\R{©\\©}©?©\index{?\\?@©?@\@?©} and ©?©\R{©\\©}©=?©\index{?\\=?@©@\@=?©}, as in, ©x ©\R{©\\©}© y© and ©x ©\R{©\\©}©= y©, which means $x^y$ and $x \leftarrow x^y$. 609 The priority of the exponentiation operator is between the cast and multiplicative operators, so that ©w * (int)x \ (int)y * z© is parenthesized as ©(w * (((int)x) \ ((int)y))) * z©.609 The priority of the exponentiation operator is between the cast and multiplicative operators, so ©-f(x) \ -g(y)© is parenthesized as ©(-f(x)) \ (-g(y))©. 610 610 611 611 There are exponentiation operators for integral and floating types, including the builtin \Index{complex} types. … … 9419 9419 The ©PRNG© types for sequential programs, including coroutining, are: 9420 9420 \begin{cfa} 9421 struct PRNG32 {}; §\C{// opaque type, no copy or assignment}§9422 void ?{}( PRNG32 & prng, uint32_t seed ); 9423 void ?{}( PRNG32 & prng ); §\C{// random seed}§9421 struct PRNG32 {}; §\C[3.5in]{// opaque type, no copy or assignment}§ 9422 void ?{}( PRNG32 & prng, uint32_t seed ); §\C{// fixed seed}§ 9423 void ?{}( PRNG32 & prng ); §\C{// random seed}§ 9424 9424 void set_seed( PRNG32 & prng, uint32_t seed ); §\C{// set seed}§ 9425 uint32_t get_seed( PRNG32 & prng ); §\C{// get seed}§9426 uint32_t prng( PRNG32 & prng ); §\C{// [0,UINT\_MAX]}§9427 uint32_t prng( PRNG32 & prng, uint32_t u ); 9425 uint32_t get_seed( PRNG32 & prng ); §\C{// get seed}§ 9426 uint32_t prng( PRNG32 & prng ); §\C{// [0,UINT\_MAX]}§ 9427 uint32_t prng( PRNG32 & prng, uint32_t u ); §\C{// [0,u)}§ 9428 9428 uint32_t prng( PRNG32 & prng, uint32_t l, uint32_t u ); §\C{// [l,u]}§ 9429 uint32_t calls( PRNG32 & prng ); §\C{// number of calls}§9430 void copy( PRNG32 & dst, PRNG32 & src ); 9431 \end{cfa} 9432 \begin{cfa} 9433 struct PRNG64 {}; §\C{// opaque type, no copy or assignment}§9434 void ?{}( PRNG64 & prng, uint64_t seed ); 9435 void ?{}( PRNG64 & prng ); §\C{// random seed}§9429 uint32_t calls( PRNG32 & prng ); §\C{// number of calls}§ 9430 void copy( PRNG32 & dst, PRNG32 & src ); §\C{// checkpoint PRNG state}§ 9431 \end{cfa} 9432 \begin{cfa} 9433 struct PRNG64 {}; §\C{// opaque type, no copy or assignment}§ 9434 void ?{}( PRNG64 & prng, uint64_t seed ); §\C{// fixed seed}§ 9435 void ?{}( PRNG64 & prng ); §\C{// random seed}§ 9436 9436 void set_seed( PRNG64 & prng, uint64_t seed ); §\C{// set seed}§ 9437 uint64_t get_seed( PRNG64 & prng ); §\C{// get seed}§9438 uint64_t prng( PRNG64 & prng ); §\C{// [0,UINT\_MAX]}§9439 uint64_t prng( PRNG64 & prng, uint64_t u ); 9437 uint64_t get_seed( PRNG64 & prng ); §\C{// get seed}§ 9438 uint64_t prng( PRNG64 & prng ); §\C{// [0,UINT\_MAX]}§ 9439 uint64_t prng( PRNG64 & prng, uint64_t u ); §\C{// [0,u)}§ 9440 9440 uint64_t prng( PRNG64 & prng, uint64_t l, uint64_t u ); §\C{// [l,u]}§ 9441 uint64_t calls( PRNG64 & prng ); §\C{// number of calls}§9442 void copy( PRNG64 & dst, PRNG64 & src ); §\C{// checkpoint PRNG state}§9441 uint64_t calls( PRNG64 & prng ); §\C{// number of calls}§ 9442 void copy( PRNG64 & dst, PRNG64 & src ); §\C{// checkpoint PRNG state}\CRT§ 9443 9443 \end{cfa} 9444 9444 The type ©PRNG© is aliased to ©PRNG64© on 64-bit architectures and ©PRNG32© on 32-bit architectures. … … 9452 9452 \begin{figure} 9453 9453 \begin{cfa} 9454 PRNG sprng1, sprng2; §\C{// select appropriate 32/64-bit PRNG}§9454 PRNG sprng1, sprng2; §\C{// select appropriate 32/64-bit PRNG}§ 9455 9455 ®set_seed( sprng1, 1009 )®; ®set_seed( sprng2, 1009 )®; 9456 9456 for ( 10 ) { … … 9496 9496 The PRNG global and companion thread functions are for concurrent programming, such as randomizing execution in short-running programs, \eg ©yield( prng() % 5 )©. 9497 9497 \begin{cfa} 9498 void set_seed( size_t seed ); §\C{// set global seed}§9499 size_t get_seed(); §\C{// get global seed}§9498 void set_seed( size_t seed ); §\C[3.5in]{// set global seed}§ 9499 size_t get_seed(); §\C{// get global seed}§ 9500 9500 // SLOWER, global routines 9501 size_t prng( void ); §\C{// [0,UINT\_MAX]}§9502 size_t prng( size_t u ); §\C{// [0,u)}§9503 size_t prng( size_t l, size_t u ); §\C{// [l,u]}§9501 size_t prng( void ); §\C{// [0,UINT\_MAX]}§ 9502 size_t prng( size_t u ); §\C{// [0,u)}§ 9503 size_t prng( size_t l, size_t u ); §\C{// [l,u]}§ 9504 9504 // FASTER, thread members 9505 size_t prng( §thread\LstStringStyle{\textdollar}§ & th ); 9506 size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t u ); 9507 size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t l, size_t u ); §\C{// [l,u]}§9505 size_t prng( §thread\LstStringStyle{\textdollar}§ & th ); §\C{// [0,UINT\_MAX]}§ 9506 size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t u ); §\C{// [0,u)}§ 9507 size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t l, size_t u ); §\C{// [l,u]}\CRT§ 9508 9508 \end{cfa} 9509 9509 The only difference between the two sets of ©prng© routines is performance.
Note: See TracChangeset
for help on using the changeset viewer.