Added runge kutta integration.

This commit is contained in:
jgoppert
2015-11-11 23:31:43 -05:00
parent 2c7a375e3d
commit 42f2e60b24
11 changed files with 112 additions and 12 deletions
+1
View File
@@ -11,6 +11,7 @@ set(tests
vector3
attitude
filter
integration
squareMatrix
)
+1 -1
View File
@@ -29,7 +29,7 @@ int main()
// euler default ctor
Eulerf e;
Eulerf e_zero = zero<float, 3, 1>();
Eulerf e_zero = zeros<float, 3, 1>();
assert(e == e_zero);
assert(e == e);
+26
View File
@@ -0,0 +1,26 @@
#include <assert.h>
#include <stdio.h>
#include <matrix/integration.hpp>
using namespace matrix;
Vector<float, 6> f(float t, Vector<float, 6> y);
Vector<float, 6> f(float t, Vector<float, 6> y) {
return ones<float, 6, 1>();
}
int main()
{
Vector<float, 6> y = ones<float, 6, 1>();
float h = 1;
float t = 1;
y.T().print();
integrate_rk4(f, y, t, h);
y.T().print();
assert(y == (ones<float, 6, 1>()*2));
return 0;
}
/* vim: set et fenc=utf-8 ff=unix sts=0 sw=4 ts=4 : */
+1 -1
View File
@@ -40,7 +40,7 @@ int main()
assert(A_large == A_large_I);
}
SquareMatrix<float, 3> zero_test = zero<float, 3, 3>();
SquareMatrix<float, 3> zero_test = zeros<float, 3, 3>();
inv(zero_test);
return 0;
+6
View File
@@ -65,6 +65,7 @@ int main()
Matrix3f m4(data);
assert(-m4 == m4*(-1));
m4.swapCols(0, 2);
assert(m4 == Matrix3f(data_col_02_swap));
@@ -72,6 +73,11 @@ int main()
m4.swapRows(0, 2);
assert(m4 == Matrix3f(data_row_02_swap));
assert(fabs(m4.min() - 1) < 1e-5);
Scalar<float> s;
s = 1;
assert(fabs(s - 1) < 1e-5);
return 0;
}
-1
View File
@@ -15,7 +15,6 @@ int main()
assert(fabs(v1.norm() - 7.416198487095663f) < 1e-5);
Vector<float, 5> v2(data2);
assert(fabs(v1.dot(v2) - 130.0f) < 1e-5);
assert(fabs(v1*v2 - 130.0f) < 1e-5);
v2.normalize();
Vector<float, 5> v3(v2);
assert(v2 == v3);