第7章 有限要素法のプログラミング
|
|
|
- みさえ かみいしづ
- 6 years ago
- Views:
Transcription
1 April 3, / 34
2 7.1 ( ) 2 Poisson 2 / 34
3 7.2 femfp.c [1] main( ) input( ) assem( ) ecm( ) f( ) solve( ) gs { solve( ) output( ) 3 / 34
4 7.3 fopen() #include <stdio.h> FILE *fopen(char *fname, char *mode); fname mode ( ) NULL mode mode r rb r+ rb+ w wb w+ wb+ a ab a ab+ 4 / 34
5 fclose() #include <stdio.h> int fclose(file *fp); fopen fp 0 EOF fprintf() include <stdio.h> int fprintf(file *fp, char *fmt,...); fp fmt 5 / 34
6 fputs() #include <stdio.h> int fputs(char *string, FILE *fp); fp string 0 EOF fgets() #include <stdio.h> char *fgets(char *string, int n, FILE *fp); fp string 0 EOF 6 / 34
7 7.4 main() /* The Finite Element Method for the Poisson Equation */ /* Full Matrix Version */ /* The Gauss Elimination Method */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define NDIM1 200 #define NDIM / 34
8 void input(int *nnode, int *nelmt, int *nbc, int ielmt[][3], double x[], double y[], int ibc[]); void assem(int nnode, int nelmt, int nbc, int ielmt[][3], double x[], double y[], int ibc[], double am[][ndim1], double fm[]); void ecm(int ielmt[][3], double x[], double y[], int ie, double ae[][3], double fe[]); void solve(int m, double a[][ndim1], double f[]); void gs_solve(int m, double a[][ndim1], double f[]); void output(double fm[], int nnode, double x[], double y[]); double f(double x, double y); 8 / 34
9 /* Main Program */ int main() { int nnode, nelmt, nbc, ielmt[ndim2][3], ibc[ndim1]; double am[ndim1][ndim1], fm[ndim1], x[ndim1], y[ndim1]; input(&nnode, &nelmt, &nbc, ielmt, x, y, ibc); assem(nnode, nelmt, nbc, ielmt, x, y, ibc, am, fm); solve(nnode, am, fm); //gs_solve(nnode, am, fm); output(fm, nnode, x, y); return(exit_success); [1] : void output(double fm[], int nnode, double x[], double y[]); output(fm, nnode, x, y); 9 / 34
10 input() /* Input */ void input(int *nnode, int *nelmt, int *nbc, int ielmt[][3], double x[], double y[], int ibc[]) { int j; FILE *fpin, *fpout; if((fpin=fopen("indata.txt","r")) == NULL){ printf(" \n"); exit(exit_failure); if((fpout=fopen("outdata.txt","w")) == NULL){ fclose(fpin); printf(" \n"); exit(exit_failure); 10 / 34
11 /* Input of Data */ printf("input (nnode, nelmt, nbc): "); fscanf(fpin, "%d%d%d", nnode, nelmt, nbc); printf("\ninput(x,y) of node i: \n"); for(j=0; j<*nnode; j++){ printf(" for i=%d: \n", j+1); fscanf(fpin, "%lg%lg", &(x[j]), &(y[j])); printf("input(1st, 2nd, 3rd) nodes of element i: \n"); for(j=0; j<*nelmt; j++){ printf(" for i=%d: \n", j+1); fscanf(fpin, "%d%d%d", &(ielmt[j][0]), &(ielmt[j][1]), &(ielmt[j][2])); 11 / 34
12 if(*nbc>0){ printf("input nodes with zero Dirichlet data"); printf(" for i=1 to %d: ", *nbc); for(j=0; j<*nbc; j++) fscanf(fpin, "%d", &(ibc[j])); printf("\n"); printf("nodes of elements \n"); for(j=0; j<2; j++) printf(" i i1 i2 i3 "); printf("\n"); for(j=0; j<*nelmt; j+=2){ printf("*%4d*%4d%4d%4d ", j+1, ielmt[j][0], ielmt[j][1], ielmt[j][2]); if(j<*nelmt-1) printf("*%4d*%4d%4d%4d", j+2, ielmt[j+1][0], ielmt[j+1][1], ielmt[j+1][2]); printf("\n"); 12 / 34
13 if(*nbc>0){ printf("nodes with zero Dirichlet data \n"); for(j=0; j<*nbc; j++) printf("%4d", ibc[j]); printf("\n"); [1] : FILE *fpin, *fpout;... : indata.txt, : outdata.txt fscanf(fpin, / 34
14 assem() /* The Direct Stiffness Method */ void assem(int nnode, int nelmt, int nbc, int ielmt[][3], double x[], double y[], int ibc[], double am[ndim1][ndim1], double fm[]) { int i, j, ie, ii, jj; double ae[3][3], fe[3]; /* Initial Clear */ for(i=0; i<nnode; i++){ fm[i]=0.0; for(j=0; j<nnode; j++) am[i][j]=0.0; 14 / 34
15 /* Assemblage of Total Matrix and Vector */ for(ie=0; ie<nelmt; ie++){ ecm(ielmt, x, y, ie, ae, fe); for(i=0; i<3; i++){ ii=ielmt[ie][i]-1; fm[ii]+=fe[i]; for(j=0; j<3; j++){ jj=ielmt[ie][j]-1; am[ii][jj]+=ae[i][j]; 15 / 34
16 /* The Homogeneous Dirichlet Condition */ if (nbc!=0){ for(i=0;i<nbc; i++){ ii=ibc[i]-1; fm[ii]=0.0; for(j=0; j<nnode;j++){ am[ii][j]=0.0; am[j][ii]=0.0; am[ii][ii]=1.0; 16 / 34
17 ecm() /* Element Coeffcient Matrix and Free Vector */ void ecm(int ielmt[][3], double x[], double y[], int ie, double ae[][3], double fe[]) { int i, j, k; double d, s, xe[3], ye[3], b[3], c[3]; for(i=0; i<3;i++){ j=ielmt[ie][i]-1; xe[i]=x[j]; ye[i]=y[j]; d=xe[0]*(ye[1]-ye[2])+xe[1]*(ye[2]-ye[0]) +xe[2]*(ye[0]-ye[1]); s=fabs(d)/2.0; 17 / 34
18 /* Calculation of Element Coefficient Matrix */ for(i=0; i<3; i++){ j=i+1; if(i==2) j=0; k=i-1; if(i==0) k=2; b[i]=(ye[j]-ye[k])/d; c[i]=(xe[k]-xe[j])/d; for(i=0; i<3; i++){ for(j=0; j<3; j++) ae[i][j]=s*(b[j]*b[i]+c[j]*c[i]); /* Calculation of Element Free Vector */ for(i=0; i<3; i++) fe[i]=s*f(xe[i], ye[i])/3.0; 18 / 34
19 solve() /* The Gauss Elimination Method */ void solve(int m, double a[][ndim1], double f[]) /* m=number of unknowns */ { int i, j, k; double aa; /* Forward Elimination */ for(i=0; i<m-1; i++){ for(j=i+1; j<m; j++){ aa=a[j][i]/a[i][i]; f[j]-=aa*f[i]; for(k=i+1; k<m; k++) a[j][k]-=aa*a[i][k]; 19 / 34
20 /* Backward Substitution */ f[m-1]/=a[m-1][m-1]; for(i=m-2; i>=0; i--){ for(j=i+1; j<m; j++) f[i]-=a[i][j]*f[j]; f[i]/=a[i][i]; 20 / 34
21 [1] : gs solve() gs solve() /* The Gauss Seidel Method */ void gs_solve(int m, double a[][ndim1], double f[]) { int i, j, k; double aa = 0.0; double u[ndim1],u_old[ndim1]; double max_delta=0.0, max_delta_old; double max_u=0.0; int count = 0; for(i=0; i<m; i++){ u[i] = 0.0; 21 / 34
22 do{ max_delta_old = max_delta; for(i=0; i<m; i++){ u_old[i] = u[i]; for(i=0; i<m; i++){ aa = 0.0; for(j=0; j<m; j++){ if(i!= j){ aa += a[i][j]*u[j]; u[i]=(f[i] - aa)/a[i][i]; 22 / 34
23 max_delta = fabs(u[0] - u_old[0]); for(i=1; i<m; i++){ if(max_delta < fabs(u[i] - u_old[i])){ max_delta = fabs(u[i] - u_old[i]); max_u = fabs(u[0]); for(i=1; i<m; i++){ if(max_u < fabs(u[i])){ max_u = fabs(u[i]); 23 / 34
24 count++; while(fabs((max_delta - max_delta_old)/max_u) >= 1.0E-5); printf("count = %d\n",count); for(i=0; i<m; i++){ f[i] = u[i]; 24 / 34
25 output() /* 0utput of Approximate Nodal Values of u */ void output(double fm[], int nnode, double x[], double y[]) { int j,m; FILE *fpout; if((fpout=fopen("outdata.txt","a")) == NULL){ printf(" \n"); exit(exit_failure); 25 / 34
26 fprintf(fpout, "\nnodal values of u\n"); fprintf(fpout, " i u \n"); for(j=0; j<nnode; j++) fprintf(fpout, "%4d%12.3e\n", j+1, fm[j]); fprintf(fpout, "\nmathematica 6 Data\n"); fprintf(fpout, "ListPlot3D[{\n"); for(j=0; j<nnode-1; j++){ fprintf(fpout, "{%f, %f, %f,\n", x[j], y[j], fm[j]); fprintf(fpout, "{%f, %f, %f\n, Mesh -> All]\n", x[j], y[j], fm[j]); fclose(fpout); [1] : FILE *fpout; / 34
27 f() /* Function for Free Term */ double f(double x, double y) { return(1.0); 27 / 34
28 7.5 indata.txt outdata.txt Basic data nnode = 9 nelmt = 8 nbc = 5 x,y-coordinates of nodes i x(i) y(i) Nodes of elements i i1 i2 i / 34
29 Nodes with zero Dirichlet data Nodal values of u i u e e e e e e e e e-001 Mathematica 6 Data ListPlot3D[{ { , , , { , , , { , , , { , , , { , , , { , , , { , , , { , , , { , , , Mesh -> All] 29 / 34
30 Mathematica outdata.txt ListPlot3D[...] Shift + Enter 30 / 34
31 Poisson Mathematica 31 / 34
32 2 indata 105.txt femfp.c femfp.c 32 / 34
33 7.7 2 Poisson 1 C 2 C / 34
34 [1]. :.,, / 34
2 [1] 7 5 C 2.1 (kikuchi-fem-mac ) input.dat (cat input.dat type input.dat ))
2.3 2007 8, 2011 6 21, 2012 5 29 1 (1) (2) (3) 2 Ω Poisson u = f (in Ω), u = 0 (on Γ 1 ), u n = 0 (on Γ 2) f Γ 1, Γ 2 Γ := Ω n Γ Ω (1980) Fortran : kikuchi-fem-mac.tar.gz 1 ( fem, 6701) tar xzf kikuchi-fem-mac.tar.gz
mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )
2008 3 10 1 mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( ) stream FILE ( man ) 40 ( ) %./a.out String : test
1 4 2 EP) (EP) (EP)
2003 2004 2 27 1 1 4 2 EP) 5 3 6 3.1.............................. 6 3.2.............................. 6 3.3 (EP)............... 7 4 8 4.1 (EP).................... 8 4.1.1.................... 18 5 (EP)
[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±
[1] #include printf("hello, world."); (G1) int -32768 32767 long int -2147483648 2147483647 float ±3.4 10 38 ±3.4 10 38 double ±1.7 10 308 ±1.7 10 308 char [2] #include int a, b, c, d,
1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l
C/C++ 2007 6 18 1 C STL(1) 2 1.1............................................... 2 1.2 stdio................................................ 3 1.3.......................................... 10 2 11 2.1 sizeof......................................
untitled
Q 8 1 8.1 (C++) C++ cin cout 5 C++ 16 6 p.63 8.3 #include 7 showbase noshowbase showpoint noshowpoint 8.3 uppercase 16 nouppercase 16 setfill(int) setprecision(int) setw(int) setbase(int) dec
: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology
I117 8 1 School of Information Science, Japan Advanced Institute of Science and Technology : CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and
ex14.dvi
1,, 0, b (b b 2 b ) n k n = n j b j, (0 n j b 1), n =(n k n k 1...n 1 n 0 ) b, n j j j +1, 0,...,b 1 (digit). b b, n b 1 ñ, ñ = k (b 1 n j )b j b N, n b n, n = b N n, n =ñ+1 b N, n m n + m (mod b N ),
1.ppt
/* * Program name: hello.c */ #include int main() { printf( hello, world\n ); return 0; /* * Program name: Hello.java */ import java.io.*; class Hello { public static void main(string[] arg)
r08.dvi
19 8 ( ) 019.4.0 1 1.1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( ) 1 next 1 prev 1 head cur tail head cur prev
C 2 / 21 1 y = x 1.1 lagrange.c 1 / Laglange / 2 #include <stdio.h> 3 #include <math.h> 4 int main() 5 { 6 float x[10], y[10]; 7 float xx, pn, p; 8 in
C 1 / 21 C 2005 A * 1 2 1.1......................................... 2 1.2 *.......................................... 3 2 4 2.1.............................................. 4 2.2..............................................
Taro-ファイル処理(公開版).jtd
ファイル処理 0. 目次 1. はじめに 2. ファイル内容の表示 3. ファイル内容の複写 3. 1 文字単位 3. 2 行単位 4. 書式付き入出力 5. 文字配列への入出力 6. 課題 6. 1 課題 1 ( ファイル圧縮 復元 ) - 1 - 1. はじめに ファイル処理プログラムの形は次のようになる #include main() { FILE *fp1,*fp2; ファイルポインタの宣言
Microsoft Word - no15.docx
7. ファイルいままでは プログラムを実行したとき その結果を画面で確認していました 簡単なものならそれでもいいのですか 複雑な結果は画面で見るだけでなく ファイルに保存できればよいでしょう ここでは このファイルについて説明します 使う関数のプロトタイプは次のとおりです FILE *fopen(const char *filename, const char *mode); ファイルを読み書きできるようにする
I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) + x * x + x x (4) * *
2015 2015 07 30 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF S + S S * S S x S +, *, x BNF S (parse tree) : * x + x x S * S x + S S S x x (1) * x x * x (2) * + x x x (3) +
実際の株価データを用いたオプション料の計算
2002 2 20 1 1 3 2 3 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 2.1.1 : : : : : : : : : : : : : : : : : : : : 5 2.1.2 : : : : : : : : : : : : : : : : : : : : 6 2.2 : : : : : : : : : :
:30 12:00 I. I VI II. III. IV. a d V. VI
2018 2018 08 02 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF N N y N x N xy yx : yxxyxy N N x, y N (parse tree) (1) yxyyx (2) xyxyxy (3) yxxyxyy (4) yxxxyxxy N y N x N yx
untitled
II 4 Yacc Lex 2005 : 0 1 Yacc 20 Lex 1 20 traverse 1 %% 2 [0-9]+ { yylval.val = atoi((char*)yytext); return NUM; 3 "+" { return + ; 4 "*" { return * ; 5 "-" { return - ; 6 "/" { return / ; 7 [ \t] { /*
C言語によるアルゴリズムとデータ構造
Algorithms and Data Structures in C 4 algorithm List - /* */ #include List - int main(void) { int a, b, c; int max; /* */ Ÿ 3Ÿ 2Ÿ 3 printf(""); printf(""); printf(""); scanf("%d", &a); scanf("%d",
Krylov (b) x k+1 := x k + α k p k (c) r k+1 := r k α k Ap k ( := b Ax k+1 ) (d) β k := r k r k 2 2 (e) : r k 2 / r 0 2 < ε R (f) p k+1 :=
127 10 Krylov Krylov (Conjugate-Gradient (CG ), Krylov ) MPIBNCpack 10.1 CG (Conjugate-Gradient CG ) A R n n a 11 a 12 a 1n a 21 a 22 a 2n A T = =... a n1 a n2 a nn n a 11 a 21 a n1 a 12 a 22 a n2 = A...
r07.dvi
19 7 ( ) 2019.4.20 1 1.1 (data structure ( (dynamic data structure 1 malloc C free C (garbage collection GC C GC(conservative GC 2 1.2 data next p 3 5 7 9 p 3 5 7 9 p 3 5 7 9 1 1: (single linked list 1
ohp07.dvi
19 7 ( ) 2019.4.20 1 (data structure) ( ) (dynamic data structure) 1 malloc C free 1 (static data structure) 2 (2) C (garbage collection GC) C GC(conservative GC) 2 2 conservative GC 3 data next p 3 5
2017 p vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = 0 (79) J s flux (67) J (79) J( r, t) = k δf δs s( r,
27 p. 47 7 7. vs. TDGL 4 Metropolis Monte Carlo equation of continuity s( r, t) t + J( r, t) = (79) J s flux (67) J (79) J( r, t) = k δf δs s( r, t) t = k δf δs (59) TDGL (8) (8) k s t = [ T s s 3 + ξ
1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include
1 1.1 C 2 1 double a[ ][ ]; 1 3x3 0 1 3x3 ( ) 0.240 0.143 0.339 0.191 0.341 0.477 0.412 0.003 0.921 1.2 malloc() malloc 2 #include #include #include enum LENGTH = 10 ; int
(K&R 2.9) ~, &,, >>, << 2. (K&R 5.7) 3. (K&R 5.9) 4. (K&R 5.10) (argc argv atoi(), atof() ) 5. (K&R 7.5) (K&R 7.6) - FILE, stdin, stdout, std
3 3 1. 1 (K&R.9) ~, &,, >>,
新・明解C言語 ポインタ完全攻略
2 1-1 1-1 /* 1-1 */ 1 int n = 100; int *p = &n; printf(" n %d\n", n); /* n int */ printf("*&n %d\n", *&n); /* *&n int */ printf(" p %p\n", p); /* p int * */ printf("&*p %p\n", &*p); /* &*p int * */ printf("sizeof(n)
新版明解C言語 実践編
2 List - "max.h" a, b max List - max "max.h" #define max(a, b) ((a) > (b)? (a) : (b)) max List -2 List -2 max #include "max.h" int x, y; printf("x"); printf("y"); scanf("%d", &x); scanf("%d", &y); printf("max(x,
超初心者用
3 1999 10 13 1. 2. hello.c printf( Hello, world! n ); cc hello.c a.out./a.out Hello, world printf( Hello, world! n ); 2 Hello, world printf n printf 3. ( ) int num; num = 100; num 100 100 num int num num
1 28 6 12 7 1 7.1...................................... 2 7.1.1............................... 2 7.1.2........................... 2 7.2...................................... 3 7.3...................................
USB 0.6 https://duet.doshisha.ac.jp/info/index.jsp 2 ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231
0 0.1 ANSI-C 0.2 web http://www1.doshisha.ac.jp/ kibuki/programming/resume p.html 0.3 2012 1 9/28 0 [ 01] 2 10/5 1 C 2 3 10/12 10 1 2 [ 02] 4 10/19 3 5 10/26 3 [ 03] 6 11/2 3 [ 04] 7 11/9 8 11/16 4 9 11/30
file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose
I117 9 2 School of Information Science, Japan Advanced Institute of Science and Technology file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line,
PowerPoint プレゼンテーション
プログラミング応用演習 第 3 回構造体, ファイル入出力 先週の出席確認へのコメント 暗号を破りたいが 平文の候補が多すぎる 人間の目で確認する代わりに どんなプログラムがあればよいか? 辞書を挙げた人が多かった 正しい着眼です 何億個もの平文候補が想定されるので 形態素解析や品詞判別を挙げた人もいます 辞書に近い回答で悪くはないのですが 平文候補ごとにあまり高機能なものを呼び出すと時間がかかる
6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = N t N 44.1 khz t = 1 sec j t f j {f 0, f 1, f 2,, f N 1
6 6.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave t T = t 44.1 khz t = 1 sec 44100 j t f j {f 0, f 1, f 2,, f 1 6.2 T {f 0, f 1, f 2,, f 1 T ft) f j = fj t) j = 0, 1, 2,,
p = 1, 2, cos 2n + p)πj = cos 2nπj 2n + p)πj, sin = sin 2nπj 7.1) f j = a ) 0 + a p + a n+p cos 2nπj p=1 p=0 1 + ) b n+p p=0 sin 2nπj 1 2 a 0 +
7 7.1 sound_wav_files flu00.wav.wav 44.1 khz 1/44100 spwave Text with Time spwave T > 0 t 44.1 khz t = 1 44100 j t f j {f 0, f 1, f 2,, f 1 = T t 7.2 T {f 0, f 1, f 2,, f 1 T ft) f j = fj t) j = 0, 1,
115 9 MPIBNCpack 9.1 BNCpack 1CPU X = , B =
115 9 MPIBNCpack 9.1 BNCpack 1CPU 1 2 3 4 5 25 24 23 22 21 6 7 8 9 10 20 19 18 17 16 X = 11 12 13 14 15, B = 15 14 13 12 11 16 17 18 19 20 10 9 8 7 6 21 22 23 24 25 5 4 3 2 1 C = XB X dmat1 B dmat2 C dmat
ex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) { double
void hash1_init(int *array) int i; for (i = 0; i < HASHSIZE; i++) array[i] = EMPTY; /* i EMPTY */ void hash1_insert(int *array, int n) if (n < 0 n >=
II 14 2018 7 26 : : [email protected] 14,, 8 2 12:00 1 O(1) n O(n) O(log n) O(1) 32 : 1G int 4 250 M 2.5 int 21 2 0 100 0 100 #include #define HASHSIZE 100 /* */ #define NOTFOUND 0
#define N1 N+1 double x[n1] =.5, 1., 2.; double hokan[n1] = 1.65, 2.72, 7.39 ; double xx[]=.2,.4,.6,.8,1.2,1.4,1.6,1.8; double lagrng(double xx); main
=1= (.5, 1.65), (1., 2.72), (2., 7.39).2,.4,.6,.8, 1., 1.2, 1.4, 1.6 1 1: x.2 1.4128.4 1.5372.6 1.796533.8 2.198 1.2 3.384133 1.4 4.1832 1.6 5.1172 8 7 6 5 y 4 3 2 1.5 1 1.5 2 x 1: /* */ #include
PowerPoint Presentation
p.130 p.198 p.208 2 double weight[num]; double min, max; min = max = weight[0]; for( i= 1; i i < NUM; i++ ) ) if if ( weight[i] > max ) max = weight[i]: if if ( weight[i] < min ) min = weight[i]: weight
02: 変数と標準入出力
C プログラミング入門 基幹 7 ( 水 5) 1 10: ファイル入出力 Linux にログインし 以下の講義ページを開いておくこと http://www-it.sci.waseda.ac.jp/teachers/w48369 2/CPR1/ 2016-06-15 今日の内容 2 標準ライブラリ関数によりファイルの出力を行う画像ファイルの生成を例題として 配列の作成を復習する 文字列の扱いを復習する
‚æ2›ñ C„¾„ê‡Ìš|
I 8 10 10 I ( 6 ) 10 10 1 / 23 1 C ( ) getchar(), gets(), scanf() ( ) putchar(), puts(), printf() 1 getchar(), putchar() 1 I ( 6 ) 10 10 2 / 23 1 (getchar 1 1) 1 #include 2 void main(void){ 3 int
[ 1] 1 Hello World!! 1 #include <s t d i o. h> 2 3 int main ( ) { 4 5 p r i n t f ( H e l l o World!! \ n ) ; 6 7 return 0 ; 8 } 1:
005 9 7 1 1.1 1 Hello World!! 5 p r i n t f ( H e l l o World!! \ n ) ; 7 return 0 ; 8 } 1: 1 [ ] Hello World!! from Akita National College of Technology. 1 : 5 p r i n t f ( H e l l o World!! \ n ) ;
Minimum C Minimum C Minimum C BNF T okenseq W hite Any D
6 2019 5 14 6.1 Minimum C....................... 6 1 6.2....................................... 6 7 6.1 Minimum C Minimum C BNF T okenseq W hite Any Digit ::= 0 1 2... 9. Number ::= Digit Digit. Alphabet
I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b
I 4 003 4 30 1 ASCII ( ) 0 17 0 NUL 16 DLE SP 0 @ P 3 48 64 80 96 11 p 1 SOH 17 DC1! 1 A Q a 33 49 65 81 97 113 q STX 18 DC " B R b 34 50 66 8 98 114 r 3 ETX 19 DC3 # 3 C S c 35 51 67 83 99 115 s 4 EOT
j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E
8 9 7 6 4 2 3 5 1 j x j j j + 1 l j l j = x j+1 x j, n x n x 1 = n 1 l j j=1 H j j + 1 l j l j E a n 1 H = ae l j, j=1 l j = x j+1 x j, x n x 1 = n 1 j=1 l j, l j = ±l l > 0) n 1 H = ϵ l j, j=1 ϵ e x x
C言語による数値計算プログラミング演習
5. 行列の固有値問題 n n 正方行列 A に対する n 個の固有値 λ i (i=1,,,n) と対応する固有ベクトル u i は次式を満たす Au = λ u i i i a11 a1 L a1 n u1i a1 a a n u i A =, ui = M O M M an 1 an L ann uni これらはまとめて, つぎのように書ける 5.1 ヤコビ法 = Λ, = [ u1 u u
comment.dvi
( ) (sample1.c) (sample1.c) 2 2 Nearest Neighbor 1 (2D-class1.dat) 2 (2D-class2.dat) (2D-test.dat) 3 Nearest Neighbor Nearest Neighbor ( 1) 2 1: NN 1 (sample1.c) /* -----------------------------------------------------------------
program.dvi
2001.06.19 1 programming semi ver.1.0 2001.06.19 1 GA SA 2 A 2.1 valuename = value value name = valuename # ; Fig. 1 #-----GA parameter popsize = 200 mutation rate = 0.01 crossover rate = 1.0 generation
/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v
1 http://www7.bpe.es.osaka-u.ac.jp/~kota/classes/jse.html [email protected] /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );
Microsoft PowerPoint - kougi2.ppt
C プログラミング演習 第 2 回 Microsoft Visual Studio.NET を使ってみよう 説明 例題 1. プログラム実行の体験 コンピュータを役に立つ道具として実感する 次ページのプログラムを使って, Microsoft Visual Studio.NETでの C++ ソースファイル編集, ビルド, テスト実行の一連の過程を体験する 例題 1 のプログラムの機能 計算の繰り返し
memo
数理情報工学演習第一 C プログラミング演習 ( 第 5 回 ) 2015/05/11 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 今日の内容 : プロトタイプ宣言 ヘッダーファイル, プログラムの分割 課題 : 疎行列 2 プロトタイプ宣言 3 C 言語では, 関数や変数は使用する前 ( ソースの上のほう ) に定義されている必要がある. double sub(int
ファイル入出力
C プログラミング Ⅱ の基礎 とは ファイルへデータを書き込んだり ( 出力 ), ファイルからデータを読み込んだり ( 入力 ) する C 言語では キーボードからの入力 画面への出力と同じようなコードで 処理を実現できる プログラム 入力 出力 ファイル 出力 入力 2 入出力の基本 ストリーム プログラム上で様々な装置への入出力を行う機構様々な入出力装置を統一的な方法で扱うことができる ハードディスクなどではファイルデータによって入出力が行われる
ex01.dvi
,. 0. 0.0. C () /******************************* * $Id: ex_0_0.c,v.2 2006-04-0 3:37:00+09 naito Exp $ * * 0. 0.0 *******************************/ #include int main(int argc, char **argv) double
DOPRI5.dvi
ODE DOPRI5 ( ) 16 3 31 Runge Kutta Dormand Prince 5(4) [1, pp. 178 179] DOPRI5 http://www.unige.ch/math/folks/hairer/software.html Fortran C C++ [3, pp.51 56] DOPRI5 C cprog.tar % tar xvf cprog.tar cprog/
double float
2015 3 13 1 2 2 3 2.1.......................... 3 2.2............................. 3 3 4 3.1............................... 4 3.2 double float......................... 5 3.3 main.......................
PowerPoint Presentation
ファイルの入出力 芝浦工業大学情報工学科 青木義満 今回の講義内容 ファイル入出力 ファイルからのデータ読込み ファイルと配列 2 1 ファイルへのデータ書き込み ( 復習 ) ソースファイル名 :fileio1.c データをファイルに書き込み #include int main(void) { ファイルポインタ宣言 int student_id = 100; char name[
II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D
II 8 2003 11 12 1 6 ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 Daisuke 8 =>. 73 Daisuke 35 Hiroshi 64 Ichiro 87 Junko
数値計算法
12.1 電気回路網に関するキルヒホッフの法則による解法 1 工学的諸問題を多元連立 1 次方程式で表現することができる. 例えば, 荷物を最短の時間と最低のコストで輸送するためにはどのようなルートで物流を行うか という問題, 工場の部品の在庫の状況からいかに最小のコストで製品をつくるか という問題, 機械要素の運動の問題, 電気回路の解析の問題など, いくつか挙げられる. つまり, 計算機で多元連立方程式を解くことができれば,
/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1
I117 II I117 PROGRAMMING PRACTICE II 2 MEMORY MANAGEMENT 2 Research Center for Advanced Computing Infrastructure (RCACI) / Yasuhiro Ohara [email protected] / SCHEDULE 1. 2011/06/07(Tue) / Basic of Programming
