首页 三次样条插值函数c语言程序

三次样条插值函数c语言程序

举报
开通vip

三次样条插值函数c语言程序三次样条插值函数c语言程序 #include #include using namespace std; const int MAX = 50; float x[MAX], y[MAX], h[MAX]; float c[MAX], a[MAX], fxym[MAX]; float f(int x1, int x2, int x3){ float a = (y[x3] - y[x2]) / (x[x3] - x[x2]); float b = (y[x2] - y[x1]) / (x[x2] - ...

三次样条插值函数c语言程序
三次样条插值函数c语言程序 #include #include using namespace std; const int MAX = 50; float x[MAX], y[MAX], h[MAX]; float c[MAX], a[MAX], fxym[MAX]; float f(int x1, int x2, int x3){ float a = (y[x3] - y[x2]) / (x[x3] - x[x2]); float b = (y[x2] - y[x1]) / (x[x2] - x[x1]); return (a - b)/(x[x3] - x[x1]); } //Çó?î?Ö void cal_m(int n){ //ÓÃ×??Ï??Çó?â?öÍä?ØÏòÁ?M?,?, float B[MAX]; B[0] = c[0] / 2; for(int i = 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]; } void printout(int n); int main(){ int n,i; char ch; do{ cout<<"Please put in the number of the dots:"; cin>>n; for(i = 0; i <= n; i++){ cout<<"Please put in X"<>x[i]; //cout<>y[i]; //cout<>t; switch(t){ case 1:cout<<"Please put in Y0\' Y"<>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; case 2:cout<<"Please put in Y0\" Y"<>f0>>f1; c[0] = a[n] = 0; fxym[0] = 2*f0; fxym[n] = 2*f1; break; default:cout<<"???ÉÓÃ\n";//?ý?? };//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<<"\nÊä?öÈý?ÎÑùÌõ?åÖµº?Êý?º\n"; printout(n); cout<<"Do you to have anther try ? y/n :"; cin>>ch; }while(ch == 'y' || ch == 'Y'); return 0; } void printout(int n){ cout< 0)cout< 0)cout<<"+ "< 0)cout<<" + "<
本文档为【三次样条插值函数c语言程序】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_574951
暂无简介~
格式:doc
大小:17KB
软件:Word
页数:5
分类:生活休闲
上传时间:2017-09-30
浏览量:151