summaryrefslogtreecommitdiff
path: root/src/c/differential_calculus
diff options
context:
space:
mode:
Diffstat (limited to 'src/c/differential_calculus')
-rw-r--r--src/c/differential_calculus/includes/ode.h28
-rw-r--r--src/c/differential_calculus/interfaces/int_ode.h27
-rw-r--r--src/c/differential_calculus/ode/doded.c39
-rw-r--r--src/c/differential_calculus/ode/dodes.c36
-rw-r--r--src/c/differential_calculus/ode/ode.c26
5 files changed, 120 insertions, 36 deletions
diff --git a/src/c/differential_calculus/includes/ode.h b/src/c/differential_calculus/includes/ode.h
index 46220a8..f08909c 100644
--- a/src/c/differential_calculus/includes/ode.h
+++ b/src/c/differential_calculus/includes/ode.h
@@ -1,9 +1,23 @@
-// FOSSEE IIT Bombay
-#ifdef __INT_ODE_H__
-#define __INT_ODE_H__
+// Copyright (C) 2016 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Siddhesh Wani
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
-double ODE(double initial_value, double start_time, double end_time, \
- char *ode_function, double nequs, double eps_abs, double eps_rel \
- double step_size)
+#ifndef __ODE_H__
+#define __ODE_H__
-#endif /*__INT_ODE_H__*/ \ No newline at end of file
+double dodes(double initial_value, double start_time, double end_time, \
+ char *ode_function, double nequs, double eps_abs, double eps_rel, \
+ double step_size);
+
+void doded(double *initial_value, double start_time, double end_time, \
+ char *ode_function, double nequs, double eps_abs, double eps_rel, \
+ double step_size, double *out);
+
+#endif /*__ODE_H__*/ \ No newline at end of file
diff --git a/src/c/differential_calculus/interfaces/int_ode.h b/src/c/differential_calculus/interfaces/int_ode.h
index 5000ed5..a27acba 100644
--- a/src/c/differential_calculus/interfaces/int_ode.h
+++ b/src/c/differential_calculus/interfaces/int_ode.h
@@ -1,9 +1,30 @@
-// FOSSEE IIT Bombay
+// Copyright (C) 2016 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Siddhesh Wani
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
-#ifdef __INT_ODE_H__
+#ifndef __INT_ODE_H__
#define __INT_ODE_H__
-#define d0d0d0g2ODEd0(in1, in2, in3, in4) ODE(in1, in2, in3, in4, 1, 1.0e-2,\
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define d0d0d0g2oded0(in1, in2, in3, in4) dodes(in1, in2, in3, in4, 1, 1.0e-2,\
1.0e-2, 1.0e-6)
+#define d2d0d0g2oded2(in1, size1, in2, in3, func_name, strsize, out) doded(in1, in2, in3, func_name \
+ 1, 1.0e-2, 1.0e-2, 1.0e-6, out)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+
#endif /*__INT_ODE_H__*/ \ No newline at end of file
diff --git a/src/c/differential_calculus/ode/doded.c b/src/c/differential_calculus/ode/doded.c
new file mode 100644
index 0000000..b544c42
--- /dev/null
+++ b/src/c/differential_calculus/ode/doded.c
@@ -0,0 +1,39 @@
+// Copyright (C) 2016 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Siddhesh Wani
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include "ode.h"
+#include "types.h"
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_odeiv2.h>
+
+
+void doded(double *initial_value, double start_time, double end_time, \
+ char *ode_function, double nequs, double eps_abs, double eps_rel, \
+ double step_size, double *out)
+{
+ double t = start_time;
+ //Setup ODE related parameters
+ gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL};
+
+ gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs);
+ gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel);
+ gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs);
+
+ while(t < end_time)
+ {
+ gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &t, step_size, &out);
+ }
+
+ gsl_odeiv2_evolve_free (e);
+ gsl_odeiv2_control_free (c);
+ gsl_odeiv2_step_free (s);
+}
diff --git a/src/c/differential_calculus/ode/dodes.c b/src/c/differential_calculus/ode/dodes.c
new file mode 100644
index 0000000..ee6718b
--- /dev/null
+++ b/src/c/differential_calculus/ode/dodes.c
@@ -0,0 +1,36 @@
+// Copyright (C) 2016 - IIT Bombay - FOSSEE
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution. The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+// Author: Siddhesh Wani
+// Organization: FOSSEE, IIT Bombay
+// Email: toolbox@scilab.in
+
+#include "ode.h"
+#include "types.h"
+#include <gsl/gsl_errno.h>
+#include <gsl/gsl_matrix.h>
+#include <gsl/gsl_odeiv2.h>
+
+
+double dodes(double initial_value, double start_time, double end_time, \
+ char *ode_function, double nequs, double eps_abs, double eps_rel, \
+ double step_size)
+{
+ double out = 0;
+ //int status;
+ //Setup ODE related parameters
+ gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL};
+
+ gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs);
+ gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel);
+ gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs);
+
+ gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &start_time, step_size, &out);
+
+ return out;
+
+}
diff --git a/src/c/differential_calculus/ode/ode.c b/src/c/differential_calculus/ode/ode.c
deleted file mode 100644
index b815e36..0000000
--- a/src/c/differential_calculus/ode/ode.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// FOSSEE IIT Bombay
-
-#include "ODE.h"
-#include "types.h"
-
-
-double ODE(double initial_value, double start_time, double end_time, \
- char *ode_function, double nequs, double eps_abs, double eps_rel \
- double step_size)
-{
- double out = 0;
- int status;
- //Setup ODE related parameters
- gsl_odeiv2_system sys = {ode_function, NULL, 2, NULL};
-
- gsl_odeiv2_step *s = gsl_odeiv2_step_alloc (gsl_odeiv2_step_rkf45, nequs);
- gsl_odeiv2_control *c = gsl_odeiv2_control_y_new (eps_abs, eps_rel);
- gsl_odeiv2_evolve *e = gsl_odeiv2_evolve_alloc (nequs);
-
- status = gsl_odeiv2_evolve_apply_fixed_step (e, c, s, &sys, &t, stepsize, x_dot);
-
- if (status == GSL_SUCCESS) {
- return out;
- }
- else return 0;
-}