summaryrefslogtreecommitdiff
path: root/test.c
blob: 24b7b3d4b9bde701deaa0c2a8285d07387bee6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// > import Data.Array.Accelerate.C
// > import qualified Data.Array.Accelerate as A
// > import qualified Data.Array.Accelerate.Interpreter as I
// > let Right (p,_,_) = translateAcc "kaas" $ \(A.T2 a b) -> A.generate (A.I2 2 3) (\(A.I2 i j) -> let A.T2 x y = b A.! A.I1 i in i * j + a A.! A.I2 i j + x * y :: A.Exp Int) in putStr p
// [...this file without main()...]
// > I.run1 (\(A.T2 a b) -> A.generate (A.I2 2 3) (\(A.I2 i j) -> let A.T2 x y = b A.! A.I1 i in i * j + a A.! A.I2 i j + x * y :: A.Exp Int)) (A.fromList (A.Z A.:. (2 :: Int) A.:. (3 :: Int)) [0..], A.fromList (A.Z A.:. (2 :: Int)) [(1,2), (3,4)])
// Matrix (Z :. 2 :. 3)
//   [  2,  3,  4,
//     15, 17, 19]
//
// Running this program will give the same result. :)


#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>

void expfun_13(int64_t* x14, int64_t* x15) {
  int64_t x16;
  int64_t x17;
  x16 = (2LL);
  x17 = (3LL);
  x14[(0)] = x16;
  x15[(0)] = x17;
}

void expfun_18(int64_t n1, int64_t n2, int64_t* a3, int64_t n4, int64_t* a5, int64_t* a6, int64_t x19, int64_t x20, int64_t* x21) {
  int64_t x35;
  int64_t x36;
  int64_t x27;
  int64_t x28;
  int64_t x22;
  int64_t x23;
  x22 = x19;
  x23 = x20;
  x27 = (x22) * (x23);
  int64_t i24;
  int64_t x25;
  int64_t x26;
  x25 = x19;
  x26 = x20;
  i24 = ((x25) * (n2)) + (x26);
  x28 = a3[i24];
  x35 = (x27) + (x28);
  int64_t x29;
  int64_t x30;
  int64_t i31;
  int64_t x32;
  x32 = x19;
  i31 = x32;
  x29 = a5[i31];
  x30 = a6[i31];
  int64_t x33;
  int64_t x34;
  x33 = x29;
  x34 = x30;
  x36 = (x33) * (x34);
  x21[(0)] = (x35) + (x36);
}

void kaas(int64_t n1, int64_t n2, int64_t* a3, int64_t n4, int64_t* a5, int64_t* a6, int64_t* n10, int64_t* n11, int64_t** a12) {
  int64_t n7;
  int64_t n8;
  expfun_13(&(n7), &(n8));
  int64_t* a9 = malloc(((n7) * (n8)) * ((sizeof (int64_t))));
  for (int64_t n38 = (0); n38 < (n7); n38++) {
    for (int64_t n39 = (0); n39 < (n8); n39++) {
      int64_t x37;
      expfun_18(n1, n2, a3, n4, a5, a6, n38, n39, &(x37));
      a9[((n38) * (n8)) + (n39)] = x37;
    }
  }
  n10[(0)] = n7;
  n11[(0)] = n8;
  a12[(0)] = a9;
}

int main() {
	int64_t a[6] = {0, 1, 2, 3, 4, 5};
	int64_t b1[2] = {1, 3};
	int64_t b2[2] = {2, 4};
	int64_t resn1, resn2;
	int64_t *res;
	kaas(2, 3, a, 2, b1, b2, &resn1, &resn2, &res);
	printf("%" PRIi64 "x%" PRIi64 ":", resn1, resn2);
	for (int64_t i = 0; i < resn1; i++)
		for (int64_t j = 0; j < resn2; j++)
			printf(" %" PRIi64, res[resn2 * i + j]);
	printf("\n");
}