Can't see outputs

Can't see the fail in splines method

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
45
46
47
48
49
50
51
52
/*LA INTERPOLACION POR SPLINES DE GRADO 2*/
  a[0] = f[0];
  c[0] = c0;
  b[0] = (f[1] - f[0] - c0 * (x[1] - x[0]) * (x[1] - x[0])) / (x[1] - x[0]);

  for(int i = 1; i < a.dim(); i++){
    a[i] = f[i];
    b[i] = b[i-1] + 2 * c[i-1] * (x[i] - x[i-1]);
    c[i] = (f[i+1] - a[i] - b[i] * (x[i+1] - x[i])) / (x[i+1] - x[i]) * (x[i+1] - x[i]);
  }

  return 0;

/******************************************************/
/* FUNCION QUE EVALUA EN UN PUNTO x0 LOS SPLINES DE GRADO 2 */

  for(int i = a.dim()-1; i >= 0; i--){
    if(x[i] < x0){
        return a[i] + b[i] * (x0 - x[i]) + c[i] * (x0 - x[i]) * (x0 - x[i]);
    }
    return a[0] + b[0] * (x0 - x[0]) + c[0] * (x0 - x[0]) * (x0 - x[0]);
  }

/******************************************************/
/*DIFERENCIAS DE NEWTON*/

  for(int k=0;k<=N;k++){
    B[k]=F[k];
  }
  A[0]=F[0];
  for(int k=1;k<=N;k++){
    for(int l=0;l<=(N-k);l++){
      if(X[k+l]==X[l]){
        return(Array1D< real >()); // SE RETORNA UN VECTOR VACIO
      }
      B[l]=(B[l+1]-B[l])/(X[k+l]-X[l]);
    }
    A[k]=B[0];
  }
  return(A);
/******************************************************/
/*NEWTON EN UN PUNTO*/

    int N=A.dim()-1;
    // HACER ALUMNO
	real E=A[N];
	for(int k=N-1;k>=0;k--){
      E=E*(X0-X[k])+A[k];
    }

    return E;
Topic archived. No new replies allowed.