Changeset 63a4b92
 Timestamp:
 Apr 29, 2021, 10:25:20 PM (2 years ago)
 Branches:
 ADT, armeh, astexperimental, enum, forallpointerdecay, jacob/cs343translation, master, newastuniqueexpr, pthreademulation, qualifiedEnum
 Children:
 b9dae14c
 Parents:
 3eb55f98
 Files:

 2 added
 3 edited
Legend:
 Unmodified
 Added
 Removed

libcfa/src/containers/array.hfa
r3eb55f98 r63a4b92 25 25 26 26 Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, ptrdiff_t i ) { 27 return (Timmed &) a.strides[i]; 28 } 29 30 Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, int i ) { 31 return (Timmed &) a.strides[i]; 32 } 33 34 Timmed & ?[?]( arpk(Zn, S, Timmed, Tbase) & a, size_t i ) { 27 35 return (Timmed &) a.strides[i]; 28 36 } … … 80 88 // Core [[,,]] operator 81 89 90 #ifdef TRY_BROKEN_DESIRED_MD_SUBSCRIPT 91 82 92 // Desired form. One definition with recursion on IxBC (worked until Jan 2021, see trac #__TODO__) 83 // forall( TA &, TB &, TC &, IxAB, IxBC ...  { TB & ?[?]( TA &, IxAB ); TC & ?[?]( TB &, IxBC ); } )84 // TC & ?[?]( TA & this, IxAB ab, IxBC bc ) {85 // return this[ab][bc];86 // }87 93 88 // Workaround form. Listing all possibilities up to 4 dims. 89 forall( TA &, TB &, IxAB  { TB & ?[?]( TA &, IxAB ); } 90 , TC &, IxBC  { TC & ?[?]( TB &, IxBC ); } ) 94 forall( TA &, TB &, TC &, IxAB, IxBC ...  { TB & ?[?]( TA &, IxAB ); TC & ?[?]( TB &, IxBC ); } ) 91 95 TC & ?[?]( TA & this, IxAB ab, IxBC bc ) { 92 96 return this[ab][bc]; 93 97 } 94 forall( TA &, TB &, IxAB  { TB & ?[?]( TA &, IxAB ); } 95 , TC &, IxBC  { TC & ?[?]( TB &, IxBC ); } 96 , TD &, IxCD  { TD & ?[?]( TC &, IxCD ); } ) 97 TD & ?[?]( TA & this, IxAB ab, IxBC bc, IxCD cd ) { 98 return this[ab][bc][cd]; 99 } 100 forall( TA &, TB &, IxAB  { TB & ?[?]( TA &, IxAB ); } 101 , TC &, IxBC  { TC & ?[?]( TB &, IxBC ); } 102 , TD &, IxCD  { TD & ?[?]( TC &, IxCD ); } 103 , TE &, IxDE  { TE & ?[?]( TD &, IxDE ); } ) 104 TE & ?[?]( TA & this, IxAB ab, IxBC bc, IxCD cd, IxDE de ) { 105 return this[ab][bc][cd][de]; 98 99 #else 100 101 // Workaround form. Listing all possibilities up to 4 dims. 102 103 forall( TA &, TB &, TC &, IxAB_0, IxBC  { TB & ?[?]( TA &, IxAB_0 ); TC & ?[?]( TB &, IxBC ); } ) 104 TC & ?[?]( TA & this, IxAB_0 ab, IxBC bc ) { 105 return this[ab][bc]; 106 106 } 107 107 108 // Adapters for "indexed by ptrdiff_t" implies "indexed by [this other integral type]" 109 // Work around restriction that assertions underlying [[,,]] must match excatly 110 forall( C &, E &  { E & ?[?]( C &, ptrdiff_t ); } ) { 108 forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxBC  { TB & ?[?]( TA &, IxAB_0, IxAB_1 ); TC & ?[?]( TB &, IxBC ); } ) 109 TC & ?[?]( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxBC bc ) { 110 return this[[ab0,ab1]][bc]; 111 } 111 112 112 // Targeted to support: for( i; z(N) ) ... a[[ ..., i, ... ]] 113 E & ?[?]( C & this, size_t i) {114 return this[ (ptrdiff_t) i];115 113 forall( TA &, TB &, TC &, IxAB_0, IxAB_1, IxAB_2, IxBC  { TB & ?[?]( TA &, IxAB_0, IxAB_1, IxAB_2 ); TC & ?[?]( TB &, IxBC ); } ) 114 TC & ?[?]( TA & this, IxAB_0 ab0, IxAB_1 ab1, IxAB_2 ab2, IxBC bc ) { 115 return this[[ab0,ab1,ab2]][bc]; 116 } 116 117 117 // Targeted to support: for( i; 5 ) ... a[[ ..., i, ... ]] 118 E & ?[?]( C & this, int i ) { 119 return this[ (ptrdiff_t) i ]; 120 } 121 } 118 #endif 122 119 123 120 // 
tests/arraycontainer/.expect/arraybasic.x64.txt
r3eb55f98 r63a4b92 1 1 expect Ws = 7.060606 2 2 result Ws [][][][] lo = 7.060606 3 result Ws [,,,] lo = 7.060606 3 4 result Ws [][][][] hi = 7.060606 5 result Ws [,,,] hi = 7.060606 4 6 expect Xs = 8.150808 5 7 result Xs [][][][] lo = 8.150808 8 result Xs [,,,] lo = 8.150808 6 9 result Xs [][][][] hi = 8.150808 10 result Xs [,,,] hi = 8.150808 
tests/arraycontainer/arraybasic.cfa
r3eb55f98 r63a4b92 105 105 printf("result Ws [][][][] lo = %f\n", result); 106 106 107 // fixme: [[,,,]] not working 108 // result = total1d_low( wxyz[[all, slice_ix, slice_ix, slice_ix]] ); 109 // printf("result Ws [,,,] lo = %f\n", result); 107 result = total1d_low( wxyz[[all, slice_ix, slice_ix, slice_ix]] ); 108 printf("result Ws [,,,] lo = %f\n", result); 110 109 111 110 result = total1d_hi( wxyz[all][slice_ix][slice_ix][slice_ix] ); 112 111 printf("result Ws [][][][] hi = %f\n", result); 113 112 114 // fixme: [[,,,]] not working 115 // result = total1d_hi( wxyz[[all, slice_ix, slice_ix, slice_ix]] ); 116 // printf("result Ws [,,,] hi = %f\n", result); 113 result = total1d_hi( wxyz[[all, slice_ix, slice_ix, slice_ix]] ); 114 printf("result Ws [,,,] hi = %f\n", result); 117 115 118 116 // summing across X, with w=y=z=1 … … 126 124 printf("result Xs [][][][] lo = %f\n", result); 127 125 128 // fixme: [[,,,]] not working 129 // result = total1d_low( wxyz[[slice_ix, all, slice_ix, slice_ix]] ); 130 // printf("result Xs [,,,] lo = %f\n", result); 126 result = total1d_low( wxyz[[slice_ix, all, slice_ix, slice_ix]] ); 127 printf("result Xs [,,,] lo = %f\n", result); 131 128 132 129 result = total1d_hi( wxyz[slice_ix][all][slice_ix][slice_ix] ); 133 130 printf("result Xs [][][][] hi = %f\n", result); 134 131 135 // fixme: [[,,,]] not working 136 // result = total1d_hi( wxyz[[slice_ix, all, slice_ix, slice_ix]] ); 137 // printf("result Xs [,,,] hi = %f\n", result); 132 result = total1d_hi( wxyz[[slice_ix, all, slice_ix, slice_ix]] ); 133 printf("result Xs [,,,] hi = %f\n", result); 138 134 139 135 }
Note: See TracChangeset
for help on using the changeset viewer.