Support more of mathlib function for easier swap in px4.

This commit is contained in:
James Goppert
2016-08-16 19:03:54 -04:00
parent 558777f34c
commit 0eb8aa0c0b
10 changed files with 188 additions and 4 deletions
+9 -2
View File
@@ -12,15 +12,22 @@ int main()
float data1[] = {1,2,3,4,5};
float data2[] = {6,7,8,9,10};
Vector<float, 5> v1(data1);
TEST(fabs(v1.norm() - 7.416198487095663f) < 1e-5);
TEST(isEqualF(v1.norm(), 7.416198487095663f));
TEST(isEqualF(v1.norm(), v1.length()));
Vector<float, 5> v2(data2);
TEST(fabs(v1.dot(v2) - 130.0f) < 1e-5);
TEST(isEqualF(v1.dot(v2), 130.0f));
v2.normalize();
Vector<float, 5> v3(v2);
TEST(isEqual(v2, v3));
float data1_sq[] = {1,4,9,16,25};
Vector<float, 5> v4(data1_sq);
TEST(isEqual(v1, v4.pow(0.5)));
// dot product operator
v1 = Vector<float, 5>(data1);
v2 = Vector<float, 5>(data2);
float dprod = v1 * v2;
TEST(isEqualF(dprod, 130.0f));
return 0;
}