summaryrefslogtreecommitdiff
path: root/matAdd.c
blob: a6120c2b231c7a40a20c442c77b7f780dfcab183 (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
/* matAdd.c
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <benjamin@chausse.xyz> wrote this file. As long as you retain this notice
 * you can do whatever you want with this stuff. If we meet some day, and you
 * think this stuff is worth it, you can buy me a beer in return.
 * Benjamin Chausse
 * ----------------------------------------------------------------------------
 */

#include <stdio.h>
#include "format.h"
#include "testData.h"

int *matAdd(int *ma, int *mb, int w, int h){

  int res[h][w];
  for (int i=0;i<w;i++){
    for (int j=0;j<h;j++){
      res[i][j] = *(ma+(i*h)+j) + *(mb+(i*h)+j);
    }
  }
    return *res;
}

int main(){
  int *test1 = matAdd(mtrxA,mtrxB,3,3);
  print(test1,3,3);
  return 0;
}