Курсовая работа: Базисные сплайны

#include<iostream>

using namespace std;

double KubichSplain ( int n, double *X, double *Y, double Xp )

{

double *Q, *L, *A, *B, *C, *D, DXp, Yp;

int i, j, k;

Q = new double [n];

L = new double [n];

A = new double [n];

B = new double [n];

C = new double [n];

D = new double [n];

for(i=0;i<n;i++)

if(Xp<=X[i])

{

k=i;

break;

}

Q[1] = (-1) * (X[2]-X[1])/2*(X[1]-X[0] + X[2]-X[1]);

L[1] = (3*(Y[2]-Y[1])/(X[2]-X[1]) - 3*(Y[1]-Y[0])/(X[1]-X[0])) / (2*(X[1]-X[0] + X[2]-X[1]));

C[n-1]=0;

C[0]=0;

for(i=3; i<n; i++)

{

Q[i-1]=(-1) * (X[i]-X[i-1]) / (2*(X[i-1]-X[i-2]+X[i]-X[i-1])+(X[i-1]-X[i-2])*Q[i-2]);

L[i-1]=(3*((Y[i]-Y[i-1])/(X[i]-X[i-1])-(Y[i-1]+Y[i-2])/

(X[i-1]-X[i-2]))-(X[i-1]-X[i-2])*L[i-2])/(2*(X[i-1]-X[i-2]+X[i]-X[i-1])+(X[i-1]-X[i-2])*Q[i-2]);

}

for(i=n-1; i>=2; i--)

К-во Просмотров: 429
Бесплатно скачать Курсовая работа: Базисные сплайны