File: funexample.c

package info (click to toggle)
xppaut 5.85-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 11,552 kB
  • ctags: 7,725
  • sloc: ansic: 80,633; cpp: 965; makefile: 265
file content (44 lines) | stat: -rw-r--r-- 840 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdlib.h> 
#include <math.h>
/*  
 some example functions
*/
choice(char **names,int *n)
{
  char nm[]={"lv-lotka-volterra","vdp-van der pol","duff-duffing"};
 *n=3;
 names[0]=nm[0];
 names[1]=nm[1];
 names[2]=nm[2];
}
 
lv(double *in,double *out,int nin,int nout,double *var,double *con)
{
  double x=in[0],y=in[1];
  double a=in[2],b=in[3],c=in[4],d=in[5];
   double t=in[6];
  out[0]=a*x*(b-y);
  out[1]=c*y*(-d+x);
}

vdp(double *in,double *out,int nin,int nout,double *var,double *con)
{
  double x=in[0],y=in[1];
  double a=in[2],b=in[3],c=in[4],d=in[5];
   double t=in[6];
  out[0]=y;
  out[1]=-x+a*y*(1-x*x);

}

duff(double *in,double *out,int nin,int nout,double *var,double *con)
{
  double x=in[0],y=in[1];
  double a=in[2],b=in[3],c=in[4],d=in[5];
 double t=in[6];
  out[0]=y;
  out[1]=x*(1-x*x)+a*sin(b*t)-c*y;
}