Changeset 6503ef4 for doc


Ignore:
Timestamp:
Dec 7, 2024, 6:48:26 PM (11 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
9f7285e
Parents:
0b98381
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r0b98381 r6503ef4  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Thu Aug 15 22:23:30 2024
    14 %% Update Count     : 6957
     13%% Last Modified On : Sat Dec  7 16:53:37 2024
     14%% Update Count     : 6970
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    454454The majority of these flags are used by \CFA developers, but some are occasionally useful to programmers.
    455455Each 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=§]
    457457cfa §test§.cfa -CFA -XCFA -p # print translated code without printing the standard prelude
    458458cfa §test§.cfa -XCFA -P -XCFA parse -XCFA -n # show program parse without prelude
     
    607607C, \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.
    608608\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©.
     609The priority of the exponentiation operator is between the cast and multiplicative operators, so ©-f(x) \ -g(y)© is parenthesized as ©(-f(x)) \ (-g(y))©.
    610610
    611611There are exponentiation operators for integral and floating types, including the builtin \Index{complex} types.
     
    94199419The ©PRNG© types for sequential programs, including coroutining, are:
    94209420\begin{cfa}
    9421 struct PRNG32 {};                                               §\C{// opaque type, no copy or assignment}§
    9422 void ?{}( PRNG32 & prng, uint32_t seed ); §\C{// fixed seed}§
    9423 void ?{}( PRNG32 & prng );                              §\C{// random seed}§
     9421struct PRNG32 {};                                                       §\C[3.5in]{// opaque type, no copy or assignment}§
     9422void ?{}( PRNG32 & prng, uint32_t seed );       §\C{// fixed seed}§
     9423void ?{}( PRNG32 & prng );                                      §\C{// random seed}§
    94249424void 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 ); §\C{// [0,u)}§
     9425uint32_t get_seed( PRNG32 & prng );                     §\C{// get seed}§
     9426uint32_t prng( PRNG32 & prng );                         §\C{// [0,UINT\_MAX]}§
     9427uint32_t prng( PRNG32 & prng, uint32_t u );     §\C{// [0,u)}§
    94289428uint32_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 ); §\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}§
     9429uint32_t calls( PRNG32 & prng );                        §\C{// number of calls}§
     9430void copy( PRNG32 & dst, PRNG32 & src );        §\C{// checkpoint PRNG state}§
     9431\end{cfa}
     9432\begin{cfa}
     9433struct PRNG64 {};                                                       §\C{// opaque type, no copy or assignment}§
     9434void ?{}( PRNG64 & prng, uint64_t seed );       §\C{// fixed seed}§
     9435void ?{}( PRNG64 & prng );                                      §\C{// random seed}§
    94369436void 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 ); §\C{// [0,u)}§
     9437uint64_t get_seed( PRNG64 & prng );                     §\C{// get seed}§
     9438uint64_t prng( PRNG64 & prng );                         §\C{// [0,UINT\_MAX]}§
     9439uint64_t prng( PRNG64 & prng, uint64_t u );     §\C{// [0,u)}§
    94409440uint64_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}§
     9441uint64_t calls( PRNG64 & prng );                        §\C{// number of calls}§
     9442void copy( PRNG64 & dst, PRNG64 & src );        §\C{// checkpoint PRNG state}\CRT§
    94439443\end{cfa}
    94449444The type ©PRNG© is aliased to ©PRNG64© on 64-bit architectures and ©PRNG32© on 32-bit architectures.
     
    94529452\begin{figure}
    94539453\begin{cfa}
    9454 PRNG sprng1, sprng2;                                    §\C{// select appropriate 32/64-bit PRNG}§
     9454PRNG sprng1, sprng2;                                            §\C{// select appropriate 32/64-bit PRNG}§
    94559455®set_seed( sprng1, 1009 )®;   ®set_seed( sprng2, 1009 )®;
    94569456for ( 10 ) {
     
    94969496The PRNG global and companion thread functions are for concurrent programming, such as randomizing execution in short-running programs, \eg ©yield( prng() % 5 )©.
    94979497\begin{cfa}
    9498 void set_seed( size_t seed );                   §\C{// set global seed}§
    9499 size_t get_seed();                                              §\C{// get global seed}§
     9498void set_seed( size_t seed );                           §\C[3.5in]{// set global seed}§
     9499size_t get_seed();                                                      §\C{// get global seed}§
    95009500// 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]}§
     9501size_t prng( void );                                            §\C{// [0,UINT\_MAX]}§
     9502size_t prng( size_t u );                                        §\C{// [0,u)}§
     9503size_t prng( size_t l, size_t u );                      §\C{// [l,u]}§
    95049504// FASTER, thread members
    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]}§
     9505size_t prng( §thread\LstStringStyle{\textdollar}§ & th ); §\C{// [0,UINT\_MAX]}§
     9506size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t u ); §\C{// [0,u)}§
     9507size_t prng( §thread\LstStringStyle{\textdollar}§ & th, size_t l, size_t u ); §\C{// [l,u]}\CRT§
    95089508\end{cfa}
    95099509The only difference between the two sets of ©prng© routines is performance.
Note: See TracChangeset for help on using the changeset viewer.