Changeset a5e2682 for doc/theses/mike_brooks_MMath
- Timestamp:
- Oct 21, 2022, 12:13:25 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 9e042d8
- Parents:
- 8bd886e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/programs/hello-md.cfa
r8bd886e ra5e2682 1 1 #include "array.hfa" 2 3 4 trait ix( C &, E &, ztype(N) ) {5 E & ?[?]( C &, ptrdiff_t );6 void __taglen( tag(C), tag(N) );7 };8 9 forall( ztype(Zn), ztype(S), Timmed &, Tbase & )10 void __taglen( tag(arpk(Zn, S, Timmed, Tbase)), tag(Zn) ) {}11 2 12 3 … … 38 29 39 30 40 forall( ztype( N ) ) 31 32 33 34 35 36 37 38 39 40 forall( [N] ) 41 41 void print1d_cstyle( array(float, N) & c ); 42 42 43 forall( C &, ztype( N ) | ix( C, float, N ) )43 forall( [N], C & | ar( C, float, N ) ) 44 44 void print1d( C & c ); 45 45 … … 58 58 59 59 60 forall( ztype( N ))60 forall( [N] ) 61 61 void print1d_cstyle( array(float, N) & c ) { 62 for( i; z(N)) {62 for( i; N ) { 63 63 printf("%.1f ", c[i]); 64 64 } … … 78 78 79 79 80 forall( C &, ztype( N ) | ix( C, float, N ) )80 forall( [N], C & | ar( C, float, N ) ) 81 81 void print1d( C & c ) { 82 for( i; z(N)) {82 for( i; N ) { 83 83 printf("%.1f ", c[i]); 84 84 } … … 99 99 100 100 101 void fill( array(float, Z(5), Z(7)) & a ) {101 void fill( array(float, 5, 7) & a ) { 102 102 for ( i; (ptrdiff_t) 5 ) { 103 103 for ( j; 7 ) { 104 a[ [i,j]] = 1.0 * i + 0.1 * j;105 printf("%.1f ", a[ [i,j]]);104 a[i,j] = 1.0 * i + 0.1 * j; 105 printf("%.1f ", a[i,j]); 106 106 } 107 107 printf("\n"); … … 118 118 119 119 120 array( float, Z(5), Z(7)) a;120 array( float, 5, 7 ) a; 121 121 fill(a); 122 122 /* … … 148 148 149 149 150 print1d( a[ [ 2, all ]] ); // 2.0 2.1 2.2 2.3 2.4 2.5 2.6151 print1d( a[ [ all, 3 ]] ); // 0.3 1.3 2.3 3.3 4.3150 print1d( a[ 2, all ] ); // 2.0 2.1 2.2 2.3 2.4 2.5 2.6 151 print1d( a[ all, 3 ] ); // 0.3 1.3 2.3 3.3 4.3 152 152 153 153 154 154 155 print1d_cstyle( a[ [ 2, all ]] );155 print1d_cstyle( a[ 2, all ] ); 156 156 157 157 … … 161 161 162 162 163 #ifdef SHOW ERR1163 #ifdef SHOW_ERROR_1 164 164 165 print1d_cstyle( a[ [ all, 2 ]] ); // bad165 print1d_cstyle( a[ all, 2 ] ); // bad 166 166 167 167 #endif
Note: See TracChangeset
for help on using the changeset viewer.