diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-05-02 04:10:56 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-05-02 04:10:56 +0800 |
commit | 33d419e4d54d969798af80f05e05f0c447a99594 (patch) | |
tree | c78355a2d334e34df865aca865dbb4864a85820c /meowpp.test/src/Matrix.cpp | |
parent | d2d7a49563a8f04bd07264a4a989d5656313d375 (diff) | |
download | meow-33d419e4d54d969798af80f05e05f0c447a99594.tar meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.gz meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.bz2 meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.lz meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.xz meow-33d419e4d54d969798af80f05e05f0c447a99594.tar.zst meow-33d419e4d54d969798af80f05e05f0c447a99594.zip |
big change about dir structure
Diffstat (limited to 'meowpp.test/src/Matrix.cpp')
-rw-r--r-- | meowpp.test/src/Matrix.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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 <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; +}; |