File:Chebyshev.png
頁面內容不支援其他語言。
外觀
Chebyshev.png (201 × 201 像素,檔案大小:26 KB,MIME 類型:image/png)
Transferred from en.wikipedia to Commons by Maksim.
The original description page was here. All following user names refer to en.wikipedia.
//
此作品為自由軟體;您可依自由軟體基金會所發表的GNU通用公共授權條款的條款散佈與/或修改,無論您依據的是本授權條款的第2版本或之後的任何版本。本作品發佈的目的是希望可以提供幫助,但不負任何擔保責任;亦無隱含對適售性或特定用途的適用性的情形擔保。請參考GNU通用公共授權條款的第2版與第3版。http://www.gnu.org/licenses/gpl.htmlGPLGNU General Public Licensetruetrue |
#include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> #define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825 #define PI2 (PI*2) #define SQ2 1.414213562373095048801688724209698078569671875376948073176679737990732478462 #define FI 1.618033988749894848204586834365638117720309179805762862135448622705260462818902449707207204 #define SX 201 #define SY 201 #define BPL ((SX*3+3)&~3) unsigned char bhdr[54]={ 0x42, 0x4D, 0x36, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x12, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char po[BPL]; double gr[SY][SX][3]; void drawit(); int main(int a, char **b) { FILE *o; int x, y, c; //Some variable declarations may not be relevant double t; char *p; srand(time(0)); drawit(); p=bhdr+2; *p++=x=54+BPL*SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8; p=bhdr+18; *p++=x=SX; *p++=x>>=8; *p++=x>>=8; *p++=x>>=8; *p++=x=SY; *p++=x>>=8; *p++=x>>=8; *p=x>>=8; if(!(o=fopen("func.bmp", "wb"))) { fclose(o); printf("Couldn't open output file.\n"); return(0); } fwrite(bhdr, 54, 1, o); for(x=SX*3;x<BPL;++x) po[x]=0; for(y=SY-1;~y;--y) { for(x=0,p=po;x<SX;++x) for(c=2;~c;--c) *p++=(t=gr[y][x][c])<=0?0:(t>=1?255:t*255); fwrite(po, BPL, 1, o); } fclose(o); return(0); } double minx, miny, maxx, maxy, dlx, dly; double cr, cg, cb; void func(int f, double x, double *y, double *dydx) { double x2, x3, x4, x5, x6, x7; x2=x*x; x3=x2*x; x4=x3*x; x5=x4*x; x6=x5*x; x7=x6*x; switch(f) { //x case 0: *y=x; *dydx=1; break; //sinh(x) case 1: *y=(exp(x)-exp(-x))/2; *dydx=(exp(x)+exp(-x))/2; break; //cosh(x) case 2: *y=(exp(x)+exp(-x))/2; *dydx=(exp(x)-exp(-x))/2; break; //tanh(x) case 3: *y=(exp(x)-exp(-x))/(exp(x)+exp(-x)); *dydx=1-*y**y; break; //Chebyshev 0-7 case 100: *y=1; *dydx=0; break; case 101: *y=x; *dydx=1; break; case 102: *y=2*x2-1; *dydx=4*x; break; case 103: *y=4*x3-3*x; *dydx=12*x2-3; break; case 104: *y=8*x4-8*x2+1; *dydx=32*x3-16*x; break; case 105: *y=16*x5-20*x3+5*x; *dydx=80*x4-60*x2+5; break; case 106: *y=32*x6-48*x4+18*x2-1; *dydx=192*x5-192*x3+38*x; break; case 107: *y=64*x7-112*x5+56*x3-7*x; *dydx=448*x6-560*x4+168*x2-7; break; default: *y=100; *dydx=0; break; } } void subp(int x, int y, double r, double g, double b) { if(x>=0&&y>=0&&x<SX&&y<SY) { gr[y][x][0]-=r; gr[y][x][1]-=g; gr[y][x][2]-=b; } } void drawdot(double x, double y) { int ix, iy; double dx, dy, ax, ay; x=(x-minx)/(maxx-minx)*(SX-1)+.5; y=(y-maxy)/(miny-maxy)*(SY-1)+.5; ix=floor(x); dx=x-ix; iy=floor(y); dy=y-iy; ax=1-dx; ay=1-dy; subp(ix-1, iy-1, cr*ax*ay*.05, cg*ax*ay*.05, cb*ax*ay*.05); subp(ix , iy-1, cr *ay*.05, cg *ay*.05, cb *ay*.05); subp(ix+1, iy-1, cr*dx*ay*.05, cg*dx*ay*.05, cb*dx*ay*.05); subp(ix-1, iy , cr*ax *.05, cg*ax *.05, cb*ax *.05); subp(ix , iy , cr *.05, cg *.05, cb *.05); subp(ix+1, iy , cr*dx *.05, cg*dx *.05, cb*dx *.05); subp(ix-1, iy+1, cr*ax*dy*.05, cg*ax*dy*.05, cb*ax*dy*.05); subp(ix , iy+1, cr *dy*.05, cg *dy*.05, cb *dy*.05); subp(ix+1, iy+1, cr*dx*dy*.05, cg*dx*dy*.05, cb*dx*dy*.05); } void drawhorz(double y) { int ix, iy; double dy, ay; y=(y-maxy)/(miny-maxy)*(SY-1)+.5; iy=floor(y); dy=y-iy; ay=1-dy; for(ix=0;ix<SX;++ix) { subp(ix , iy-1, cr *ay , cg *ay , cb *ay ); subp(ix , iy , cr , cg , cb ); subp(ix , iy+1, cr *dy , cg *dy , cb *dy ); } } void drawvert(double x) { int ix, iy; double dx, ax; x=(x-minx)/(maxx-minx)*(SX-1)+.5; ix=floor(x); dx=x-ix; ax=1-dx; for(iy=0;iy<SY;++iy) { subp(ix-1, iy , cr*ax , cg*ax , cb*ax ); subp(ix , iy , cr , cg , cb ); subp(ix+1, iy , cr*dx , cg*dx , cb*dx ); } } void drawaxes() { drawhorz(0); drawvert(0); } void drawgrid() { int a, b; for(a=ceil(miny/dly)-1;a<=floor(maxy/dly)+1;++a) drawhorz(a*dly); for(a=ceil(minx/dlx)-1;a<=floor(maxx/dlx)+1;++a) drawvert(a*dlx); } void drawfunc(int f) { double x, y, dydx, pfx, pfy; pfx=(maxx-minx)/(SX-1); pfy=(maxy-miny)/(SY-1); for(x=minx;x<maxx;x+=.1*pfx/sqrt(1+dydx*dydx/((pfy*pfy)/(pfx*pfx)))) { func(f, x, &y, &dydx); drawdot(x, y); } } void drawit() { int x, y, c; for(y=0;y<SY;++y) for(x=0;x<SY;++x) for(c=0;c<3;++c) gr[y][x][c]=1; //Chebyshev 0, 1, 2, 3, 4, 5, 6, 7 minx=miny=-5/4.; maxx=maxy=5/4.; dlx=dly=1; cr=.6; cg=.6; cb=.6; drawfunc(100); cr=.1; cg=.8; cb=.8; drawfunc(101); cr=.8; cg=.8; cb=.1; drawfunc(102); cr=.8; cg=.1; cb=.8; drawfunc(103); cr=.1; cg=.1; cb=.8; drawfunc(104); cr=.1; cg=.1; cb=.1; drawfunc(105); cr=.1; cg=.8; cb=.1; //drawfunc(106); cr=.8; cg=.1; cb=.1; //drawfunc(107); /* //sinh, cosh, tanh minx=miny=-5; maxx=maxy=5; dlx=dly=1; cr=.1; cg=cb=.8; drawfunc(1); cg=.1; cb=cr=.8; drawfunc(2); cb=.1; cr=cg=.8; drawfunc(3); */ cr=cg=cb=.8; drawaxes(); cr=cg=cb=.1; drawgrid(); cr=cg=cb=.025; dlx=dly=.1; drawgrid(); } //
date/time | username | edit summary |
---|---|---|
01:07, 12 September 2004 | en:User:Cyp | (C source) |
01:04, 12 September 2004 | en:User:Cyp | (Graph of Chebyshev polynomials) |
原始上傳日誌
Legend: (cur) = this is the current file, (del) = delete this old version, (rev) = revert to this old version.
Click on date to download the file or see the image uploaded on that date.
- (del) (cur) 01:04, 12 September 2004 . . en:User:Cyp Cyp ( en:User_talk:Cyp Talk) . . 201x201 (26147 bytes) (Graph of Chebyshev polynomials)
在此檔案描寫的項目
描繪內容
image/png
26,147 位元組
201 像素
201 像素
檔案歷史
點選日期/時間以檢視該時間的檔案版本。
日期/時間 | 縮圖 | 尺寸 | 使用者 | 備註 | |
---|---|---|---|---|---|
目前 | 2006年3月18日 (六) 18:01 | 201 × 201(26 KB) | Maksim | La bildo estas kopiita de wikipedia:en. La originala priskribo estas: //{{GPL}}<pre> #include <stdio.h> #include <math.h> #include <stdlib.h> #include <time.h> #define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089 |
檔案用途
全域檔案使用狀況
以下其他 wiki 使用了這個檔案:
- fa.wikipedia.org 的使用狀況
- fr.wikipedia.org 的使用狀況
- pms.wikipedia.org 的使用狀況
- sr.wikipedia.org 的使用狀況
隱藏分類: