QR

Size: px
Start display at page:

Download "QR"

Transcription

1 QR QR QR QR QR (x i, y i ), i = 1,..., n y i = y(x i ), i = 1,..., n y(x) y i y(x i ) y(x) ϕ i (x) y(x) = c 1 ϕ 1 (x) + c 2 ϕ(x) + + c m ϕ m (x), y i = y(x i ) = c 1 ϕ 1 (x i ) + c 2 ϕ(x i ) + + c m ϕ m (x i ), i = 1,..., n c i

2 13. 2 ϕ 1 (x 1 ) ϕ 2 (x 1 ) ϕ m (x 1 ) ϕ 1 (x 2 ) ϕ 2 (x 2 ) ϕ m (x 2 ).... ϕ 1 (x n ) ϕ 2 (x n ) ϕ m (x n ) c 1 c 2. c m = y 1 y 2. y n (1) n m A A = (a ij ) = (ϕ j (x i )) (2) c y c T = (c 1, c 2,, c m ) y T = (y 1, y 2,, y n ) (1) Ac = y (3) 13.1 QR (3) m n c e = y Ac 2 = (y Ac) T (y Ac) (4) e = y T y c T A T y y T Ac c T A T Ac = y T y 2c T A T y + c T A T Ac e c T = 2AT y + 2A T Ac = 0 A T Ac = A T y A T A 0 c = (A T A) 1 A T y (3) A T A T Ac = A T y (5)

3 // least squre method 3 4 #include "pch.h" 5 // #include <iostream> 6 #include <math.h> 7 8 #define N 9 9 #define M double x[] = { , , , , , , , , }; 14 double y[] = { , , , , , , , , }; int 18 main(int ac, char av[]) 19 { 20 double a[n][m], r[m][m]; 21 double b[m], c[m], s; 22 int n = N, m = M; 23 int i, j, k; 24 double p, q; for (i = 0; i < n; i++) { 27 s = x[i]; 28 a[i][0] = 1; 29 a[i][1] = s; 30 s = s s; 31 a[i][2] = s; 32 s = s x[i]; 33 a[i][3] = s; 34 s = s x[i]; 35 a[i][4] = s; 36 } for (j = 0; j < m; j++) { 39 for (k = 0; k < m; k++) { 40 s = 0; 41 for (i = 0; i < n; i++) 42 s = s + a[i][j] a[i][k]; 43 r[j][k] = s; 44 } 45 } 46 for (j = 0; j < m; j++) { // aˆt y > b 47 s = 0; 48 for (i = 0; i < n; i++) 49 s = s + a[i][j] y[i]; 50 b[j] = s; 51 } 52 for (i = 0; i < m; i++) { 53 p = r[i][i]; 54 for (j = i + 1; j < m; j++) { 55 q = r[j][i] / p; 56 for (k = i + 1; k < n; k++) 57 r[j][k] = r[j][k] q r[i][k];

4 r[j][i] = 0; 59 b[j] = b[j] q b[i]; 60 } 61 } for (i = m 1; i >= 0; i ) { 64 c[i] = b[i]; 65 for (j = m 1; j > i; j ) { 66 c[i] = c[i] r[i][j] c[j]; 67 } 68 c[i] = c[i] / r[i][i]; 69 } 70 printf("solution\n"); 71 for (i = 0; i < m; i++) { 72 printf("c%d: %18.15f, ", i + 1, c[i]); 73 } 74 printf("\n"); 75 } QR (3) A QR A = QR Q n m (Q T Q = I) R m m Ac = QRc = y Q T Q T QRc = Rc = Q T y Rc = Q T y R QR 1 // qr decomposition for non square matrix 2 3 #include "pch.h" 4 #include <iostream> 5 #include <math.h> 6 7 #define N 9 8 #define M void gram schmidt(double a[n][m], int n, int m, double q[n][m]); 11 void qr decomposition(double a[n][m], int n, int m, 12 double q[n][m], double r[m][m]); double x[] = { , , , , , , , , };

5 double y[] = { , , , , , , , , }; int 20 main(int ac, char av[]) 21 { 22 double a[n][m]; 23 double q[n][m], r[m][m]; 24 double b[m], c[m], s; 25 int n = N, m = M; 26 int i, j; for (i = 0; i < n; i++) { 29 s = x[i]; 30 a[i][0] = 1; 31 a[i][1] = s; 32 s = s s; 33 a[i][2] = s; 34 s = s x[i]; 35 a[i][3] = s; 36 s = s x[i]; 37 a[i][4] = s; 38 } qr decomposition(a, n, m, q, r); 41 for (j = 0; j < m; j++) { // QˆT y > b 42 s = 0; 43 for (i = 0; i < n; i++) 44 s = s + q[i][j] y[i]; 45 b[j] = s; 46 } 47 for (i = m 1; i >= 0; i ) { // solve Rc = b 48 c[i] = b[i]; 49 for (j = m 1; j > i; j ) { 50 c[i] = c[i] r[i][j] c[j]; 51 } 52 c[i] = c[i] / r[i][i]; 53 } 54 printf("solution\n"); 55 for (i = 0; i < m; i++) { 56 printf("c%d: %18.15f, ", i + 1, c[i]); 57 } 58 printf("\n"); 59 } void 63 qr decomposition(double a[n][m], int n, int m, 64 double q[n][m], double r[m][m]) 65 { 66 int i, j, k, l; 67 double s, p; gram schmidt(a, n, m, q); 70 for (k = 0; k < m; k++) { 71 for (j = 0; j < k; j++) { 72 s = 0; 73 for (i = 0; i < n; i++) 74 s = s + a[i][k] q[i][j]; 75 r[j][k] = s; 76 }

6 s = 0; 78 for (i = 0; i < n; i++) { 79 p = a[i][k]; 80 for (l = 0; l < k; l++) { 81 p = p r[l][k] q[i][l]; 82 } 83 s = s + p p; 84 } 85 r[k][k] = sqrt(s); 86 for (j = k + 1; j < m; j++) 87 r[j][k] = 0; 88 } 89 } void 92 gram schmidt(double a[n][m], int n, int m, double q[n][m]) 93 { 94 int i, j, k; 95 double s; 96 for (i = 0; i < n; i++) { 97 for (j = 0; j < m; j++) 98 q[i][j] = a[i][j]; 99 } 100 for (j = 0; j < m; j++) { 101 s = 0; 102 for (i = 0; i < n; i++) 103 s = s + q[i][j] q[i][j]; // (a[j], a[j]) 104 s = 1 / sqrt(s); 105 for (i = 0; i < n; i++) 106 q[i][j] = q[i][j] s; // a[j] 107 for (k = j + 1; k < m; k++) { 108 s = 0; 109 for (i = 0; i < n; i++) 110 s = s + q[i][k] q[i][j]; // (a[j], a[k]) 111 for (i = 0; i < n; i++) 112 q[i][k] = q[i][k] s q[i][j]; // a[i] 113 } 114 } 115 } 13.2 QR A = a= , , , , , , a^ta= , , , ,, B =

7 13. 7 solution c1: , c2: , A T A c 1, c 2 A T A QR a= , , , , , , qr decomposition q= , , , , , , r= , , , , solution c1: , c2: , A A QR 13.3 n m A n m A = UΣV T U n m (U T U = I ) V m m Σ m m A 0 Σ σ 1, σ 2,..., σ m 0 σ 1 σ 2... σ m A n < m σ n+1,..., σ m 0 U 0 A A T A = (UΣV T ) T UΣV T = V Σ 2 V T Σ 2 V Σ 2 A T A {σ i 2, i = 1,..., m} A T A

8 n m A A + (1) AA + A = A (2) A + AA + = A + (3) (AA + ) T = AA + (4) (A + A) T = A + A A + A (A + ) + = A (A T ) + = (A + ) T A B m (AB) + = B + A + A m A + = (A T A) 1 A T A A = UΣV T A + = V Σ + U T Σ + i σ i 0 1/σ i σ i A n m Ax = b (6) k n x = A + b + (I A + A)k A + b x A A + = A 1 A + b (6) A x = A + b Ax b A 2. U 3. QR 4. QR R k U V 5. V

9 QR #include <stdio.h> 2 #include <stdlib.h> 3 #include <math.h> 4 5 #define M 3 6 #define N #define SIGN(a, b) ((b) >= 0.0? fabs(a) : fabs(a)) 9 #define MAX(x,y) ((x)>(y)?(x):(y)) 10 #define MIN(x,y) ((x)>(y)?(y):(x)) double PYTHAG(double a, double b); 13 int svd(double a[m][n], int m, int n, double s[n], 14 double v[n][n]); int 17 main(int ac, char av[]) 18 { 19 int n = N, m = M; 20 double a[m][n] = { {1, 1}, {0, 1.0e 5}, {0, 0} }; 21 double b[m] = { 0, 1.0e 5, 1 }; 22 double u[m][n], v[n][n], s[n]; 23 int i, j; 24 double x[m], t; svd(a, m, n, s, v); printf("a=\n"); 29 for (i = 0; i < m; i++) { 30 for (j = 0; j < n; j++) 31 printf("%10.5lf, ", a[i][j]); 32 printf("\n"); 33 } 34 printf("v=\n"); 35 for (i = 0; i < n; i++) { 36 for (j = 0; j < n; j++) 37 printf("%10.5lf, ", v[i][j]); 38 printf("\n"); 39 } 40 printf("s=\n"); 41 for (i = 0; i < n; i++) { 42 printf("%10.5lf", s[i]); 43 printf("\n"); 44 } 45 // solve Ax = B 46 for (i = 0; i < m; i++) { 47 t = 0; 48 for (j = 0; j < n; j++) 49 t = t + a[j][i] b[j]; 50 x[i] = s[i] == 0.0? 0.0 : t / s[i]; 51 x[i] = t; 52 } 53 for (i = 0; i < n; i++) {

10 t = 0; 55 for (j = 0; j < n; j++) 56 t = t + v[j][i] x[i]; 57 printf("%18.15lf\n", t); 58 } 59 } double 63 PYTHAG(double a, double b) 64 { 65 double at = fabs(a), bt = fabs(b), ct, result; if (at > bt) { 68 ct = bt / at; 69 result = at sqrt(1.0 + ct ct); 70 } else if (bt > 0.0) { 71 ct = at / bt; 72 result = bt sqrt(1.0 + ct ct); 73 } else 74 result = 0.0; 75 return (result); 76 } int 79 svd(double a[m][n], int m, int n, double w[n], double v[n][n]) 80 { 81 int flag, i, its, j, jj, k, l, nm; 82 double c, f, h, s, x, y, z; 83 double anorm = 0.0, g = 0.0, scale = 0.0; 84 double rv1[n]; if (m < n) { 87 fprintf(stderr, "#rows must be > #cols \n"); 88 return (0); 89 } // Householder reduction to bidiagonal form 92 for (i = 0; i < n; i++) { 93 // left hand reduction 94 l = i + 1; 95 rv1[i] = scale g; 96 g = s = scale = 0.0; 97 if (i < m) { 98 for (k = i; k < m; k++) 99 scale += fabs(a[k][i]); 100 if (scale) { 101 for (k = i; k < m; k++) { 102 a[k][i] = (a[k][i] / scale); 103 s += (a[k][i] a[k][i]); 104 } 105 f = a[i][i]; 106 g = SIGN(sqrt(s), f); 107 h = f g s; 108 a[i][i] = (f g); 109 if (i!= n 1) { 110 for (j = l; j < n; j++) { 111 for (s = 0.0, k = i; k < m; k++) 112 s += (a[k][i] a[k][j]); 113 f = s / h; 114 for (k = i; k < m; k++)

11 a[k][j] += (f a[k][i]); 116 } 117 } 118 for (k = i; k < m; k++) 119 a[k][i] = (a[k][i] scale); 120 } 121 } 122 w[i] = (scale g); 123 // right hand reduction 124 g = s = scale = 0.0; 125 if (i < m && i!= n 1) { 126 for (k = l; k < n; k++) 127 scale += fabs(a[i][k]); 128 if (scale) { 129 for (k = l; k < n; k++) { 130 a[i][k] = (a[i][k] / scale); 131 s += (a[i][k] a[i][k]); 132 } 133 f = a[i][l]; 134 g = SIGN(sqrt(s), f); 135 h = f g s; 136 a[i][l] = (f g); 137 for (k = l; k < n; k++) 138 rv1[k] = a[i][k] / h; 139 if (i!= m 1) { 140 for (j = l; j < m; j++) { 141 for (s = 0.0, k = l; k < n; k++) 142 s += (a[j][k] a[i][k]); 143 for (k = l; k < n; k++) 144 a[j][k] += (s rv1[k]); 145 } 146 } 147 for (k = l; k < n; k++) 148 a[i][k] = (a[i][k] scale); 149 } 150 } 151 anorm = MAX(anorm, (fabs(w[i]) + fabs(rv1[i]))); 152 } // accumulate the right hand transformation 155 for (i = n 1; i >= 0; i ) { 156 if (i < n 1) { 157 if (g) { 158 for (j = l; j < n; j++) 159 v[j][i] = ((a[i][j] / a[i][l]) / g); 160 for (j = l; j < n; j++) { 161 for (s = 0.0, k = l; k < n; k++) 162 s += (a[i][k] v[k][j]); 163 for (k = l; k < n; k++) 164 v[k][j] += (s v[k][i]); 165 } 166 } 167 for (j = l; j < n; j++) 168 v[i][j] = v[j][i] = 0.0; 169 } 170 v[i][i] = 1.0; 171 g = rv1[i]; 172 l = i; 173 } // accumulate the left hand transformation

12 for (i = n 1; i >= 0; i ) { 177 l = i + 1; 178 g = w[i]; 179 if (i < n 1) 180 for (j = l; j < n; j++) 181 a[i][j] = 0.0; 182 if (g) { 183 g = 1.0 / g; 184 if (i!= n 1) { 185 for (j = l; j < n; j++) { 186 for (s = 0.0, k = l; k < m; k++) 187 s += (a[k][i] a[k][j]); 188 f = (s / a[i][i]) g; 189 for (k = i; k < m; k++) 190 a[k][j] += (f a[k][i]); 191 } 192 } 193 for (j = i; j < m; j++) 194 a[j][i] = (a[j][i] g); 195 } else { 196 for (j = i; j < m; j++) 197 a[j][i] = 0.0; 198 } a[i][i]; 200 } // diagonalize the bidiagonal form 203 for (k = n 1; k >= 0; k ) { // loop over singular values 204 for (its = 0; its < 30; its++) { 205 // loop over allowed iterations 206 flag = 1; 207 for (l = k; l >= 0; l ) { // test for splitting 208 nm = l 1; 209 if (fabs(rv1[l]) + anorm == anorm) { 210 flag = 0; 211 break; 212 } 213 if (fabs(w[nm]) + anorm == anorm) 214 break; 215 } 216 if (flag) { 217 c = 0.0; 218 s = 1.0; 219 for (i = l; i <= k; i++) { 220 f = s rv1[i]; 221 if (fabs(f) + anorm!= anorm) { 222 g = w[i]; 223 h = PYTHAG(f, g); 224 w[i] = h; 225 h = 1.0 / h; 226 c = g h; 227 s = ( f h); 228 for (j = 0; j < m; j++) { 229 y = a[j][nm]; 230 z = a[j][i]; 231 a[j][nm] = (y c + z s); 232 a[j][i] = (z c y s); 233 } 234 } 235 } 236 }

13 z = w[k]; 238 if (l == k) { // convergence 239 if (z < 0.0) { // make singular value nonnegative 240 w[k] = ( z); 241 for (j = 0; j < n; j++) 242 v[j][k] = ( v[j][k]); 243 } 244 break; 245 } 246 if (its >= 30) { 247 printf("no convergence after 30,000! iterations \n"); 248 return (0); 249 } // shift from bottom 2 x 2 minor 252 x = w[l]; 253 nm = k 1; 254 y = w[nm]; 255 g = rv1[nm]; 256 h = rv1[k]; 257 f = ((y z) (y + z) + (g h) (g + h)) / (2.0 h y); 258 g = PYTHAG(f, 1.0); 259 f = ((x z) (x + z) + h ((y / (f + SIGN(g, f))) h)) / x; // next QR transformation 262 c = s = 1.0; 263 for (j = l; j <= nm; j++) { 264 i = j + 1; 265 g = rv1[i]; 266 y = w[i]; 267 h = s g; 268 g = c g; 269 z = PYTHAG(f, h); 270 rv1[j] = z; 271 c = f / z; 272 s = h / z; 273 f = x c + g s; 274 g = g c x s; 275 h = y s; 276 y = y c; 277 for (jj = 0; jj < n; jj++) { 278 x = v[jj][j]; 279 z = v[jj][i]; 280 v[jj][j] = (x c + z s); 281 v[jj][i] = (z c x s); 282 } 283 z = PYTHAG(f, h); 284 w[j] = z; 285 if (z) { 286 z = 1.0 / z; 287 c = f z; 288 s = h z; 289 } 290 f = (c g) + (s y); 291 x = (c y) (s g); 292 for (jj = 0; jj < m; jj++) { 293 y = a[jj][j]; 294 z = a[jj][i]; 295 a[jj][j] = (y c + z s); 296 a[jj][i] = (z c y s); 297 }

14 } 299 rv1[l] = 0.0; 300 rv1[k] = f; 301 w[k] = x; 302 } 303 } 304 return (1); 305 } A =

1 5 13 4 1 41 1 411 1 412 2 413 3 414 3 415 4 42 6 43 LU 7 431 LU 10 432 11 433 LU 11 44 12 441 13 442 13 443 SOR ( ) 14 444 14 445 15 446 16 447 SOR 16 448 16 45 17 4 41 n x 1,, x n a 11 x 1 + a 1n x

More information

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 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

More information

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou 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() 2 double *a[ ]; double 1 malloc() double 1 malloc() free() 3 #include #include

More information

XMPによる並列化実装2

XMPによる並列化実装2 2 3 C Fortran Exercise 1 Exercise 2 Serial init.c init.f90 XMP xmp_init.c xmp_init.f90 Serial laplace.c laplace.f90 XMP xmp_laplace.c xmp_laplace.f90 #include int a[10]; program init integer

More information

Gauss

Gauss 15 1 LU LDL T 6 : 1g00p013-5 1 6 1.1....................................... 7 1.2.................................. 8 1.3.................................. 8 2 Gauss 9 2.1.....................................

More information

スライド 1

スライド 1 数値解析 平成 24 年度前期第 13 週 [7 月 11 日 ] 静岡大学創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義アウトライン [7 月 11 日 ] 関数近似と補間 最小 2 乗近似による関数近似 ラグランジュ補間 形状処理工学の基礎 点列からの曲線の生成 T.Kanai, U.Tokyo 関数近似 p.116 複雑な関数を簡単な関数で近似する関数近似 閉区間

More information

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

[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,

More information

スライド 1

スライド 1 数値解析 平成 29 年度前期第 14 週 [7 月 10 日 ] 静岡大学工学研究科機械工学専攻ロボット 計測情報分野創造科学技術大学院情報科学専攻 三浦憲二郎 期末試験 7 月 31 日 ( 月 ) 9 10 時限 A : 佐鳴会議室 B : 佐鳴ホール 講義アウトライン [7 月 10 日 ] 関数近似と補間 最小 2 乗近似による関数近似 ( 復習 ) ラグランジュ補間 形状処理工学の基礎

More information

2 [1] 7 5 C 2.1 (kikuchi-fem-mac ) input.dat (cat input.dat type input.dat ))

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

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó  ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡ (2018) 2018 5 17 0 0 if switch if if ( ) if ( 0) if ( ) if ( 0) if ( ) (0) if ( 0) if ( ) (0) ( ) ; if else if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 if else ( 0) 1 if ( ) 1 else 2 (0) 2 if else

More information

C言語による数値計算プログラミング演習

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

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

: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

More information

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 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..............................................

More information

joho12.ppt

joho12.ppt n φ 1 (x),φ 2 (x),,φ n (x) (x i, f i ) Q n c 1,,c n (,f k ) q n = c i φ i (x) x Q n i=1 c 1 = 0 c 1 n ( c 1 ) = q n f k 2 Q n ( c 1 ) = q 2 2 n ( ) 2 f k q n ( ) + f k Q n c 1 = c 1 q n 2 q n( ) q n q

More information

comment.dvi

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) /* -----------------------------------------------------------------

More information

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) * *

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) +

More information

新版明解C言語 実践編

新版明解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,

More information

:30 12:00 I. I VI II. III. IV. a d V. VI

:30 12:00 I. I VI II. III. IV. a d V. VI 2017 2017 08 03 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF X [ S ] a S S ; X X X, S [, a, ], ; BNF X (parse tree) (1) [a;a] (2) [[a]] (3) [a;[a]] (4) [[a];a] : [a] X 2 222222

More information

r07.dvi

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

More information

ohp07.dvi

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

More information

スライド 1

スライド 1 数値解析 2019 年度前期第 13 週 [7 月 11 日 ] 静岡大学創造科学技術大学院情報科学専攻工学部機械工学科計測情報講座 三浦憲二郎 講義アウトライン [7 月 11 日 ] 関数近似と補間 最小 2 乗近似による関数近似 ラグランジュ補間 T.Kanai, U.Tokyo 関数近似 p.116 複雑な関数を簡単な関数で近似する 関数近似 閉区間 [a,b] で定義された関数 f(x)

More information

Microsoft Word - C.....u.K...doc

Microsoft Word - C.....u.K...doc C uwêííôöðöõ Ð C ÔÖÐÖÕ ÐÊÉÌÊ C ÔÖÐÖÕÊ C ÔÖÐÖÕÊ Ç Ê Æ ~ if eíè ~ for ÒÑÒ ÌÆÊÉÉÊ ~ switch ÉeÍÈ ~ while ÒÑÒ ÊÍÍÔÖÐÖÕÊ ~ 1 C ÔÖÐÖÕ ÐÊÉÌÊ uê~ ÏÒÏÑ Ð ÓÏÖ CUI Ô ÑÊ ÏÒÏÑ ÔÖÐÖÕÎ d ÈÍÉÇÊ ÆÒ Ö ÒÐÑÒ ÊÔÎÏÖÎ d ÉÇÍÊ

More information

9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0)

9 8 7 (x-1.0)*(x-1.0) *(x-1.0) (a) f(a) (b) f(a) Figure 1: f(a) a =1.0 (1) a 1.0 f(1.0) E-mail: takio-kurita@aist.go.jp 1 ( ) CPU ( ) 2 1. a f(a) =(a 1.0) 2 (1) a ( ) 1(a) f(a) a (1) a f(a) a =2(a 1.0) (2) 2 0 a f(a) a =2(a 1.0) = 0 (3) 1 9 8 7 (x-1.0)*(x-1.0) 6 4 2.0*(x-1.0) 6 2 5 4 0 3-2

More information

2000 7 17 iii,,.,,,,.,.,,. =,,.,,.,.,,,,,,, fortran,.,,,,.,,, iv (i),., 10,, 10 1. (ii),, fortran, fortran, C,.. (i),., 10 23.. (ii),.,, fortran Pasal,, for, if then else. C., fortran C.,.,,.,.,,.,,.,.,,,,.

More information

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C 1 6 9 1 main main 1 NULL NULL 1 15 23 25 48 26 30 32 36 38 43 45 47 50 52 for 2 (a) 2 2 1 Yacc 2 (b) 2 3 yytext tmp2 ("") tmp2->next->word tmp2 yytext tmp2->next->word

More information

V T n n = A r n A n r n U V m m n n UT U = I V T V = I : A = A = UΣV T A T AV = VΣ T Σ : AB T = B T A T V A T A V A V T V = I 3 V A V T V = I : A AK =

V T n n = A r n A n r n U V m m n n UT U = I V T V = I : A = A = UΣV T A T AV = VΣ T Σ : AB T = B T A T V A T A V A V T V = I 3 V A V T V = I : A AK = PLS Janes PLS PLS PCR MLR PCA singular value decomposition : m n A 3 A = U m n m m Σ m n VT n n U left singular matrix V Σ U = m m A m r Σ = m n σ σ r A m m r V T n n = A r n A n r n U V m m n n UT U =

More information

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* ( 2016 2016 07 28 10:30 12:00 I. I VI II. III. IV. a d V. VI. 80 100 60 1 I. Backus-Naur BNF : 11011 N N 0 N N 11 1001 N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) 1100100 (2) 1111011 (3) 1110010 (4) 1001011

More information

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return 0; 戻り値 1: main() 2.2 C main

1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf(hello World!!\n); return 0; 戻り値 1: main() 2.2 C main C 2007 5 29 C 1 11 2 2.1 main() 1 FORTRAN C main() main main() main() 1 return 1 1 return main() { main main C 1 戻り値の型 関数名 引数 関数ブロックをあらわす中括弧 main() 関数の定義 int main(void){ printf("hello World!!\n"); return

More information

kiso2-09.key

kiso2-09.key 座席指定はありません 計算機基礎実習II 2018 のウェブページか 第9回 ら 以下の課題に自力で取り組んで下さい 計算機基礎実習II 第7回の復習課題(rev07) 第9回の基本課題(base09) 第8回試験の結果 中間試験に関するコメント コンパイルできない不完全なプログラムなど プログラミングに慣れていない あるいは複雑な問題は 要件 をバラして段階的にプログラムを作成する exam08-2.c

More information

1 4 2 EP) (EP) (EP)

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)

More information

第7章 有限要素法のプログラミング

第7章 有限要素法のプログラミング April 3, 2019 1 / 34 7.1 ( ) 2 Poisson 2 / 34 7.2 femfp.c [1] main( ) input( ) assem( ) ecm( ) f( ) solve( ) gs { solve( ) output( ) 3 / 34 7.3 fopen() #include FILE *fopen(char *fname, char

More information

1.ppt

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)

More information

1 28 6 12 7 1 7.1...................................... 2 7.1.1............................... 2 7.1.2........................... 2 7.2...................................... 3 7.3...................................

More information

: : : : ) ) 1. d ij f i e i x i v j m a ij m f ij n x i =

: : : : ) ) 1. d ij f i e i x i v j m a ij m f ij n x i = 1 1980 1) 1 2 3 19721960 1965 2) 1999 1 69 1980 1972: 55 1999: 179 2041999: 210 211 1999: 211 3 2003 1987 92 97 3) 1960 1965 1970 1985 1990 1995 4) 1. d ij f i e i x i v j m a ij m f ij n x i = n d ij

More information

2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1

2008 ( 13 ) C LAPACK 2008 ( 13 )C LAPACK p. 1 2008 ( 13 ) C LAPACK LAPACK p. 1 Q & A Euler http://phase.hpcc.jp/phase/mppack/long.pdf KNOPPIX MT (Mersenne Twister) SFMT., ( ) ( ) ( ) ( ). LAPACK p. 2 C C, main Asir ( Asir ) ( ) (,,...), LAPACK p.

More information

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,

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 + ξ

More information

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. このサンプルページの内容は, 新装版 1 刷発行時のものです.

C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます.  このサンプルページの内容は, 新装版 1 刷発行時のものです. C による数値計算法入門 ( 第 2 版 ) 新装版 サンプルページ この本の定価 判型などは, 以下の URL からご覧いただけます. http://www.morikita.co.jp/books/mid/009383 このサンプルページの内容は, 新装版 1 刷発行時のものです. i 2 22 2 13 ( ) 2 (1) ANSI (2) 2 (3) Web http://www.morikita.co.jp/books/mid/009383

More information

‚æ4›ñ

‚æ4›ñ ( ) ( ) ( ) A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 (OUS) 9 26 1 / 28 ( ) ( ) ( ) A B C D Z a b c d z 0 1 2 9 (OUS) 9

More information

untitled

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] { /*

More information

#6 : ( 8-13) URL : j inoue/index.html : Neugart

#6 : ( 8-13) URL :   j inoue/index.html : Neugart #6 : ( 8-13) RL : http://chaosweb.complex.eng.hokudai.ac.jp/ j inoue/index.html 23 5 31 9 5 9.1 :...................... 51 9.2 Neugart..................................... 53 9.2.1................................

More information

空き容量一覧表(154kV以上)

空き容量一覧表(154kV以上) 1/3 A. 電気所 ( 発電所, 変電所, 配電塔 ) における変圧器の空き容量 覧 < 留意事項 > (1) 空容量は 安であり 系統接続の前には 接続検討のお申込みによる詳細検討が必要となります その結果 空容量が変更となる場合があります (2) 熱容量を考慮した空き容量を記載しております その他の要因 ( や系統安定度など ) で連系制約が発 する場合があります (3) 表 は 既に空容量がないため

More information

2/8 一次二次当該 42 AX 変圧器 なし 43 AY 変圧器 なし 44 BA 変圧器 なし 45 BB 変圧器 なし 46 BC 変圧器 なし

2/8 一次二次当該 42 AX 変圧器 なし 43 AY 変圧器 なし 44 BA 変圧器 なし 45 BB 変圧器 なし 46 BC 変圧器 なし 1/8 A. 電気所 ( 発電所, 変電所, 配電塔 ) における変圧器の空き容量一覧 < 留意事項 > (1) 空容量は目安であり 系統接続の前には 接続検討のお申込みによる詳細検討が必要となります その結果 空容量が変更となる場合があります (2) 特に記載のない限り 熱容量を考慮した空き容量を記載しております その他の要因 ( や系統安定度など ) で連系制約が発生する場合があります (3)

More information

2004 2005 2 2 1G01P038-0 1 2 1.1.............................. 2 1.2......................... 2 1.3......................... 3 2 4 2.1............................ 4 2.2....................... 4 2.3.......................

More information

Taro-最大値探索法の開発(公開版

Taro-最大値探索法の開発(公開版 最大値探索法の開発 0. 目次 1. 開発過程 1 目標 1 : 4 個のデータの最大値を求める 目標 2 : 4 個のデータの最大値を求める 改良 : 多数のデータに対応するため 配列を使う 目標 3 : n 個のデータの最大値を求める 改良 : コードを簡潔に記述するため for 文を使う 目標 4 : n 個のデータの最大値を求める 改良 : プログラムをわかりやすくするため 関数を使う 目標

More information

新・明解C言語 実践編

新・明解C言語 実践編 第 1 章 見 21 1-1 見えないエラー 見 List 1-1 "max2x1.h" a, b max2 List 1-1 chap01/max2x1.h max2 "max2x1.h" #define max2(a, b) ((a) > (b)? (a) : (b)) max2 List 1-2 List 1-2 chap01/max2x1test.c max2 #include

More information

[ 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:

[ 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 ) ;

More information

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf(hello World\n); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o 18 C ( ) 1 1 1.1 hello world.c 5 printf("hello World\n"); 6 } [ ] [ ] #include % cc hello_world.c %./a.out Hello World [a.out ] % cc hello_world.c -o hello_world [ ( ) ] (K&R 4.1.1) #include

More information

ex12.dvi

ex12.dvi 1 0. C, char., char, 0,. C, ("),., char str[]="abc" ; str abc.,, str 4. str 3. char str[10]="abc" ;, str 10, str 3., char s[]="abc", t[10] ;, t = s. ASCII, 0x00 0x7F, char., "abc" 3, 1. 1 8 256, 2., 2

More information

(Basic Theory of Information Processing) 1

(Basic Theory of Information Processing) 1 (Basic Theory of Information Processing) 1 10 (p.178) Java a[0] = 1; 1 a[4] = 7; i = 2; j = 8; a[i] = j; b[0][0] = 1; 2 b[2][3] = 10; b[i][j] = a[2] * 3; x = a[2]; a[2] = b[i][3] * x; 2 public class Array0

More information

BW BW

BW BW Induced Sorting BW 11T2042B 2015 3 23 1 1 1.1................................ 1 1.2................................... 1 2 BW 1 2.1..................................... 2 2.2 BW.................................

More information

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 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

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裶²ó  ¨¡ À©¸æ¹½Â¤¡§·«¤êÊÖ¤· ¨¡ (2018) 2018 5 24 ( ) while ( ) do while ( ); for ( ; ; ) while int i = 0; while (i < 100) { printf("i = %3d\n", i); i++; while int i = 0; i while (i < 100) { printf("i = %3d\n", i); i++; while int i =

More information

橡Pro PDF

橡Pro PDF 1 void main( ) char c; /* int c; */ int sum=0; while ((c = getchar())!= EOF) if(isdigit(c) ) sum += (c-'0'); printf("%d\n", sum); main()int i,sum=0; for(i=0;i

More information

DA13

DA13 データ構造とアルゴリズム第 13 回 知能情報学メジャー 和 俊和 5 整列 5.1 整列とは 5.2 単純な整列アルゴリズム 5.3 挿 ソートとその拡張 5.4 ヒープソート 5.5 クイックソート 5.6 マージソート 5.7 値の 較を いない整列 5.6 マージソート 1 与えられたデータ A を A " と A # にほぼ 等分する. 2A " と A # を整列する. このとき, データ数が

More information

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 :=

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...

More information

Taro-再帰関数Ⅲ(公開版).jtd

Taro-再帰関数Ⅲ(公開版).jtd 0. 目次 1 1. ソート 1 1. 1 挿入ソート 1 1. 2 クイックソート 1 1. 3 マージソート - 1 - 1 1. ソート 1 1. 1 挿入ソート 挿入ソートを再帰関数 isort を用いて書く 整列しているデータ (a[1] から a[n-1] まで ) に a[n] を挿入する操作を繰り返す 再帰的定義 isort(a[1],,a[n]) = insert(isort(a[1],,a[n-1]),a[n])

More information

3 ( 9 ) ( 13 ) ( ) 4 ( ) (3379 ) ( ) 2 ( ) 5 33 ( 3 ) ( ) 6 10 () 7 ( 4 ) ( ) ( ) 8 3() 2 ( ) 9 81

3 ( 9 ) ( 13 ) ( ) 4 ( ) (3379 ) ( ) 2 ( ) 5 33 ( 3 ) ( ) 6 10 () 7 ( 4 ) ( ) ( ) 8 3() 2 ( ) 9 81 1 ( 1 8 ) 2 ( 9 23 ) 3 ( 24 32 ) 4 ( 33 35 ) 1 9 3 28 3 () 1 (25201 ) 421 5 ()45 (25338 )(2540 )(1230 ) (89 ) () 2 () 3 ( ) 2 ( 1 ) 3 ( 2 ) 4 3 ( 9 ) ( 13 ) ( ) 4 ( 43100 ) (3379 ) ( ) 2 ( ) 5 33 ( 3 )

More information

21 B92 B92 Quantum cryptography simulator

21 B92 B92 Quantum cryptography simulator 21 B92 B92 Quantum cryptography simulator 1100348 2010 3 1 B92 BB84 BB84 E91 B92 2 3 B92 4 3 5 B92, i Abstract B92 Quantum cryptography simulator Soichiro MATSUMOTO English Nowadays, the public key cryptosystem

More information

21 1 1 1 2 2 5 7 9 11 13 13 14 18 18 20 28 28 29 31 31 34 35 35 36 37 37 38 39 40 56 66 74 89 99 - ------ ------ -------------- ---------------- 1 10 2-2 8 5 26 ( ) 15 3 4 19 62 2,000 26 26 5 3 30 1 13

More information

8 / 0 1 i++ i 1 i-- i C !!! C 2

8 / 0 1 i++ i 1 i-- i C !!! C 2 C 2006 5 2 printf() 1 [1] 5 8 C 5 ( ) 6 (auto) (static) 7 (=) 1 8 / 0 1 i++ i 1 i-- i 1 2 2.1 C 4 5 3 13!!! C 2 2.2 C ( ) 4 1 HTML はじめ mkdir work 作業用ディレクトリーの作成 emacs hoge.c& エディターによりソースプログラム作成 gcc -o fuga

More information

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² –

£Ã¥×¥í¥°¥é¥ß¥ó¥°(2018) - Âè11²ó – ½ÉÂꣲ¤Î²òÀ⡤±é½¬£² – (2018) 11 2018 12 13 2 g v dv x dt = bv x, dv y dt = g bv y (1) b v 0 θ x(t) = v 0 cos θ ( 1 e bt) (2) b y(t) = 1 ( v 0 sin θ + g ) ( 1 e bt) g b b b t (3) 11 ( ) p14 2 1 y 4 t m y > 0 y < 0 t m1 h = 0001

More information

新・明解C言語 ポインタ完全攻略

新・明解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)

More information

/* 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

/* 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 kota@fbs.osaka-u.ac.jp /* do-while */ #include #include int main(void) double val1, val2, arith_mean, geo_mean; printf( \n );

More information

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の

プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; } Point; 問題 18. 問題 17 の プログラミング方法論 II 第 14,15 回 ( 担当 : 鈴木伸夫 ) 問題 17. x 座標と y 座標をメンバに持つ構造体 Point を作成せよ 但し座標 は double 型とする typedef struct{ (a) x; (b) y; Point; 問題 18. 問題 17 の Point を用いて 2 点の座標を入力するとその 2 点間の距 離を表示するプログラムを作成せよ 平方根は

More information

ohp03.dvi

ohp03.dvi 19 3 ( ) 2019.4.20 CS 1 (comand line arguments) Unix./a.out aa bbb ccc ( ) C main void int main(int argc, char *argv[]) {... 2 (2) argc argv argc ( ) argv (C char ) ( 1) argc 4 argv NULL. / a. o u t \0

More information

r08.dvi

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

More information

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru

44 6 MPI 4 : #LIB=-lmpich -lm 5 : LIB=-lmpi -lm 7 : mpi1: mpi1.c 8 : $(CC) -o mpi1 mpi1.c $(LIB) 9 : 10 : clean: 11 : -$(DEL) mpi1 make mpi1 1 % mpiru 43 6 MPI MPI(Message Passing Interface) MPI 1CPU/1 PC Cluster MPICH[5] 6.1 MPI MPI MPI 1 : #include 2 : #include 3 : #include 4 : 5 : #include "mpi.h" 7 : int main(int argc,

More information

II Time-stamp: <05/09/30 17:14:06 waki> ii

II Time-stamp: <05/09/30 17:14:06 waki> ii II waki@cc.hirosaki-u.ac.jp 18 1 30 II Time-stamp: ii 1 1 1.1.................................................. 1 1.2................................................... 3 1.3..................................................

More information

II 2 3.,, A(B + C) = AB + AC, (A + B)C = AC + BC. 4. m m A, m m B,, m m B, AB = BA, A,, I. 5. m m A, m n B, AB = B, A I E, 4 4 I, J, K

II 2 3.,, A(B + C) = AB + AC, (A + B)C = AC + BC. 4. m m A, m m B,, m m B, AB = BA, A,, I. 5. m m A, m n B, AB = B, A I E, 4 4 I, J, K II. () 7 F 7 = { 0,, 2, 3, 4, 5, 6 }., F 7 a, b F 7, a b, F 7,. (a) a, b,,. (b) 7., 4 5 = 20 = 2 7 + 6, 4 5 = 6 F 7., F 7,., 0 a F 7, ab = F 7 b F 7. (2) 7, 6 F 6 = { 0,, 2, 3, 4, 5 },,., F 6., 0 0 a F

More information

() () () () () 175 () Tel Fax

() () () () () 175 () Tel Fax JPCA-PE04-02-01-02-01S JPCA PE04-02-01-02-01S 2005 () () () () () 175 () 167-0042 3122 2 Tel 03-5310-2020Fax 03-5310-2021e-mailstd@jpca.org Detail Specification for PT Optical Module 1 PT PT 12 Optoelectronic

More information

ohp08.dvi

ohp08.dvi 19 8 ( ) 2019.4.20 1 (linked list) ( ) next ( 1) (head) (tail) ( ) top head tail head data next 1: 2 (2) NULL nil ( ) NULL ( NULL ) ( 1 ) (double linked list ) ( 2) 3 (3) head cur tail head cur prev data

More information

r11.dvi

r11.dvi 19 11 ( ) 2019.4.20 1 / 1.1 ( n n O(n 2 O(n 2 ) ( 1 d n 1 n logn O(nlogn n ( n logn C 1.2 ( ( merge 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge int *ivec_new(int size) { int *a = (int*)malloc((size+1)

More information

ohp11.dvi

ohp11.dvi 19 11 ( ) 2019.4.20 1 / ( ) n O(n 2 ) O(n 2 ) ( ) 1 d n 1 n logn O(nlogn) n ( n logn C ) 2 ( ) ( merge) 2 1 1 3 1 4 5 4 2 3 7 9 7 1 2 3 4 5 7 9 1: 2 ivec merge 3 ( ) (2) int *ivec_new(int size) { int *a

More information

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 ( ) 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

More information

Taro-スタック(公開版).jtd

Taro-スタック(公開版).jtd 0. 目次 1. 1. 1 配列によるの実現 1. 2 再帰的なデータ構造によるの実現 1. 3 地図情報処理 1. 4 問題 問題 1 グラフ探索問題 - 1 - 1. は データの出し入れが一カ所で行われ 操作は追加と削除ができるデータ構造をいう 出入口 追加 削除 操作 最初 111 追加 111 222 追加 111 222 333 追加 111 222 333 444 追加 111 222

More information

Taro-再帰関数Ⅱ(公開版).jtd

Taro-再帰関数Ⅱ(公開版).jtd 0. 目次 6. 2 項係数 7. 二分探索 8. 最大値探索 9. 集合 {1,2,,n} 上の部分集合生成 - 1 - 6. 2 項係数 再帰的定義 2 項係数 c(n,r) は つぎのように 定義される c(n,r) = c(n-1,r) + c(n-1,r-1) (n 2,1 r n-1) = 1 (n 0, r=0 ) = 1 (n 1, r=n ) c(n,r) 0 1 2 3 4 5

More information

‚æ2›ñ C„¾„ê‡Ìš|

‚æ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

More information

Taro-プログラミングの基礎Ⅱ(公

Taro-プログラミングの基礎Ⅱ(公 0. 目次 2. プログラムの作成 2. 1 コラッツ問題 自然数 n から出発して n が偶数ならば 2 で割り n が奇数ならば 3 倍して 1 を足す操作を行う この操作を繰り返すと最後に 1 になると予想されている 問題 1 自然数 aの操作回数を求めよ 問題 2 自然数 aから bまでのなかで 最大操作回数となる自然数を求めよ 2. 2 耐久数 正整数の各桁の数字を掛け 得られた結果についても同様の操作を繰り返す

More information

2 P.S.P.T. P.S.P.T. wiki 26

2 P.S.P.T. P.S.P.T. wiki  26 P.S.P.T. C 2011 4 10 2 P.S.P.T. P.S.P.T. wiki p.s.p.t.since1982@gmail.com http://www23.atwiki.jp/pspt 26 3 2 1 C 8 1.1 C................................................ 8 1.1.1...........................................

More information

I 2 tutimura/ I 2 p.1/??

I 2   tutimura/ I 2 p.1/?? I 2 tutimura@mist.i.u-tokyo.ac.jp http://www.misojiro.t.u-tokyo.ac.jp/ tutimura/ 2002 4 25 I 2 p.1/?? / / Makefile I 2 p.2/?? Makefile make GNU make I 2 p.3/?? Makefile L A T E X I 2 p.4/?? core (1) gcc,

More information

LINEAR ALGEBRA I Hiroshi SUZUKI Department of Mathematics International Christian University

LINEAR ALGEBRA I Hiroshi SUZUKI Department of Mathematics International Christian University LINEAR ALGEBRA I Hiroshi SUZUKI Department of Mathematics International Christian University 2002 2 2 2 2 22 2 3 3 3 3 3 4 4 5 5 6 6 7 7 8 8 9 Cramer 9 0 0 E-mail:hsuzuki@icuacjp 0 3x + y + 2z 4 x + y

More information

A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clan

A 30 A A ( ) 2 C C (, machine language) C (C compiler) ( ) Mac Apple Xcode Clan C 2017 9 29, 30 5 13 http://nalab.mind.meiji.ac.jp/~mk/labo/text/ 1 2 2 C 2 3 4 3.1 C................................... 4 3.2 Hello world........................................ 5 3.3 5...............................

More information

A common.h include #include <stdio.h> #include <time.h> #define MAXN int A[MAXN], n; double start,end; void inputdata(

A common.h include #include <stdio.h> #include <time.h> #define MAXN int A[MAXN], n; double start,end; void inputdata( 2 065762A 19 7 13 1 2 2.1 common.h include #include #include #define MAXN 1000000 int A[MAXN], n; double start,end; void inputdata(void) int i; // printf(" "); scanf("%d",&n); // printf("

More information

untitled

untitled W1A W1B W1C W1D W1E W1F W1G W1H W1I W1J W1K W1L W1N W1O W1P W1Q W1R W2A W2B W2C W2D W2F W2G W2H W2I W2J W2K W2L W2N W2O W2P W2Q W2R W3A W3B W3C W3D W3E W3F W3G W3H W3I W3J W3K W3N W3O W3P W3Q W3R W4A W4B

More information

matrix util program bstat gram schmidt

matrix util program bstat gram schmidt matrix util 14 12 3 1 2 2 program 2 2.1 bstat............................... 3 2.2 gram schmidt........................... 3 2.3 matadd............................... 3 2.4 matarith.............................

More information

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

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

More information

C言語によるアルゴリズムとデータ構造

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",

More information

3-1. 1) 1-1) =10.92m =18.20m m 2 6,480 3, =30 30kN/m 2 Z=0.9

3-1. 1) 1-1) =10.92m =18.20m m 2 6,480 3, =30 30kN/m 2 Z=0.9 3-1. 3-2. 3-3. 3-1. 1) 1-1) =10.92m =18.20m 198.74m 2 6,480 3,800 4.5 =30 30kN/m 2 Z=0.9 1-2) G1 G2 G3 G4 1-3) G1 G2 H3 1-4) t = 12 2.5 2) 2-1) No ( ) 1 120 120 2 120 120 3 120 180 360 4 120 150 210 5

More information

5 n P j j (P i,, P k, j 1) 1 n n ) φ(n) = n (1 1Pj [ ] φ φ P j j P j j = = = = = n = φ(p j j ) (P j j P j 1 j ) P j j ( 1 1 P j ) P j j ) (1 1Pj (1 1P

5 n P j j (P i,, P k, j 1) 1 n n ) φ(n) = n (1 1Pj [ ] φ φ P j j P j j = = = = = n = φ(p j j ) (P j j P j 1 j ) P j j ( 1 1 P j ) P j j ) (1 1Pj (1 1P p P 1 n n n 1 φ(n) φ φ(1) = 1 1 n φ(n), n φ(n) = φ()φ(n) [ ] n 1 n 1 1 n 1 φ(n) φ() φ(n) 1 3 4 5 6 7 8 9 1 3 4 5 6 7 8 9 1 4 5 7 8 1 4 5 7 8 10 11 1 13 14 15 16 17 18 19 0 1 3 4 5 6 7 19 0 1 3 4 5 6 7

More information

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i )

x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x i ) A(x i ) = h 2 {f(x i) + f(x i+1 ) = h {f(a + i h) + f(a + (i + 1) h), (2) 2 a b n A(x i ) 1 f(x) a b f(x)dx = n A(x i ) (1) ix [a, b] n i A(x i ) x i 1 f(x) [a, b] n h = (b a)/n y h = (b-a)/n y = f (x) h h a a+h a+2h a+(n-1)h b x 1: 1 x h = (b a)/n [x i, x i+1 ] = [a+i h, a+ (i + 1) h] A(x

More information

28

28 y i = Z i δ i +ε i ε i δ X y i = X Z i δ i + X ε i [ ] 1 δ ˆ i = Z i X( X X) 1 X Z i [ ] 1 σ ˆ 2 Z i X( X X) 1 X Z i Z i X( X X) 1 X y i σ ˆ 2 ˆ σ 2 = [ ] y i Z ˆ [ i δ i ] 1 y N p i Z i δ ˆ i i RSTAT

More information

Microsoft Word - Sample_CQS-Report_English_backslant.doc

Microsoft Word - Sample_CQS-Report_English_backslant.doc ***** Corporation ANSI C compiler test system System test report 2005/11/16 Japan Novel Corporation *****V43/NQP-DS-501-1 Contents Contents......2 1. Evaluated compiler......3 1.1. smp-compiler compiler...3

More information

実際の株価データを用いたオプション料の計算

実際の株価データを用いたオプション料の計算 2002 2 20 1 1 3 2 3 2.1 : : : : : : : : : : : : : : : : : : : : : : : : : : : : 5 2.1.1 : : : : : : : : : : : : : : : : : : : : 5 2.1.2 : : : : : : : : : : : : : : : : : : : : 6 2.2 : : : : : : : : : :

More information

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 >=

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 : : proen@mm.ics.saitama-u.ac.jp 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

More information

tuat1.dvi

tuat1.dvi ( 1 ) http://ist.ksc.kwansei.ac.jp/ tutimura/ 2012 6 23 ( 1 ) 1 / 58 C ( 1 ) 2 / 58 2008 9 2002 2005 T E X ptetex3, ptexlive pt E X UTF-8 xdvi-jp 3 ( 1 ) 3 / 58 ( 1 ) 4 / 58 C,... ( 1 ) 5 / 58 6/23( )

More information

Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1) (2) ( ) BASIC BAS

Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1) (2) ( ) BASIC BAS Appendix A BASIC BASIC Beginner s All-purpose Symbolic Instruction Code FORTRAN COBOL C JAVA PASCAL (NEC N88-BASIC Windows BASIC (1 (2 ( BASIC BASIC download TUTORIAL.PDF http://hp.vector.co.jp/authors/va008683/

More information

memo

memo 計数工学プログラミング演習 ( 第 3 回 ) 2017/04/25 DEPARTMENT OF MATHEMATICAL INFORMATICS 1 内容 ポインタの続き 引数の値渡しと参照渡し 構造体 2 ポインタで指されるメモリへのアクセス double **R; 型 R[i] と *(R+i) は同じ意味 意味 R double ** ポインタの配列 ( の先頭 ) へのポインタ R[i]

More information

sim98-8.dvi

sim98-8.dvi 8 12 12.1 12.2 @u @t = @2 u (1) @x 2 u(x; 0) = (x) u(0;t)=u(1;t)=0fort 0 1x, 1t N1x =1 x j = j1x, t n = n1t u(x j ;t n ) Uj n U n+1 j 1t 0 U n j =1t=(1x) 2 = U n j+1 0 2U n j + U n j01 (1x) 2 (2) U n+1

More information