Changeset b8e047a
- Timestamp:
- Jul 28, 2024, 10:12:28 PM (4 months ago)
- Branches:
- master
- Children:
- caa3e2c
- Parents:
- 82ff201a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/collections/array.hfa
r82ff201a rb8e047a 45 45 forall( [N], S & | sized(S), Timmed &, Tbase & ) { 46 46 // 47 // Single-dim array s ruct (with explicit packing and atom)47 // Single-dim array struct (with explicit packing and atom) 48 48 // 49 49 struct arpk { … … 83 83 // Mike is open to being shown a smaller set of overloads that still passes the test. 84 84 85 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, zero_t ) {85 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, zero_t ) { 86 86 //assert( 0 < N ); 87 87 subcheck( a, 0L, 0, N ); 88 return (Timmed &) 89 } 90 91 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, one_t ) {88 return (Timmed &)a.strides[0]; 89 } 90 91 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, one_t ) { 92 92 //assert( 1 < N ); 93 93 subcheck( a, 1L, 0, N ); 94 return (Timmed &) 95 } 96 97 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, int i ) {94 return (Timmed &)a.strides[1]; 95 } 96 97 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, int i ) { 98 98 //assert( i < N ); 99 99 subcheck( a, (long int)i, 0, N ); 100 return (Timmed &) 101 } 102 103 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, int i ) {100 return (Timmed &)a.strides[i]; 101 } 102 103 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, int i ) { 104 104 //assert( i < N ); 105 105 subcheck( a, (long int)i, 0, N ); 106 return (Timmed &) 107 } 108 109 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, unsigned int i ) {106 return (Timmed &)a.strides[i]; 107 } 108 109 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, unsigned int i ) { 110 110 //assert( i < N ); 111 111 subcheck( a, (long int)i, 0, N ); 112 return (Timmed &) 113 } 114 115 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, unsigned int i ) {112 return (Timmed &)a.strides[i]; 113 } 114 115 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, unsigned int i ) { 116 116 //assert( i < N ); 117 117 subcheck( a, (unsigned long int)i, 0, N ); 118 return (Timmed &) 119 } 120 121 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, long int i ) {118 return (Timmed &)a.strides[i]; 119 } 120 121 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, long int i ) { 122 122 //assert( i < N ); 123 123 subcheck( a, i, 0, N ); 124 return (Timmed &) 125 } 126 127 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, long int i ) {124 return (Timmed &)a.strides[i]; 125 } 126 127 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, long int i ) { 128 128 //assert( i < N ); 129 129 subcheck( a, i, 0, N ); 130 return (Timmed &) 131 } 132 133 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, unsigned long int i ) {130 return (Timmed &)a.strides[i]; 131 } 132 133 static inline Timmed & ?[?]( arpk( N, S, Timmed, Tbase ) & a, unsigned long int i ) { 134 134 //assert( i < N ); 135 135 subcheck( a, i, 0, N ); 136 return (Timmed &) 137 } 138 139 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, unsigned long int i ) {136 return (Timmed &)a.strides[i]; 137 } 138 139 static inline const Timmed & ?[?]( const arpk( N, S, Timmed, Tbase ) & a, unsigned long int i ) { 140 140 //assert( i < N ); 141 141 subcheck( a, i, 0, N ); 142 return (Timmed &) 143 } 144 145 static inline size_t ?`len( arpk( N, S, Timmed, Tbase ) & a ) {142 return (Timmed &)a.strides[i]; 143 } 144 145 static inline size_t ?`len( arpk( N, S, Timmed, Tbase ) & a ) { 146 146 return N; 147 147 } 148 148 149 static inline void __taglen( tag(arpk( N, S, Timmed, Tbase )), tag(N) ) {}149 static inline void __taglen( tag(arpk( N, S, Timmed, Tbase )), tag(N) ) {} 150 150 } 151 151 … … 157 157 158 158 forall( [N], S & | sized(S), Timmed &, Tbase & | { void ?{}( Timmed & ); } ) 159 static inline void ?{}( arpk( N, S, Timmed, Tbase ) & this ) {159 static inline void ?{}( arpk( N, S, Timmed, Tbase ) & this ) { 160 160 void ?{}( S (&)[N] ) {} 161 161 ?{}(this.strides); 162 162 163 for (i; N) ?{}( (Timmed &) 163 for (i; N) ?{}( (Timmed &)this.strides[i] ); 164 164 } 165 165 166 166 forall( [N], S & | sized(S), Timmed &, Tbase & | { void ^?{}( Timmed & ); } ) 167 static inline void ^?{}( arpk( N, S, Timmed, Tbase ) & this ) {167 static inline void ^?{}( arpk( N, S, Timmed, Tbase ) & this ) { 168 168 void ^?{}( S (&)[N] ) {} 169 169 ^?{}(this.strides); 170 170 171 171 for (i; N ) { 172 ^?{}( (Timmed &) 172 ^?{}( (Timmed &)this.strides[N-i-1] ); 173 173 } 174 174 } … … 182 182 183 183 forall( [N], ZTags ... , Trslt &, Tatom & | { Trslt mkar_( tag(Tatom), ZTags ); } ) 184 static inline arpk( N, Trslt, Trslt, Tatom) mkar_( tag(Tatom), tag(N), ZTags ) {}184 static inline arpk( N, Trslt, Trslt, Tatom) mkar_( tag(Tatom), tag(N), ZTags ) {} 185 185 186 186 // based on https://stackoverflow.com/questions/1872220/is-it-possible-to-iterate-over-arguments-in-variadic-macros … … 254 254 // Base 255 255 forall( [Nq], Sq & | sized(Sq), Tbase & ) 256 static inline tag(arpk( Nq, Sq, Tbase, Tbase )) enq_( tag(Tbase ), tag(Nq), tag(Sq), tag(Tbase ) ) {257 tag(arpk( Nq, Sq, Tbase, Tbase )) ret;256 static inline tag(arpk( Nq, Sq, Tbase, Tbase )) enq_( tag(Tbase ), tag(Nq), tag(Sq), tag(Tbase ) ) { 257 tag(arpk( Nq, Sq, Tbase, Tbase )) ret; 258 258 return ret; 259 259 } 260 260 261 261 // Rec 262 forall( [Nq], Sq & | sized(Sq), [N], S & | sized(S), recq &, recr &, Tbase & | { tag(recr) enq_( tag(Tbase 263 static inline tag(arpk( N, S, recr, Tbase )) enq_( tag(Tbase ), tag(Nq), tag(Sq), tag(arpk(N, S, recq, Tbase )) ) {264 tag(arpk( N, S, recr, Tbase )) ret;262 forall( [Nq], Sq & | sized(Sq), [N], S & | sized(S), recq &, recr &, Tbase & | { tag(recr) enq_( tag(Tbase), tag(Nq), tag(Sq), tag(recq) ); } ) 263 static inline tag(arpk( N, S, recr, Tbase )) enq_( tag(Tbase ), tag(Nq), tag(Sq), tag(arpk( N, S, recq, Tbase )) ) { 264 tag(arpk( N, S, recr, Tbase )) ret; 265 265 return ret; 266 266 } … … 268 268 // Wrapper 269 269 extern struct all_t {} all; 270 forall( [N], S & | sized(S), Te &, result &, Tbase & | { tag(result) enq_( tag(Tbase 271 static inline result & ?[?]( arpk( N, S, Te, Tbase ) & this, all_t ) {270 forall( [N], S & | sized(S), Te &, result &, Tbase & | { tag(result) enq_( tag(Tbase), tag(N), tag(S), tag(Te) ); } ) 271 static inline result & ?[?]( arpk( N, S, Te, Tbase ) & this, all_t ) { 272 272 return (result&) this; 273 273 }
Note: See TracChangeset
for help on using the changeset viewer.