Last change
on this file since 4db0140 was
5546f50b,
checked in by Peter A. Buhr <pabuhr@…>, 8 months ago
|
more switch to tabs
|
-
Property mode set to
100644
|
File size:
872 bytes
|
Rev | Line | |
---|
[8d76f2b] | 1 | #include <array.hfa> |
---|
| 2 | |
---|
| 3 | #ifndef DIMSVERSION |
---|
| 4 | #define DIMSVERSION 1 |
---|
| 5 | #endif |
---|
| 6 | |
---|
| 7 | #if DIMSVERSION == 1 |
---|
| 8 | |
---|
| 9 | forall( [N] ) |
---|
| 10 | size_t foo( array( size_t, N ) & a ) { |
---|
[5546f50b] | 11 | size_t retval = 0; |
---|
| 12 | for( i; N ) { |
---|
| 13 | retval += a[i]; |
---|
| 14 | } |
---|
| 15 | return retval; |
---|
[8d76f2b] | 16 | } |
---|
| 17 | |
---|
| 18 | #elif DIMSVERSION == 2 |
---|
| 19 | |
---|
| 20 | forall( [N], [M] ) |
---|
| 21 | size_t foo( array( size_t, N, M ) & a ) { |
---|
[5546f50b] | 22 | size_t retval = 0; |
---|
| 23 | for( i; N ) for( j; M ) { |
---|
| 24 | retval += a[i][j]; |
---|
| 25 | } |
---|
| 26 | return retval; |
---|
[8d76f2b] | 27 | } |
---|
| 28 | |
---|
| 29 | #elif DIMSVERSION == 3 |
---|
| 30 | |
---|
| 31 | forall( [N] ) |
---|
| 32 | size_t foo( array( size_t, N ) & a, array( size_t, N ) & b ) { |
---|
[5546f50b] | 33 | size_t retval = 0; |
---|
| 34 | for( i; N ) { |
---|
| 35 | retval += a[i] - b[i]; |
---|
| 36 | } |
---|
| 37 | return retval; |
---|
[8d76f2b] | 38 | } |
---|
| 39 | |
---|
| 40 | #elif DIMSVERSION == 4 |
---|
| 41 | |
---|
| 42 | forall( [M], [N], [P] ) |
---|
| 43 | void foo ( array(size_t, M, P) & src1, |
---|
[5546f50b] | 44 | array(size_t, P, N) & src2, |
---|
| 45 | array(size_t, M, N) & tgt ) { |
---|
| 46 | for (i; M) for (j; N) { |
---|
| 47 | tgt[i][j] = 0; |
---|
| 48 | for (k; P) |
---|
| 49 | tgt[i][j] += src1[i][k] * src2[k][j]; |
---|
| 50 | } |
---|
[8d76f2b] | 51 | } |
---|
| 52 | |
---|
| 53 | #else |
---|
| 54 | #error Bad Version |
---|
| 55 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.