source: doc/theses/mike_brooks_MMath/programs/array-boundcheck-removal.cfa @ 1379c96e

Last change on this file since 1379c96e was 5546f50b, checked in by Peter A. Buhr <pabuhr@…>, 4 months ago

more switch to tabs

  • Property mode set to 100644
File size: 872 bytes
Line 
1#include <array.hfa>
2
3#ifndef DIMSVERSION
4#define DIMSVERSION 1
5#endif
6
7#if DIMSVERSION == 1
8
9forall( [N] )
10size_t foo( array( size_t, N ) & a ) {
11        size_t retval = 0;
12        for( i; N ) {
13                retval += a[i];
14        }
15        return retval;
16}
17
18#elif DIMSVERSION == 2
19
20forall( [N], [M] )
21size_t foo( array( size_t, N, M ) & a ) {
22        size_t retval = 0;
23        for( i; N ) for( j; M ) {
24                retval += a[i][j];
25        }
26        return retval;
27}
28
29#elif DIMSVERSION == 3
30
31forall( [N] )
32size_t foo( array( size_t, N ) & a, array( size_t, N ) & b ) {
33        size_t retval = 0;
34        for( i; N ) {
35                retval += a[i] - b[i];
36        }
37        return retval;
38}
39
40#elif DIMSVERSION == 4
41
42forall( [M], [N], [P] )
43void foo   ( array(size_t, M, P) & src1,
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        }
51}
52
53#else
54#error Bad Version
55#endif
Note: See TracBrowser for help on using the repository browser.