From 33d419e4d54d969798af80f05e05f0c447a99594 Mon Sep 17 00:00:00 2001 From: cathook Date: Fri, 2 May 2014 04:10:56 +0800 Subject: big change about dir structure --- meowpp.test/src/Matrix.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 meowpp.test/src/Matrix.cpp (limited to 'meowpp.test/src/Matrix.cpp') diff --git a/meowpp.test/src/Matrix.cpp b/meowpp.test/src/Matrix.cpp new file mode 100644 index 0000000..6ef94b7 --- /dev/null +++ b/meowpp.test/src/Matrix.cpp @@ -0,0 +1,45 @@ +#include "meowpp/math/Matrix.h" + +#include "meowpp.h" + +#include +#include + +using namespace meow; + + + +void print(Matrix 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 a(3, 4, 0); + Matrix b(3, 4, 0); + Matrix 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; +}; -- cgit v1.2.3