gps_pvt 0.3.3 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,91 @@
1
+ /*
2
+ * Copyright (c) 2015, M.Naruoka (fenrir)
3
+ * All rights reserved.
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without modification,
6
+ * are permitted provided that the following conditions are met:
7
+ *
8
+ * - Redistributions of source code must retain the above copyright notice,
9
+ * this list of conditions and the following disclaimer.
10
+ * - Redistributions in binary form must reproduce the above copyright notice,
11
+ * this list of conditions and the following disclaimer in the documentation
12
+ * and/or other materials provided with the distribution.
13
+ * - Neither the name of the naruoka.org nor the names of its contributors
14
+ * may be used to endorse or promote products derived from this software
15
+ * without specific prior written permission.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
21
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
+ * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ *
30
+ */
31
+
32
+ #ifndef __INTEGRAL_H
33
+ #define __INTEGRAL_H
34
+
35
+ /** @file
36
+ * @brief �ϕ��@���L�q�����t�@�C���ł��B
37
+ *
38
+ * �ϕ��@���L�q�����t�@�C���ł��B
39
+ * ���݂̓I�C���[�@�ARunge-Kutta�@(2���A4��)��3��ނ̐ϕ��@���T�|�[�g���Ă��܂��B
40
+ *
41
+ */
42
+
43
+ /**
44
+ * Runge-Kutta�@(4��)�ɂ��ϕ�
45
+ *
46
+ * @param f ����������\f$ f(x, y) \f$
47
+ * @param x ��ԗ�
48
+ * @param y �ړI��
49
+ * @param h ��ԗʂ̍���
50
+ * @return �w���ԗʍ������o�߂����ۂ̖ړI��
51
+ */
52
+ template <class Function, class V1, class V2>
53
+ V2 nextByRK4(const Function &f, const V1 &x, const V2 &y, const V1 &h){
54
+ V2 k1(f(x, y) * h);
55
+ V2 k2(f(x + h/2, y + k1/2) * h);
56
+ V2 k3(f(x + h/2, y + k2/2) * h);
57
+ V2 k4(f(x + h, y + k3) * h);
58
+ return y + (k1 + k2*2 + k3*2 + k4)/6;
59
+ }
60
+
61
+ /**
62
+ * Runge-Kutta�@(2��)�ɂ��ϕ�
63
+ *
64
+ * @param f ����������\f$ f(x, y) \f$
65
+ * @param x ��ԗ�
66
+ * @param y �ړI��
67
+ * @param h ��ԗʂ̍���
68
+ * @return �w���ԗʍ������o�߂����ۂ̖ړI��
69
+ */
70
+ template <class Function, class V1, class V2>
71
+ V2 nextByRK2(const Function &f, const V1 &x, const V2 &y, const V1 &h){
72
+ V2 k1(f(x, y) * h);
73
+ V2 k2(f(x + h, y + k1) * h);
74
+ return y + (k1 + k2)/2;
75
+ }
76
+
77
+ /**
78
+ * Euler�@(1��)�ɂ��ϕ�
79
+ *
80
+ * @param f ����������\f$ f(x, y) \f$
81
+ * @param x ��ԗ�
82
+ * @param y �ړI��
83
+ * @param h ��ԗʂ̍���
84
+ * @return �w���ԗʍ������o�߂����ۂ̖ړI��
85
+ */
86
+ template <class Function, class V1, class V2>
87
+ V2 nextByEuler(const Function &f, const V1 &x, const V2 &y, const V1 &h){
88
+ return y + f(x, y) * h;
89
+ }
90
+
91
+ #endif /* __INTEGRAL_H */