aboutsummaryrefslogtreecommitdiff
path: root/apps/systemlib/math/Vector.cpp
diff options
context:
space:
mode:
authorjgoppert <james.goppert@gmail.com>2013-01-06 15:33:55 -0500
committerjgoppert <james.goppert@gmail.com>2013-01-06 15:33:55 -0500
commitd9491b20cc5fc8b683eb0f60a50da6b322b55e57 (patch)
tree48d44accf2ccff88766bca351c78be06bb9fa4a0 /apps/systemlib/math/Vector.cpp
parent4f3b17f53b120cd54112097f4217a90863013c1f (diff)
downloadpx4-firmware-d9491b20cc5fc8b683eb0f60a50da6b322b55e57.tar.gz
px4-firmware-d9491b20cc5fc8b683eb0f60a50da6b322b55e57.tar.bz2
px4-firmware-d9491b20cc5fc8b683eb0f60a50da6b322b55e57.zip
Reformat of math library with astyle.
Diffstat (limited to 'apps/systemlib/math/Vector.cpp')
-rw-r--r--apps/systemlib/math/Vector.cpp71
1 files changed, 36 insertions, 35 deletions
diff --git a/apps/systemlib/math/Vector.cpp b/apps/systemlib/math/Vector.cpp
index 5bdbc9168..c039a758b 100644
--- a/apps/systemlib/math/Vector.cpp
+++ b/apps/systemlib/math/Vector.cpp
@@ -44,56 +44,57 @@
namespace math
{
-static const float data_testA[] = {1,3};
-static const float data_testB[] = {4,1};
+static const float data_testA[] = {1, 3};
+static const float data_testB[] = {4, 1};
-static Vector testA(2,data_testA);
-static Vector testB(2,data_testB);
+static Vector testA(2, data_testA);
+static Vector testB(2, data_testB);
int __EXPORT vectorTest()
{
- vectorAddTest();
- vectorSubTest();
- return 0;
+ vectorAddTest();
+ vectorSubTest();
+ return 0;
}
int vectorAddTest()
{
- printf("Test Vector Add\t\t: ");
- Vector r = testA + testB;
- float data_test[] = {5.0f, 4.0f};
- ASSERT(vectorEqual(Vector(2,data_test),r));
- printf("PASS\n");
- return 0;
+ printf("Test Vector Add\t\t: ");
+ Vector r = testA + testB;
+ float data_test[] = {5.0f, 4.0f};
+ ASSERT(vectorEqual(Vector(2, data_test), r));
+ printf("PASS\n");
+ return 0;
}
int vectorSubTest()
{
- printf("Test Vector Sub\t\t: ");
- Vector r(2);
- r = testA - testB;
- float data_test[] = {-3.0f, 2.0f};
- ASSERT(vectorEqual(Vector(2,data_test),r));
- printf("PASS\n");
- return 0;
+ printf("Test Vector Sub\t\t: ");
+ Vector r(2);
+ r = testA - testB;
+ float data_test[] = { -3.0f, 2.0f};
+ ASSERT(vectorEqual(Vector(2, data_test), r));
+ printf("PASS\n");
+ return 0;
}
-bool vectorEqual(const Vector & a, const Vector & b, float eps)
+bool vectorEqual(const Vector &a, const Vector &b, float eps)
{
- if (a.getRows() != b.getRows()) {
- printf("row number not equal a: %d, b:%d\n", a.getRows(), b.getRows());
- return false;
- }
- bool ret = true;
- for (size_t i=0;i<a.getRows();i++)
- {
- if (!equal(a(i),b(i),eps))
- {
- printf("element mismatch (%d)\n", i);
- ret = false;
- }
- }
- return ret;
+ if (a.getRows() != b.getRows()) {
+ printf("row number not equal a: %d, b:%d\n", a.getRows(), b.getRows());
+ return false;
+ }
+
+ bool ret = true;
+
+ for (size_t i = 0; i < a.getRows(); i++) {
+ if (!equal(a(i), b(i), eps)) {
+ printf("element mismatch (%d)\n", i);
+ ret = false;
+ }
+ }
+
+ return ret;
}
} // namespace math