aboutsummaryrefslogtreecommitdiffstats
path: root/_test
diff options
context:
space:
mode:
authorcathook <b01902109@csie.ntu.edu.tw>2014-05-01 05:15:29 +0800
committercathook <b01902109@csie.ntu.edu.tw>2014-05-01 05:15:29 +0800
commitb05f1bc3bc1a0f3316b755f8c2a9acab562614ad (patch)
treeb9cfb60aa2df3e2a891f3f78ab5166adea3d8cf1 /_test
parent5e989019d254dfc2e7ca8f3c6a8dc6507cd0efaf (diff)
downloadmeow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar.gz
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar.bz2
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar.lz
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar.xz
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.tar.zst
meow-b05f1bc3bc1a0f3316b755f8c2a9acab562614ad.zip
add math
Diffstat (limited to '_test')
-rw-r--r--_test/meowpp.cpp2
-rw-r--r--_test/meowpp_BinaryIndexTree.cpp3
-rw-r--r--_test/meowpp_Colors.cpp6
-rw-r--r--_test/meowpp_DisjointSet.cpp3
-rw-r--r--_test/meowpp_KD_Tree.cpp3
-rw-r--r--_test/meowpp_Matrix.cpp45
-rw-r--r--_test/meowpp_MergeableHeap.cpp3
-rw-r--r--_test/meowpp_SegmentTree.cpp3
-rw-r--r--_test/meowpp_SplayTree.cpp33
-rw-r--r--_test/meowpp_SplayTree_Range.cpp19
-rw-r--r--_test/meowpp_VP_Tree.cpp4
11 files changed, 78 insertions, 46 deletions
diff --git a/_test/meowpp.cpp b/_test/meowpp.cpp
index 805f459..e45a4c1 100644
--- a/_test/meowpp.cpp
+++ b/_test/meowpp.cpp
@@ -4,6 +4,8 @@
#include <cstdlib>
#include <ctime>
+#include "meowpp/Usage.h"
+
////////////////////////////
meow::Usage usg("meowpp"), usg2;
int count = 0;
diff --git a/_test/meowpp_BinaryIndexTree.cpp b/_test/meowpp_BinaryIndexTree.cpp
index 3841a84..3071839 100644
--- a/_test/meowpp_BinaryIndexTree.cpp
+++ b/_test/meowpp_BinaryIndexTree.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/BinaryIndexTree.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <vector>
diff --git a/_test/meowpp_Colors.cpp b/_test/meowpp_Colors.cpp
index 847f838..59f612f 100644
--- a/_test/meowpp_Colors.cpp
+++ b/_test/meowpp_Colors.cpp
@@ -1,3 +1,9 @@
+#include "meowpp/colors/RGB.h"
+#include "meowpp/colors/YUV.h"
+#include "meowpp/colors/HSL.h"
+#include "meowpp/colors/HSV.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
TEST(Colors){
diff --git a/_test/meowpp_DisjointSet.cpp b/_test/meowpp_DisjointSet.cpp
index b871c4d..484e146 100644
--- a/_test/meowpp_DisjointSet.cpp
+++ b/_test/meowpp_DisjointSet.cpp
@@ -1,7 +1,10 @@
+#include "meowpp/dsa/DisjointSet.h"
+
#include "meowpp.h"
#include <vector>
+
TEST(DisjointSet){
int N = 10000000;
meow::DisjointSet dsj(N);
diff --git a/_test/meowpp_KD_Tree.cpp b/_test/meowpp_KD_Tree.cpp
index dcbda5f..6cb2e0c 100644
--- a/_test/meowpp_KD_Tree.cpp
+++ b/_test/meowpp_KD_Tree.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/KD_Tree.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <vector>
diff --git a/_test/meowpp_Matrix.cpp b/_test/meowpp_Matrix.cpp
new file mode 100644
index 0000000..dbcfcb1
--- /dev/null
+++ b/_test/meowpp_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){
+ 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;
+};
diff --git a/_test/meowpp_MergeableHeap.cpp b/_test/meowpp_MergeableHeap.cpp
index c4814da..65fe2cc 100644
--- a/_test/meowpp_MergeableHeap.cpp
+++ b/_test/meowpp_MergeableHeap.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/MergeableHeap.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <vector>
diff --git a/_test/meowpp_SegmentTree.cpp b/_test/meowpp_SegmentTree.cpp
index 777ca9d..05b1b51 100644
--- a/_test/meowpp_SegmentTree.cpp
+++ b/_test/meowpp_SegmentTree.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/SegmentTree.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <ctime>
diff --git a/_test/meowpp_SplayTree.cpp b/_test/meowpp_SplayTree.cpp
index 0d1e2f2..68ae58f 100644
--- a/_test/meowpp_SplayTree.cpp
+++ b/_test/meowpp_SplayTree.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/SplayTree.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <algorithm>
@@ -328,7 +331,6 @@ TEST(SplayTree){
case 0:
if(lowerBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "lowerBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -336,7 +338,6 @@ TEST(SplayTree){
case 1:
if(rUpperBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "rUpperBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -344,7 +345,6 @@ TEST(SplayTree){
case 2:
if(rLowerBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "rLowerBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -352,7 +352,6 @@ TEST(SplayTree){
case 3:
if(upperBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "upperBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -362,7 +361,6 @@ TEST(SplayTree){
case 6:
if(find(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "find");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -373,7 +371,6 @@ TEST(SplayTree){
if(normal[i1].size() > 0){
if(order(i1, rand() % normal[i1].size(), &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "order");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -382,24 +379,6 @@ TEST(SplayTree){
case 10:
if(first_last(i1, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "first_last");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
- show(true);
- return false;
- }
- break;
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- if(insert(i1, k, rand() * 1.0 / RAND_MAX * 50, &tn, &tm) == false){
- meow::messagePrintf(-1, "fail(%s)", "insert");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -412,7 +391,6 @@ TEST(SplayTree){
case 26:
if(split(i1, i2, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "split");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -429,7 +407,6 @@ TEST(SplayTree){
case 36:
if(merge(i1, i2, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "merge");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -440,7 +417,6 @@ TEST(SplayTree){
case 40:
if(erase(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "erase");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -456,7 +432,6 @@ TEST(SplayTree){
case 49:
if(keyOffset(i1, ((rand() & 2) - 1) * k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "keyOffset");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -466,7 +441,6 @@ TEST(SplayTree){
case 52:
if(copy(i1, i2, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "copy");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -482,7 +456,6 @@ TEST(SplayTree){
/*
if(valueOffset(i1, 1.0 * rand() / RAND_MAX * 100, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "valueOffset");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
diff --git a/_test/meowpp_SplayTree_Range.cpp b/_test/meowpp_SplayTree_Range.cpp
index 870d91a..0233a49 100644
--- a/_test/meowpp_SplayTree_Range.cpp
+++ b/_test/meowpp_SplayTree_Range.cpp
@@ -1,3 +1,6 @@
+#include "meowpp/dsa/SplayTree_Range.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <algorithm>
@@ -381,7 +384,6 @@ TEST(SplayTree_Range){
case 0:
if(lowerBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "lowerBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -389,7 +391,6 @@ TEST(SplayTree_Range){
case 1:
if(rUpperBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "rUpperBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -397,7 +398,6 @@ TEST(SplayTree_Range){
case 2:
if(rLowerBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "rLowerBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -405,7 +405,6 @@ TEST(SplayTree_Range){
case 3:
if(upperBound(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "upperBound");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -415,7 +414,6 @@ TEST(SplayTree_Range){
case 6:
if(find(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "find");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -426,7 +424,6 @@ TEST(SplayTree_Range){
if(normal[i1].size() > 0){
if(order(i1, rand() % normal[i1].size(), &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "order");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -435,7 +432,6 @@ TEST(SplayTree_Range){
case 10:
if(first_last(i1, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "first_last");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -452,7 +448,6 @@ TEST(SplayTree_Range){
case 20:
if(insert(i1, k, rand() * 1.0 / RAND_MAX * 50 + 1, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "insert");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -465,7 +460,6 @@ TEST(SplayTree_Range){
case 26:
if(split(i1, i2, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "split");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -482,7 +476,6 @@ TEST(SplayTree_Range){
case 36:
if(merge(i1, i2, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "merge");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -493,7 +486,6 @@ TEST(SplayTree_Range){
case 40:
if(erase(i1, k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "erase");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -509,7 +501,6 @@ TEST(SplayTree_Range){
case 49:
if(keyOffset(i1, ((rand() & 2) - 1) * k, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "keyOffset");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -519,7 +510,6 @@ TEST(SplayTree_Range){
case 52:
if(copy(i1, i2, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "copy");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -533,7 +523,6 @@ TEST(SplayTree_Range){
case 59:
if(valueOverride(i1, 1.0 * rand() / RAND_MAX * 100 + 1, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "valueOffset");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -547,7 +536,6 @@ TEST(SplayTree_Range){
case 66:
if(valueOffset(i1, 1.0 * rand() / RAND_MAX * 100 + 1, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "valueOffset");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
@@ -555,7 +543,6 @@ TEST(SplayTree_Range){
default:
if(query(i1, rand() % 200 - 100, rand() % 200 - 100, &tn, &tm) == false){
meow::messagePrintf(-1, "fail(%s)", "query");
- //for(int z = 0; z < N; z++){ splay[z].print(); }
show(true);
return false;
}
diff --git a/_test/meowpp_VP_Tree.cpp b/_test/meowpp_VP_Tree.cpp
index 34c979c..c01db38 100644
--- a/_test/meowpp_VP_Tree.cpp
+++ b/_test/meowpp_VP_Tree.cpp
@@ -1,3 +1,7 @@
+#include "meowpp/dsa/VP_Tree.h"
+#include "meowpp/dsa/KD_Tree.h"
+#include "meowpp/utility.h"
+
#include "meowpp.h"
#include <vector>