EVSL  1.1.0
EigenValues Slicing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
simpson.c
Go to the documentation of this file.
1 #include <math.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include "blaslapack.h"
5 #include "def.h"
6 #include "internal_proto.h"
7 #include "string.h" //for memset
8 #include "struct.h"
9 //#include "vector.h"
27 void simpson(double* xi, double* yi, int npts) {
28  double tc = 0.0, ti, tm, ysav;
29  int i = 1;
30  //-------------------- save yi[even_i]
31  ysav = yi[0];
32  yi[0] = 0;
33  while (i < npts - 1) {
34  // -------------------- ysav = yi[i-1] saved
35  // trapeze portion
36  ti = (xi[i] - xi[i - 1]) * (ysav + yi[i]) / 2.0;
37  tm = tc + ti;
38  // simpsion portion
39  ti = (xi[i + 1] - xi[i - 1]) * (ysav + 4 * yi[i] + yi[i + 1]) / 6.0;
40  tc += ti;
41  // save and replace
42  yi[i] = tm;
43  ysav = yi[i + 1];
44  yi[i + 1] = tc;
45  i += 2;
46  }
47  //-------------------- case when npts is even
48  if (i == npts - 1) {
49  ti = (xi[i] - xi[i - 1]) * (yi[i] + ysav) / 2.0;
50  yi[i] = tc + ti;
51  }
52 }
defs in EVSL
This file contains function prototypes and constant definitions internally used in EVSL...
structs used in evsl
Defs for blaslapack routines.
void simpson(double *xi, double *yi, int npts)
Definition: simpson.c:27