aboutsummaryrefslogtreecommitdiffstats
path: root/_test/meowpp_Matrix.cpp
blob: 6ef94b79fbd098f13982f68fbfc23ac80fa68c78 (plain) (blame)
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
#include "meowpp/math/Matrix.h"

#include "meowpp.h"

#include <cmath>
#include <cstdlib>

using namespace meow;



void print(Matrix<int> const& m){
  for(size_t r = 0; r < m.rows(); r++){
    printf("[");
    for(size_t c = 0; c < m.cols(); c++){
      printf("%8d", m(r, c));
    }
    printf("]\n");
  }
}

TEST(Matrix, "Unfinished"){
  Matrix<int> a(3, 4, 0);
  Matrix<int> b(3, 4, 0);
  Matrix<int> c(4, 5, 0);
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 4; j++){
      a.entry(i, j, rand() % 100);
      b.entry(i, j, rand() % 100);
    }
  }
  for(int i = 0; i < 4; i++){
    for(int j = 0; j < 5; j++){
      c.entry(i, j, rand() % 100);
    }
  }
  printf("A = \n"); print(a);
  printf("B = \n"); print(b);
  printf("C = \n"); print(b);
  printf("A + B = \n"); print(a + b);
  printf("A * C = \n"); print(a * c);
  printf("A * B^T = \n"); print(a * b.transpose());
  
  return true;
};