❶ 求雙線性插值法的c語言程序!幫幫忙!拜託各位了!

ab
t
cd
就是兩次線性插值,先在x方向插出t上下方的_t1、_t2,然後再用它們插出t來
floattest(floatx,floaty)
{
float_t1,_t2,t;
_t1=a+(b-a)*(x-ax)/(bx-ax);
_t2=c+(d-c)*(x-cx)/(dx-cx);
t=_t1+(_t2-_t1)*(y-ay);
returnt;
}

❷ 三次樣條插值用c語言具體怎麼做

void SPL(int n, double *x, double *y, int ni, double *xi, double *yi); 是你所要。
已知 n 個點 x,y; x 必須已按順序排好。要插值 ni 點,橫坐標 xi[], 輸出 yi[]。
程序里用double 型,保證計算精度。

SPL調用現成的程序。
現成的程序很多。端點處理方法不同,結果會有不同。想同matlab比較,你需 嘗試 調用 spline()函數 時,令 end1 為 1, 設 slope1 的值,令 end2 為 1 設 slope2 的值。

❸ 求c語言寫的雙三次插值函數

void SPL(int n, double *x, double *y, int ni, double *xi, double *yi); 是你所要。
已知 n 個點 x,y; x 必須已按順序排好。要插值 ni 點,橫坐標 xi[], 輸出 yi[]。
程序里用double 型,保證計算精度。

SPL調用現成的程序。
現成的程序很多。端點處理方法不同,結果會有不同。想同matlab比較,你需 嘗試 調用 spline()函數 時,令 end1 為 1, 設 slope1 的值,令 end2 為 1 設 slope2 的值。

#include <stdio.h>
#include <math.h>

int spline (int n, int end1, int end2,
double slope1, double slope2,
double x[], double y[],
double b[], double c[], double d[],
int *iflag)
{
int nm1, ib, i, ascend;
double t;
nm1 = n - 1;
*iflag = 0;
if (n < 2)
{ /* no possible interpolation */
*iflag = 1;
goto LeaveSpline;
}
ascend = 1;
for (i = 1; i < n; ++i) if (x[i] <= x[i-1]) ascend = 0;
if (!ascend)
{
*iflag = 2;
goto LeaveSpline;
}
if (n >= 3)
{
d[0] = x[1] - x[0];
c[1] = (y[1] - y[0]) / d[0];
for (i = 1; i < nm1; ++i)
{
d[i] = x[i+1] - x[i];
b[i] = 2.0 * (d[i-1] + d[i]);
c[i+1] = (y[i+1] - y[i]) / d[i];
c[i] = c[i+1] - c[i];
}
/* ---- Default End conditions */
b[0] = -d[0];
b[nm1] = -d[n-2];
c[0] = 0.0;
c[nm1] = 0.0;
if (n != 3)
{
c[0] = c[2] / (x[3] - x[1]) - c[1] / (x[2] - x[0]);
c[nm1] = c[n-2] / (x[nm1] - x[n-3]) - c[n-3] / (x[n-2] - x[n-4]);
c[0] = c[0] * d[0] * d[0] / (x[3] - x[0]);
c[nm1] = -c[nm1] * d[n-2] * d[n-2] / (x[nm1] - x[n-4]);
}
/* Alternative end conditions -- known slopes */
if (end1 == 1)
{
b[0] = 2.0 * (x[1] - x[0]);
c[0] = (y[1] - y[0]) / (x[1] - x[0]) - slope1;
}
if (end2 == 1)
{
b[nm1] = 2.0 * (x[nm1] - x[n-2]);
c[nm1] = slope2 - (y[nm1] - y[n-2]) / (x[nm1] - x[n-2]);
}
/* Forward elimination */
for (i = 1; i < n; ++i)
{
t = d[i-1] / b[i-1];
b[i] = b[i] - t * d[i-1];
c[i] = c[i] - t * c[i-1];
}
/* Back substitution */
c[nm1] = c[nm1] / b[nm1];
for (ib = 0; ib < nm1; ++ib)
{
i = n - ib - 2;
c[i] = (c[i] - d[i] * c[i+1]) / b[i];
}
b[nm1] = (y[nm1] - y[n-2]) / d[n-2] + d[n-2] * (c[n-2] + 2.0 * c[nm1]);
for (i = 0; i < nm1; ++i)
{
b[i] = (y[i+1] - y[i]) / d[i] - d[i] * (c[i+1] + 2.0 * c[i]);
d[i] = (c[i+1] - c[i]) / d[i];
c[i] = 3.0 * c[i];
}
c[nm1] = 3.0 * c[nm1];
d[nm1] = d[n-2];
}
else
{
b[0] = (y[1] - y[0]) / (x[1] - x[0]);
c[0] = 0.0;
d[0] = 0.0;
b[1] = b[0];
c[1] = 0.0;
d[1] = 0.0;
}
LeaveSpline:
return 0;
}

double seval (int n, double u,
double x[], double y[],
double b[], double c[], double d[],
int *last)
{
int i, j, k;
double w;
i = *last;
if (i >= n-1) i = 0;
if (i < 0) i = 0;
if ((x[i] > u) || (x[i+1] < u))
{
i = 0;
j = n;
do
{
k = (i + j) / 2;
if (u < x[k]) j = k;
if (u >= x[k]) i = k;
}
while (j > i+1);
}
*last = i;
w = u - x[i];
w = y[i] + w * (b[i] + w * (c[i] + w * d[i]));
return (w);
}

void SPL(int n, double *x, double *y, int ni, double *xi, double *yi)
{
double *b, *c, *d;
int iflag,last,i;
b = (double *) malloc(sizeof(double) * n);
c = (double *)malloc(sizeof(double) * n);
d = (double *)malloc(sizeof(double) * n);
if (!d) { printf("no enough memory for b,c,d\n");}
else {
spline (n,0,0,0,0,x,y,b,c,d,&iflag);
if (iflag==0) printf("I got coef b,c,d now\n"); else printf("x not in order or other error\n");
for (i=0;i<ni;i++) yi[i] = seval(ni,xi[i],x,y,b,c,d,&last);
free(b);free(c);free(d);
};
}

main(){
double x[6]={0.,1.,2.,3.,4.,5};
double y[6]={0.,0.5,2.0,1.6,0.5,0.0};
double u[8]={0.5,1,1.5,2,2.5,3,3.5,4};
double s[8];
int i;
SPL(6, x,y, 8, u, s);
for (i=0;i<8;i++) printf("%lf %lf \n",u[i],s[i]);
return 0;
}

❹ 拉格朗日插值用c語言怎麼編程各位高手幫幫忙啦

下,用的是C++
#include <iostream>
#include <iomanip>
#include <stdlib.h>
using namespace std;
#define N 100
void lagrange()
{
int n,k,m,q=1;
float x[N],y[N],xx,yyy1,yyy2,yy1,yy2,yy3;
cout<<"請輸入X的個數:";
cin>>n;
for(k=0;k<=n-1;k++)
{
cout<<"請輸入X"<<k<<"的值:";
cin>>x[k];
cout<<"請輸入Y"<<k<<"的值:";
cin>>y[k];
}
system("cls");
cout<<"則Xi與Yi表格如下:"<<endl;
cout<<"Xi"<<" ";for(k=0;k<=n-1;k++)cout<<setiosflags(ios::left)<<setw(10)<<x[k];
cout<<endl;
cout<<"Yi"<<" ";for(k=0;k<=n-1;k++)cout<<setiosflags(ios::left)<<setw(10)<<y[k];
cout<<endl;
while(q)
{
cout<<"請輸入所求x的值:";
cin>>xx;
while(xx>x[k-1]||xx<x[0])
{
cout<<"輸入錯誤,請重新輸入:";
cin>>xx;
}
for(k=0;k<=n-1;k++)
{
if(xx<x[k])
{
m=k-1;
k=n-1;
}
}
yyy1=y[m]*((xx-x[m+1])/(x[m]-x[m+1]))+y[m+1]*((xx-x[m])/(x[m+1]-x[m]));
cout<<"則拉格朗日分段線性插值為:"<<yyy1<<endl;
for(k=0;k<=n-1;k++)
{
if(xx<x[k])
{
m=k-1;
k=n-1;
}
}
if((xx-x[m])>(x[m+1]-xx))m=m+1;
else m=m;
yy1=y[m-1]*((xx-x[m])*(xx-x[m+1]))/((x[m-1]-x[m])*(x[m-1]-x[m+1]));
yy2=y[m]*((xx-x[m-1])*(xx-x[m+1]))/((x[m]-x[m-1])*(x[m]-x[m+1]));
yy3=y[m+1]*((xx-x[m-1])*(xx-x[m]))/((x[m+1]-x[m-1])*(x[m+1]-x[m]));
yyy2=yy1+yy2+yy3;
cout<<"則拉格朗日分段二次插值為:"<<yyy2<<endl;
cout<<"是否輸入其餘要求x的值[是(1),否(0)]:";
cin>>q;
}
system("cls");
}
void main()
{
lagrange();
}
另外,站長團上有產品團購,便宜有保證

❺ 求用c語言編寫牛頓插值法

程序代碼如下。
希望能幫助到你!

牛頓內插容值法
#include<stdio.h>
#include<math.h>
#define N 4
void Difference(float *x,float *y,int n)
{
float *f;
int k,i;
f=(float *)malloc(n*sizeof(float));
for(k=1;k<=n;k++)
{
f[0]=y[k];
for(i=0;i<k;i++)
f[i+1]=(f[i]-y[i])/(x[k]-x[i]);
y[k]=f[k];
}
return;
}
main()
{
int i;
float varx=0.895,b;
float x[N+1]={0.4,0.55,0.65,0.8,0.9};
float y[N+1]={0.41075,0.57815,0.69675,0.88811,1.02652};
Difference(x,(float *)y,N);
b=y[N];
for(i=N-1;i>=0;i--)b=b*(varx-x[i])+y[i];
printf("Nn(%f)=%f",varx,b);
getchar();
}

❻ Akima 插值和樣條插值的C語言源代碼,要有注釋。

Akima插值

附帶的圖片為運行結果

#include"stdio.h"

#include"math.h"

#include"interpolation.h"

voidinterpolation_akima(AKINTEPap){

intnum,k,kk,m,l;

doublepio,*mtr,*x,*y,u[5],p,q;

num=ap->n;k=ap->k;

pio=ap->t;mtr=ap->s;

x=ap->x;y=ap->y;

if(num<1){

return;

}

elseif(num==1){

mtr[0]=mtr[4]=y[0];

return;

}

elseif(num==2){

mtr[0]=y[0];

mtr[1]=(y[1]-y[0])/(x[1]-x[0]);

if(k<0)

mtr[4]=(y[0]*(pio-x[1])-y[1]*(pio-x[0]))/(x[0]-x[1]);

return;

}

if(k<0){

if(pio<=x[1])kk=0;

elseif(pio>=x[num-1])kk=num-2;

else{

kk=1;m=num;

while(((kk-m)!=1)&&((kk-m)!=-1)){

l=(kk+m)/2;

if(pio<x[l-1])m=l;

elsekk=l;

}

kk--;

}

}

elsekk=k;

if(kk>=num-1)kk=num-2;

u[2]=(y[kk+1]-y[kk])/(x[kk+1]-x[kk]);

if(num==3){

if(kk==0){

u[3]=(y[2]-y[1])/(x[2]-x[1]);

u[4]=2.0*u[3]-u[2];

u[1]=2.0*u[2]-u[3];

u[0]=2.0*u[1]-u[2];

}

else{

u[1]=(y[1]-y[0])/(x[1]-x[0]);

u[0]=2.0*u[1]-u[2];

u[3]=2.0*u[2]-u[1];

u[4]=2.0*u[3]-u[2];

}

}

else{

if(kk<=1){

u[3]=(y[kk+2]-y[kk+1])/(x[kk+2]-x[kk+1]);

if(kk==1){

u[1]=(y[1]-y[0])/(x[1]-x[0]);

u[0]=2.0*u[1]-u[2];

if(num==4)u[4]=2.0*u[3]-u[2];

elseu[4]=(y[4]-y[3])/(x[4]-x[3]);

}

else{

u[1]=2.0*u[2]-u[3];

u[0]=2.0*u[1]-u[2];

u[4]=(y[3]-y[2])/(x[3]-x[2]);

}

}

elseif(kk>=(num-3)){

u[1]=(y[kk]-y[kk-1])/(x[kk]-x[kk-1]);

if(kk==(num-3)){

u[3]=(y[num-1]-y[num-2])/(x[num-1]-x[num-2]);

u[4]=2.0*u[3]-u[2];

if(num==4)u[0]=2.0*u[1]-u[2];

elseu[0]=(y[kk-1]-y[kk-2])/(x[kk-1]-x[kk-2]);

}

else{

u[3]=2.0*u[2]-u[1];

u[4]=2.0*u[3]-u[2];

u[0]=(y[kk-1]-y[kk-2])/(x[kk-1]-x[kk-2]);

}

}

else{

u[1]=(y[kk]-y[kk-1])/(x[kk]-x[kk-1]);

u[0]=(y[kk-1]-y[kk-2])/(x[kk-1]-x[kk-2]);

u[3]=(y[kk+2]-y[kk+1])/(x[kk+2]-x[kk+1]);

u[4]=(y[kk+3]-y[kk+2])/(x[kk+3]-x[kk+2]);

}

}

mtr[0]=fabs(u[3]-u[2]);

mtr[1]=fabs(u[0]-u[1]);

if((fabs(mtr[0])<0.0000001)&&(fabs(mtr[1])<0.0000001))

p=(u[1]+u[2])/2.0;

elsep=(mtr[0]*u[1]+mtr[1]*u[2])/(mtr[0]+mtr[1]);

mtr[0]=fabs(u[3]-u[4]);

mtr[1]=fabs(u[2]-u[1]);

if((fabs(mtr[0])<0.0000001)&&(fabs(mtr[1])<0.0000001))

q=(u[2]+u[3])/2.0;

elseq=(mtr[0]*u[2]+mtr[1]*u[3])/(mtr[0]+mtr[1]);

mtr[0]=y[kk];

mtr[1]=p;

mtr[3]=x[kk+1]-x[kk];

mtr[2]=(3.0*u[2]-2.0*p-q)/mtr[3];

mtr[3]=(q+p-2.0*u[2])/(mtr[3]*mtr[3]);

if(k<0){

p=pio-x[kk];

mtr[4]=mtr[0]+mtr[1]*p+mtr[2]*p*p+mtr[3]*p*p*p;

}

return;

}

main()

{

doublex[11]={3.0,5.0,8.0,13.0,17.0,25.0,27.0,29.0,31.0,35.0,39.0};

doubley[11]={7.0,10.0,11.0,17.0,23.0,18.0,13.0,6.0,3.0,1.0,0.0};

AKINTEaa={11,x,y,-1,14.0,{0}};

AKINTEab={11,x,y,-1,28.0,{0}};

printf(" ");

interpolation_akima(&aa);

printf("x=%6.3f,f(x)=%e ",aa.t,aa.s[4]);

printf("mtr0=%e,mtr1=%e,mtr2=%e,mtr3=%e ",aa.s[0],aa.s[1],aa.s[2],aa.s[3]);

printf(" ");

interpolation_akima(&ab);

printf("x=%6.3f,f(x)=%e ",ab.t,ab.s[4]);

printf("mtr0=%e,mtr1=%e,mtr2=%e,mtr3=%e ",ab.s[0],ab.s[1],ab.s[2],ab.s[3]);

printf(" ");

}

三次樣條插值的實現

1、程序比較簡單的:

#include<iostream>

#include<iomanip>

usingnamespacestd;

constintMAX=50;

floatx[MAX],y[MAX],h[MAX];

floatc[MAX],a[MAX],fxym[MAX];

floatf(intx1,intx2,intx3){

floata=(y[x3]-y[x2])/(x[x3]-x[x2]);

floatb=(y[x2]-y[x1])/(x[x2]-x[x1]);

return(a-b)/(x[x3]-x[x1]);

}//求差分

voidcal_m(intn){//用追趕法求解出彎矩向量M……

floatB[MAX];

B[0]=c[0]/2;

for(inti=1;i<n;i++)

B[i]=c[i]/(2-a[i]*B[i-1]);

fxym[0]=fxym[0]/2;

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

fxym[i]=(fxym[i]-a[i]*fxym[i-1])/(2-a[i]*B[i-1]);

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

fxym[i]=fxym[i]-B[i]*fxym[i+1];

}

voidprintout(intn);

intmain(){

intn,i;charch;

do{

cout<<"Pleaseputinthenumberofthedots:";

cin>>n;

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

cout<<"PleaseputinX"<<i<<':';

cin>>x[i];//cout<<endl;

cout<<"PleaseputinY"<<i<<':';

cin>>y[i];//cout<<endl;

}

for(i=0;i<n;i++)//求步長

h[i]=x[i+1]-x[i];

cout<<"Please輸入邊界條件 1:已知兩端的一階導數 2:兩端的二階導數已知 默認:自然邊界條件 ";

intt;

floatf0,f1;

cin>>t;

switch(t){

case1:cout<<"PleaseputinY0'Y"<<n<<"' ";

cin>>f0>>f1;

c[0]=1;a[n]=1;

fxym[0]=6*((y[1]-y[0])/(x[1]-x[0])-f0)/h[0];

fxym[n]=6*(f1-(y[n]-y[n-1])/(x[n]-x[n-1]))/h[n-1];

break;

case2:cout<<"PleaseputinY0"Y"<<n<<"" ";

cin>>f0>>f1;

c[0]=a[n]=0;

fxym[0]=2*f0;fxym[n]=2*f1;

break;

default:cout<<"不可用 ";//待定

};//switch

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

fxym[i]=6*f(i-1,i,i+1);

for(i=1;i<n;i++){

a[i]=h[i-1]/(h[i]+h[i-1]);

c[i]=1-a[i];

}

a[n]=h[n-1]/(h[n-1]+h[n]);

cal_m(n);

cout<<" 輸出三次樣條插值函數: ";

printout(n);

cout<<"Doyoutohaveanthertry?y/n:";

cin>>ch;

}while(ch=='y'||ch=='Y');

return0;

}

voidprintout(intn){

cout<<setprecision(6);

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

cout<<i+1<<":["<<x[i]<<","<<x[i+1]<<"] "<<" ";

/*

cout<<fxym[i]/(6*h[i])<<"*("<<x[i+1]<<"-x)^3+"<<<<"*(x-"<<x[i]<<")^3+"

<<(y[i]-fxym[i]*h[i]*h[i]/6)/h[i]<<"*("<<x[i+1]<<"-x)+"

<<(y[i+1]-fxym[i+1]*h[i]*h[i]/6)/h[i]<<"(x-"<<x[i]<<") ";

cout<<endl;*/

floatt=fxym[i]/(6*h[i]);

if(t>0)cout<<t<<"*("<<x[i+1]<<"-x)^3";

elsecout<<-t<<"*(x-"<<x[i+1]<<")^3";

t=fxym[i+1]/(6*h[i]);

if(t>0)cout<<"+"<<t<<"*(x-"<<x[i]<<")^3";

elsecout<<"-"<<-t<<"*(x-"<<x[i]<<")^3";

cout<<" ";

t=(y[i]-fxym[i]*h[i]*h[i]/6)/h[i];

if(t>0)cout<<"+"<<t<<"*("<<x[i+1]<<"-x)";

elsecout<<"-"<<-t<<"*("<<x[i+1]<<"-x)";

t=(y[i+1]-fxym[i+1]*h[i]*h[i]/6)/h[i];

if(t>0)cout<<"+"<<t<<"*(x-"<<x[i]<<")";

elsecout<<"-"<<-t<<"*(x-"<<x[i]<<")";

cout<<endl<<endl;

}

cout<<endl;

}

2、程序比較復雜的:

(程序前面的01.,02.,03.等等為語句編號,實際應用時請一一刪除)01./*=======================================================================*/

02.#include<stdio.h>

03.////////////////////////////////////////////////////////////////////////////////

04.#defineMAXNUM50//定義樣條數據區間個數最多為50個

05.typedefstructSPLINE//定義樣條結構體,用於存儲一條樣條的所有信息

06.{//初始化數據輸入

07.floatx[MAXNUM+1];//存儲樣條上的點的x坐標,最多51個點

08.floaty[MAXNUM+1];//存儲樣條上的點的y坐標,最多51個點

09.unsignedintpoint_num;//存儲樣條上的實際的點的個數

10.floatbegin_k1;//開始點的一階導數信息

11.floatend_k1;//終止點的一階導數信息

12.//floatbegin_k2;//開始點的二階導數信息

13.//floatend_k2;//終止點的二階導數信息

14.//計算所得的樣條函數S(x)

15.floatk1[MAXNUM+1];//所有點的一階導數信息

16.floatk2[MAXNUM+1];//所有點的二階導數信息

17.//51個點之間有50個段,func[]存儲每段的函數系數

18.floata3[MAXNUM],a1[MAXNUM];

19.floatb3[MAXNUM],b1[MAXNUM];

20.//分段函數的形式為Si(x)=a3[i]*{x(i+1)-x}^3+a1[i]*{x(i+1)-x}+

21.//b3[i]*{x-x(i)}^3+b1[i]*{x-x(i)}

22.//xi為x[i]的值,xi_1為x[i+1]的值

23.}SPLINE,*pSPLINE;

24.typedefintRESULT;//返回函數執行的結果狀態,下面為具體的返回選項

25.#ifndefTRUE

26.#defineTRUE1

27.#endif

28.#ifndefFALSE

29.#defineFALSE-1

30.#endif

31.#ifndefNULL

32.#defineNULL0

33.#endif

34.#ifndefERR

35.#defineERR-2

36.#endif

37.//////////////////////////////////////////////////////////////////////////////////

38./*===============================================================================

39.***函數名稱:Spline3()

40.***功能說明:完成三次樣條差值,其中使用追趕法求解M矩陣

41.***入口參數:(pSPLINE)pLine樣條結構體指針pLine中的x[],y[],num,begin_k1,end_k1

42.***出口參數:(pSPLINE)pLine樣條結構體指針pLine中的函數參數

43.***返回參數:返回程序執行結果的狀態TRUEorFALSE

44.================================================================================*/

45.RESULTSpline3(pSPLINEpLine)

46.{

47.floatH[MAXNUM]={0};//小區間的步長

48.floatFi[MAXNUM]={0};//中間量

49.floatU[MAXNUM+1]={0};//中間量

50.floatA[MAXNUM+1]={0};//中間量

51.floatD[MAXNUM+1]={0};//中間量

52.floatM[MAXNUM+1]={0};//M矩陣

53.floatB[MAXNUM+1]={0};//追趕法中間量

54.floatY[MAXNUM+1]={0};//追趕法中間變數

55.inti=0;

56.////////////////////////////////////////計算中間參數

57.if((pLine->point_num<3)||(pLine->point_num>MAXNUM+1))

58.{

59.returnERR;//輸入數據點個數太少或太多

60.}

61.for(i=0;i<=pLine->point_num-2;i++)

62.{//求H[i]

63.H[i]=pLine->x[i+1]-pLine->x[i];

64.Fi[i]=(pLine->y[i+1]-pLine->y[i])/H[i];//求F[x(i),x(i+1)]

65.}

66.for(i=1;i<=pLine->point_num-2;i++)

67.{//求U[i]和A[i]和D[i]

68.U[i]=H[i-1]/(H[i-1]+H[i]);

69.A[i]=H[i]/(H[i-1]+H[i]);

70.D[i]=6*(Fi[i]-Fi[i-1])/(H[i-1]+H[i]);

71.}

72.//若邊界條件為1號條件,則

73.U[i]=1;

74.A[0]=1;

75.D[0]=6*(Fi[0]-pLine->begin_k1)/H[0];

76.D[i]=6*(pLine->end_k1-Fi[i-1])/H[i-1];

77.//若邊界條件為2號條件,則

78.//U[i]=0;

79.//A[0]=0;

80.//D[0]=2*begin_k2;

81.//D[i]=2*end_k2;

82./////////////////////////////////////////追趕法求解M矩陣

83.B[0]=A[0]/2;

84.for(i=1;i<=pLine->point_num-2;i++)

85.{

86.B[i]=A[i]/(2-U[i]*B[i-1]);

87.}

88.Y[0]=D[0]/2;

89.for(i=1;i<=pLine->point_num-1;i++)

90.{

91.Y[i]=(D[i]-U[i]*Y[i-1])/(2-U[i]*B[i-1]);

92.}

93.M[pLine->point_num-1]=Y[pLine->point_num-1];

94.for(i=pLine->point_num-1;i>0;i--)

95.{

96.M[i-1]=Y[i-1]-B[i-1]*M[i];

97.}

98.//////////////////////////////////////////計算方程組最終結果

99.for(i=0;i<=pLine->point_num-2;i++)

100.{

101.pLine->a3[i]=M[i]/(6*H[i]);

102.pLine->a1[i]=(pLine->y[i]-M[i]*H[i]*H[i]/6)/H[i];

103.pLine->b3[i]=M[i+1]/(6*H[i]);

104.pLine->b1[i]=(pLine->y[i+1]-M[i+1]*H[i]*H[i]/6)/H[i];

105.}

106.returnTRUE;

107.}

108.//////////////////////////////////////////////////////////////////////////////////

109.SPLINEline1;

110.pSPLINEpLine1=&line1;

111.//////////////////////////////////////////////////////////////////////////////////

112.main()

113.{

114.line1.x[0]=27.7;

115.line1.x[1]=28;

116.line1.x[2]=29;

117.line1.x[3]=30;

118.line1.y[0]=4.1;

119.line1.y[1]=4.3;

120.line1.y[2]=4.1;

121.line1.y[3]=3.0;

122.line1.point_num=4;

123.line1.begin_k1=3.0;

124.line1.end_k1=-4.0;

125.Spline3(pLine1);

126.return0;

127.}

128.//////////////////////////////////////////////////////////////////////////////////

❼ 求C語言二維插值程序代碼

我沒有~