⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threesamples1.java

📁 数值算法例子,牛顿插值,拉格朗日,三次样条
💻 JAVA
字号:
/*@author 邱宇峰 ,software project031,
 *2004,9,30
 */
 
 import java.awt.*;
 import java.awt.event.*;
 
class threeSamples1{
 	double s1;
	double h[];
	double a[];
	double b[];
	double c[];
	double d[];
	double s2[];
	double newY;
	int X=0;

		public threeSamples1(int location[][],int count,Graphics g){
			h=new double[count];
			a=new double[count];
			b=new double[count];
			c=new double[count];
			d=new double[count];
			s2=new double[count];
			for(int i=0;i<count-1;i++) h[i]=((double)location[i+1][0]-(double)location[i][0]);
			a[1]=2.0*(h[0]+h[1]);
			for(int i=2;i<count-1;i++) a[i]=2*(h[i-1]+h[i])-(h[i-1]*h[i-1])/a[i-1];
			for(int i=1;i<count;i++) c[i]=((double)location[i][1]-(double)location[i-1][1])/h[i-1];
			for(int i=1;i<count-1;i++) d[i]=6*(c[i+1]-c[i]);
			b[1]=d[1];
			for(int i=2;i<count-1;i++) b[i]=d[i]-(b[i-1]*h[i-1])/a[i-1];
			s2[0]=0;s2[count-1]=0;
			s2[count-2]=b[count-2]/a[count-2];
			for(int i=count-3;i>=1;i--) s2[i]=(b[i]-h[i]*s2[i+1])/a[i];
			g.setColor(Color.black);
			for(int i=0;i<count-1;i++){
				X=location[i][0];
				while(X<=location[i+1][0]){
					for(long h=0;h<1000000;h++);
						s1=c[i+1]-s2[i+1]*h[i]/6-s2[i]*h[i]/3;
						newY=(double)location[i][1]+s1*((double)X-(double)location[i][0])+s2[i]*((double)X-(double)location[i][0])*((double)X-(double)location[i][0])/2+(s2[i+1]-s2[i])*((double)X-(double)location[i][0])*((double)X-(double)location[i][0])*((double)X-(double)location[i][0])/(6*h[i]);
						g.drawString("*",X,(int)newY);	
						X++;
				}
			}
		}
	}
		

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -