comment.dvi

Similar documents
スライド 1

スライド 1

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

XMPによる並列化実装2

スライド 1

DVIOUT

double float

スライド 1

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)

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

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

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

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

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

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

新・明解C言語 実践編

新版明解C言語 実践編

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B

超初心者用

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

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

t 2 2 t 2 t F ( ) p- 2 2 F 2 G F ( ) 2 2 F 2 G F ( ) 2 2 2

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

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

memo

memo

ex01.dvi

2006年10月5日(木)実施

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

115 9 MPIBNCpack 9.1 BNCpack 1CPU X = , B =

Prog1_12th

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

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() 2 double *a[ ]; double 1 malloc() dou

PowerPoint Presentation

lexex.dvi

untitled

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

r07.dvi

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

ohp07.dvi

PowerPoint プレゼンテーション

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

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

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 +

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

untitled

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

A/B (2010/10/08) Ver kurino/2010/soft/soft.html A/B

Microsoft PowerPoint - 14th.ppt [互換モード]

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

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

(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

プログラミング基礎

slide5.pptx

ohp03.dvi

Microsoft PowerPoint - kougi9.ppt


卒 業 研 究 報 告.PDF

P05.ppt

PC Windows 95, Windows 98, Windows NT, Windows 2000, MS-DOS, UNIX CPU

untitled

C

Łñ“’‘‚2004

プリント


橡Pro PDF

QR

main

program.dvi

tuat1.dvi

PowerPoint Presentation

Microsoft PowerPoint - 第3回目.ppt [互換モード]

Taro-ファイル処理(公開版).jtd

USB ID TA DUET 24:00 DUET XXX -YY.c ( ) XXX -YY.txt() XXX ID 3 YY ID 5 () #define StudentID 231

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

joho07-1.ppt

memo

gengo1-12

Gauss

para02-2.dvi

AutoTuned-RB

プログラミング及び演習 第1回 講義概容・実行制御

(search: ) [1] ( ) 2 (linear search) (sequential search) 1

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

コンピュータ概論

ex01.dvi

DKA ( 1) 1 n i=1 α i c n 1 = 0 ( 1) 2 n i 1 <i 2 α i1 α i2 c n 2 = 0 ( 1) 3 n i 1 <i 2 <i 3 α i1 α i2 α i3 c n 3 = 0. ( 1) n 1 n i 1 <i 2 < <i

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

memo

1.ppt

gengo1-12


Microsoft PowerPoint - 11th.ppt [互換モード]

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

r08.dvi

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

$ ls -l $ ls -l -a $ ls -la $ ls -F $ ls <dirname> <dirname> $ cd <dirname> <dirname> $ cd $ pwd $ cat <filename> <filename> $ less <filename> <filena

Microsoft Word - cpro_m_13.doc

ohp08.dvi

Transcription:

( ) (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) /* ----------------------------------------------------------------- */ /* (2 2 ver.) */ /* ----------------------------------------------------------------- */ /* Nearest Neighbor */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define LDATA 20 // #define TDATA 40 // #define DIM 2 // double class1[ldata][dim]; double class2[ldata][dim]; // 1 // 2 double test[tdata][dim]; // ( ) int tans[tdata]; // int result[tdata]; // double met1[tdata]; // ( 1) double met2[tdata]; // ( 2) int main(int argc, char* argv[]){ /* ---------- ---------- */ int input(); // int nearest(); // Nearest Neighbor int output(); // /********** **********/ input(); /********** Nearest Neighbor **********/ nearest(); /********** **********/ output(); return(0); 2

/* ---------------------------------------------------- */ /* */ /* ---------------------------------------------------- */ int input(){ FILE *fin1, *fin2, *fin3; int i, j; // /* ----------- open ---------- */ fin1 = fopen("2d-class1.dat", "r"); if( fin1 == NULL){ fprintf(stderr, "file open error : 2D-class1.dat \n"); return -1; fin2 = fopen("2d-class2.dat", "r"); if( fin2 == NULL){ fprintf(stderr, "file open error : 2D-class2.dat \n"); return -1; fin3 = fopen("2d-test.dat", "r"); if( fin3 == NULL){ fprintf(stderr, "file open error : 2D-test.dat \n"); return -1; /* ---------- ---------- */ for(i=0;i<ldata;i++){ for(j=0;j<dim;j++){ fscanf(fin1, "%lf", &class1[i][j]); fscanf(fin2, "%lf", &class2[i][j]); for(i=0;i<tdata;i++){ for(j=0;j<dim;j++) fscanf(fin3, "%lf", &test[i][j]); fscanf(fin3, "%d", &tans[i]); /* ---------- close ---------- */ fclose(fin1); fclose(fin2); fclose(fin3); return 0; 3

/* ---------------------------------------------------- */ /* Nearest Neighbor */ /* ---------------------------------------------------- */ int nearest(){ double min1, min2, dist, tmp; /* min1 min2 */ /* */ int i, j, k; for(k=0;k<tdata;k++){ min1 = min2 = 9999999; // for(i=0;i<ldata;i++){ /* ---------- ---------- */ tmp = 0; for(j=0;j<dim;j++) tmp += (test[k][j] - class1[i][j]) * (test[k][j] - class1[i][j]); dist = sqrt(tmp); if(min1 > dist) min1 = dist; /* min1 */ /* ---------- ---------- */ tmp = 0; for(j=0;j<dim;j++) tmp += (test[k][j] - class2[i][j]) * (test[k][j] - class2[i][j]); dist = sqrt(tmp); if(min2 > dist) min2 = dist; /* min2 */ met1[k] = min1; met2[k] = min2; /* */ if(min1 <= min2) result[k] = 1; else result[k] = 2; return 0; /* ---------------------------------------------------- */ /* */ /* ---------------------------------------------------- */ int output(){ 4

FILE *fout; int k; /* ---------- open ---------- */ fout = fopen("2d-result.dat", "w"); if( fout == NULL){ fprintf(stderr, "file open error : result.dat \n"); return -1; /* ---------- ---------- */ fprintf(fout, "NUM MIN1 MIN2 RES ANS o/x\n"); fprintf(fout, "--------------------------------\n"); for(k=0;k<tdata;k++){ fprintf(fout, "%3d %4.2lf %4.2lf %3d %3d ", k+1, met1[k], met2[k], result[k], tans[k]); if(result[k] == tans[k]) fprintf(fout, "o \n"); else fprintf(fout, "x \n"); /* ---------- close ---------- */ fclose(fout); return 0; 5

input() nearest() Nearest Neighbor output() 3 1 1 /* ---------- ---------- */ int input(); // int nearest(); // Nearest Neighbor int output(); // 1 1 (x ) 2 1 (x ) 3 1 (x ). 1 2 (y ) 2 2 (y ) 3 2 (y ). i j class[i][j] 2 1 2 2 #define LDATA 20 // #define TDATA 40 // #define DIM 2 // double class1[ldata][dim]; double class2[ldata][dim]; // 1 // 2 double test[tdata][dim]; // ( ) 6

3 /* ---------- ---------- */ for(i=0;i<ldata;i++){ for(j=0;j<dim;j++){ fscanf(fin1, "%lf", &class1[i][j]); fscanf(fin2, "%lf", &class2[i][j]); for(i=0;i<tdata;i++){ for(j=0;j<dim;j++) fscanf(fin3, "%lf", &test[i][j]); fscanf(fin3, "%d", &tans[i]); 7

1. URL sample1.c 2D-class1.dat 2D-class2.dat 2D-test.dat http://www.it.ecei.tohoku.ac.jp/pattern/ 2. % cc sample1.c -lm 3. % a.out 4. % less result.dat 8

(u-eigen.c g-eigen.c) (u-eigen.c g-eigen.c) N CLAPACK u-eigen.c - Ax = λx g-eigen.c - Ax = λbx (u-eigen.c) /* Ax = x */ /* C interface example for dsyev hidehisa_2006/05/01 */ #include <stdio.h> #include <stdlib.h> #include <PRT.h> /* #define L (64) */ int main( void ){ FILE int *fp; ds; int N; // double A[L][L],E[L],V[L][L]; int i,j; /* ---------- ---------- */ fp=fopen( "NA4.dat", "r"); // if( fp==null ){ fprintf(stderr,"file open error\n"); return(-1); else{ fscanf(fp, "%d", &N ); // for(i=0;i<n;i++) for(j=0;j<n;j++) fscanf(fp,"%lf", &A[i][j] ); // fclose( fp ); 9

/* ---------- ---------- */ ds=dsyev(n,a,e,v); if( ds < 0 ){ perror("dsyev"); exit(2); /* ---------- ---------- */ fprintf(stderr,"*** Output ***\n\n"); for(i=0;i<n;i++) fprintf(stderr,"\t Eigenvalue"); for(i=0;i<n;i++) fprintf(stderr,"\t %9.6lf", E[i] ); fprintf(stderr,"\n\n"); for(i=0;i<n;i++) fprintf(stderr,"\t Eigenvector"); for(j=0;j<n;j++){ for(i=0;i<n;i++) fprintf(stderr,"\t %9.6lf", V[i][j] ); return( 0 ); (g-eigen.c) /* Ax = Bx */ /* C interface example for dsygv hidehisa_2006/05/01 */ #include <stdio.h> #include <stdlib.h> #include <PRT.h> /* #define L ( 64 ) */ int main( void ){ FILE int *fp; ds; int N; // double A[L][L],B[L][L],E[L],V[L][L]; int i,j; /* ---------- ---------- */ fp=fopen( "NAB4.dat", "r"); if( fp==null ){ fprintf(stderr,"file open error\n"); return(-1); else{ 10

fscanf(fp, "%d", &N ); // if( N > L ){ perror("input N"); exit(1); for(i=0;i<n;i++) for(j=0;j<n;j++) fscanf(fp,"%lf", &A[i][j] ); // A for(i=0;i<n;i++) for(j=0;j<n;j++) fscanf(fp,"%lf", &B[i][j] ); // B fclose( fp ); /* ---------- ---------- */ ds=dsygv(n,a,b,e,v); if( ds < 0 ){ perror("dsygv"); exit(2); /* ---------- ---------- */ fprintf(stderr,"*** Output ***\n\n"); for(i=0;i<n;i++) fprintf(stderr,"\t Eigenvalue"); for(i=0;i<n;i++) fprintf(stderr,"\t %9.6lf", E[i] ); fprintf(stderr,"\n\n"); for(i=0;i<n;i++) fprintf(stderr,"\t Eigenvector"); for(j=0;j<n;j++){ for(i=0;i<n;i++) fprintf(stderr,"\t %9.6lf", V[i][j] ); return( 0 ); 11

(NAB4.dat) 1 (g-eigen.c) )4 A = 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 4 B = 153 31 58 58 31 153 58 58 58 58 153 31 58 58 31 153 4 // 2 1 1 2 // A 1 1 1 1 1 1 2 2 2 1 2 4 153 31 58-58 // B 31 153-58 58 58-58 153 31-58 58 31 153 (u-eigen.c) A 12

1. URL u-eigen.c g-eigen.c NA4.dat NAB4.dat http://www.it.ecei.tohoku.ac.jp/pattern/ 2. (LAPACK) "$PRTFLAG" % cc u-eigen.c $PRTFLAG % cc g-eigen.c $PRTFLAG 3. % a.out 13