Computer Programming I (Advanced)

Similar documents
Introduction to Information and Communication Technology (a)

Yamaha Steinberg USB Driver V for Mac Release Notes

電脳梁山泊烏賊塾 構造体のサイズ. Visual Basic

Unofficial Redmine Cooking - QA #782 yaml_db を使った DB のマイグレーションで失敗する

今日の予定 1. 展開図の基礎的な知識 1. 正多面体の共通の展開図. 2. 複数の箱が折れる共通の展開図 :2 時間目 3. Rep-Cube: 最新の話題 4. 正多面体に近い立体と正 4 面体の共通の展開図 5. ペタル型の紙で折るピラミッド型 :2 時間目 ~3 時間目

Androidプログラミング 2 回目 迫紀徳

Methods to Detect Malicious MS Document File using File Structure Inspection

J の Lab システムの舞台裏 - パワーポイントはいらない -

サーブレットと Android との連携. Generated by Foxit PDF Creator Foxit Software For evaluation only.

本書について... 7 本文中の表記について... 7 マークについて... 7 MTCE をインストールする前に... 7 ご注意... 7 推奨 PC 仕様... 8 MTCE をインストールする... 9 MTCE をアンインストールする... 11

A. 展開図とそこから折れる凸立体の研究 1. 複数の箱が折れる共通の展開図 2 通りの箱が折れる共通の展開図 3 通りの箱が折れる共通の展開図そして. 残された未解決問題たち 2. 正多面体の共通の展開図 3. 正多面体に近い立体と正 4 面体の共通の展開図 ( 予備 )

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

フラクタル 1 ( ジュリア集合 ) 解説 : ジュリア集合 ( 自己平方フラクタル ) 入力パラメータの例 ( 小さな数値の変化で模様が大きく変化します. Ar や Ai の数値を少しずつ変化させて描画する. ) プログラムコード. 2010, AGU, M.

携帯電話の 吸収率 (SAR) について / Specific Absorption Rate (SAR) of Mobile Phones

Cloud Connector 徹底解説. 多様な基盤への展開を可能にするための Citrix Cloud のキーコンポーネント A-5 セールスエンジニアリング本部パートナー SE 部リードシステムズエンジニア. 哲司 (Satoshi Komiyama) Citrix

Agilent. IO Libraries Suite 16.3/16.2 簡易取扱説明書. [ IO Libraries Suite 最新版 ]

MySQL Cluster 7.3 リリース記念!! 5 分で作る MySQL Cluster 環境

Online Meetings with Zoom

Certificate of Accreditation

JASCO-HPLC Operating Manual. (Analytical HPLC)

Yamaha Steinberg USB Driver V for Windows Release Notes

Quick Install Guide. Adaptec SCSI RAID 2120S Controller

API サーバの URL. <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE COMPLIANCE_SCAN SYSTEM "

PSLT Adobe Typekit Service (2016v1.1)

PCIe SSD PACC EP P3700 Intel Solid-State Drive Data Center Tool

振込依頼書記入要領 Entry Guide for Direct Deposit Request Form

Googleの強みは ささえるのは世界一のインフラ. Google File System 2008年度後期 情報システム構成論2 第10回 クラウドと協調フィルタリング. 初期(1999年)の Googleクラスタ. 最近のデータセンタ Google Chrome Comicより

WD/CD/DIS/FDIS stage

PRODUCT DESCRIPTIONS AND METRICS

Saki is a Japanese high school student who/ has just started to study/ in the US.//

Chapter 1 Videos Lesson 61 Thrillers are scary ~Reading~

Yamaha Steinberg USB Driver V for Windows Release Notes

UB-U01III/U02III/U03II User s Manual

Zabbix ログ解析方法. 2018/2/14 サイバートラスト株式会社 Linux/OSS 事業部技術統括部花島タケシ. Copyright Cybertrust Japan Co., Ltd. All rights reserved.

Certificate of Accreditation

Snoop cache. AMANO, Hideharu, Keio University Textbook pp.40-60

暗い Lena トーンマッピング とは? 明るい Lena. 元の Lena. tone mapped. image. original. image. tone mapped. tone mapped image. image. original image. original.

MathWorks Products and Prices Japan September 2016

DürrConnect the clever connection. The quick connection with the Click

2007/10/17 ソフトウェア基礎課題布広. /** * SOFT * AppletTest01.java * 文字表示 */

2. 集団の注目位置推定 提案手法では 複数の人物が同一の対象を注視している状況 置 を推定する手法を検討する この状況下では 図 1 のよう. 顔画像からそれぞれの注目位置を推定する ただし f は 1 枚 この仮説に基づいて 複数の人物を同時に撮影した低解像度顔

楽天株式会社楽天技術研究所 Autumn The Seasar Foundation and the others all rights reserved.

~ ソフトウエア認証への取り組みと課題 ~

Private Sub 終了 XToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 終了 XToolStripMenuItem.

Relaxed Consistency models and software distributed memory. Computer Architecture Textbook pp.79-83

TOOLS for MR V1.7.7 for Mac Release Notes

マルチビットアップセット耐性及びシングルビットアップセット耐性を備えた

UML. A Model Trasformation Environment for Embedded Control Software Design with Simulink Models and UML Models

Quick Installation Manual

Centralized (Indirect) switching networks. Computer Architecture AMANO, Hideharu

DSK8AD1DA. 8ch A/D & 1ch D/A for DSK/EVM.

Video Annotation and Retrieval Using Vague Shot Intervals

サンプル. NI TestStand TM I: Introduction Course Manual

Rechargeable LED Work Light

IRS16: 4 byte ASN. Version: 1.0 Date: April 22, 2008 Cisco Systems 2008 Cisco, Inc. All rights reserved. Cisco Systems Japan

Lecture 4 Branch & cut algorithm

User Guide. P6 Barcode Scanner. English 日本語

アルゴリズムの設計と解析 (W4022) 教授 : 黄潤和 広野史明 (A4/A8)

Operational Precaution

Infragistics ASP.NET リリースノート

Synchronization with shared memory. AMANO, Hideharu Textbook pp.60-68

TRACE32 Training... シンボルデータベース 内部シンボルデータベースの構造 シンボルデータベースの一般情報 シンボルブラウザ 選択したシンボルの詳細 ソースファイル内の検索...

The Secret Life of Components

Web 成績登録システム利用の手引き ( 改訂版 )

Unified System Management Technology for Data Centres

Studies of Large-Scale Data Visualization: EXTRAWING and Visual Data Mining

PNRGOV/Ver11.1/ 旅客氏名表予約情報報告 (PNR01)

グラフを表すデータ構造 JAVA での実装

Web Billing User Guide

The Judgment of Document Similarities Orthogonal Transformations and Improvement of the property

プログラマ本体 I/F 回路図 -Programmer I/F Circuit Diagram-...2 FLASH2 内部 2 FLASHMATE5V1 内部 2

Interdomain Routing Security Workshop 21 BGP, 4 Bytes AS. Brocade Communications Systems, K.K.

和英対訳版. IEC Standard Template のユーザーガイド 備考 : 英語原文掲載 URL ( 一財 ) 日本規格協会

NI TB Introduction. Conventions INSTALLATION INSTRUCTIONS Wire Terminal Block for the NI PXI-2529

NUC and its Applications

Vehicle Calibration Techniques Established and Substantiated for Motorcycles

IPv6 関連 WG の状況 (6man, v6ops, softwire)

Apollo-LakeタブレットにUbuntu17.10を Install Ubuntu17.10 on Apollo-Lake Tablet

A note on quaternion, applied to attitude estimation Minoru HIGASHIGUCHI 四元数について衛星姿勢の逐次推定への応用例

HPE Insight Control サーバープロビジョニング 7.6 ビルドプランリファレンスガイド

ご注意. (4) 運用した結果の影響につきましては (4) の項に関わらず責任を負いかねますのでご了承ください (5) Autodesk Device Interface(ADI) および Heidi Device Interface(HDI) ドライバは 周辺機器メーカーに対応しています

URL IO オブジェクト指向プログラミング特論 2018 年度只木進一 : 工学系研究科

MetaSMIL : A Description Language for Dynamic Integration of Multimedia Content

FUJITSU Software SystemcastWizard Professional V5.1 L30 ユーザーズガイド B7FW Z0(00) 2014 年 8 月

製 品 ガ イ ド NetShield for NetWare V E R S I O N 4. 6

tp.responsewriter, r *http.request) { /* Hmmm, I wonder if this main */ hosttokens := strings.split(r.host, ":"); if len(hosttok

Infrared Data Association Trademark and Brand Guidelines

QPHY-SATA Serial ATA Serial Data オペレーターズ マニュアル

BMW Head Up Display (HUD) Teardown BMW ヘッドアップディスプレイティアダウン

PGroonga 2. Make PostgreSQL rich full text search system backend!

SteelEye Protection Suite for Linux

Dream the sky. Make it yours.

QuickTransit for Solaris/SPARC-to-Linux/Itanium 動作検証報告書 株式会社ネットワールドシステム基盤技術部プラットフォームソリューショングループ丸山真一

IP Network Technology

L3 SSG/SSD を使用している PPPoA クライアントで PC を設定すること

BraindumpStudy. BraindumpStudy Exam Dumps, High Pass Rate!

船舶保安システムのセルフチェックリスト. Record No. Name of Ship 船名 flag 国籍 Name of Company 会社名 Date 点検日 Place 場所 Checked by 担当者名. MS-SELF-CHK-SHIP-j (2012.

Nonfinancial Reporting Track:03 Providing non-financial information to reporters, analysts and asset managers; the EDINET Case

さまざまなニーズにお応えできるラインナップ!

Preparing Information Design-Oriented. Posters. easy to. easy to. See! Understand! easy to. Convey!

Transcription:

Computer Programming I (Advanced) 7 th week Kazumasa Yamamoto Dept. Comp. Sci. & Eng. Computer Programming I (Adv.) 7th week 1

Exercise of last week 1. Sorting by bubble sort Compare the bubble sort with qsort() in the standard library by using clock(). How slow is the bubble sort? 2. Character string search by Boyer-Moore algorithm Compare the BM algorithm with a brute-force method with strncmp() by using clock(). How fast is the BM algorithm? Computer Programming I (Adv.) 7th week 2

前回の課題 1. バブルソートによるソーティング 標準ライブラリ内の qsort() と比べて どれくらい遅いか clock() を使って見てみる 2. Boyer-Moore 法による文字列検索 strncmp() で力任せに検索するのと比べて どれくらい速くなるか clock() を使って見てみる Computer Programming I (Adv.) 7th week 3

Today s contents Control of auxiliary programs pipe gnuplot How to use Exercise: Game of Life (with gnuplot) Computer Programming I (Adv.) 7th week 4

今日の内容 外部プログラムを制御する パイプ gnuplot 簡単な使い方 課題 : ライフゲーム ( 表示は gnuplot で ) Computer Programming I (Adv.) 7th week 5

Control of auxiliary programs Controlling an auxiliary program from a C language program Run an auxiliary program Then, pass data to the running program Pass the data by using pipe pipe in shell command line $ ls less Do the same thing by yourself! Computer Programming I (Adv.) 7th week 6

外部プログラムの制御 C 言語のプログラムから 既存の外部プログラムを制御する 外部プログラムを動かす 動いている外部プログラムにデータを渡す パイプを使ってデータを渡すことを考える shellのコマンドラインで使うパイプ $ ls less 自前でやってみよう Computer Programming I (Adv.) 7th week 7

Program control by pipe Open / close of a pipe popen() / pclose() popen() Open a pipe 1 st arg. : command line character string 2 nd arg. : file mode (the same as in fopen() ) Return value : a pointer to the pipe (FILE structure) pclose() Close the pipe Argument : the pointer to the pipe (FILE structure) Computer Programming I (Adv.) 7th week 8

パイプによるプログラム制御 パイプを開く 閉じる popen() / pclose() popen() パイプを開く 第 1 引数 : コマンドライン文字列 第 2 引数 : 開くモード (fopen() と同じ ) 返り値 : ファイル構造体へのポインタ pclose() パイプを閉じる 引数 : ファイル構造体へのポインタ Computer Programming I (Adv.) 7th week 9

Simple example #include <stdio.h> int main() { FILE *pipe; char str[256]; // <stdio.h> has definitions of pipe related. // a FILE structure variable. The same as for a file. pipe = popen( ls -1, r ); // read the result of ls -1 while (fgets(str, 256, pipe)!= NULL) { // Input / Output of pipe is printf( %s, str); // the same as a file, because } // it s via the FILE structure } pclose(pipe); // Close the pipe Computer Programming I (Adv.) 7th week 10

単純な例 #include <stdio.h> int main() { FILE *pipe; char str[256]; // パイプ関係のものは <stdio.h> で宣言されている // パイプ用のファイル構造体 普通のファイルと同じ pipe = popen( ls -1, r ); // ls -1 の結果を読み込む while (fgets(str, 256, pipe)!= NULL) { // パイプに対する入出力は printf( %s, str); // ファイル構造体経由なので } // 普通のファイルと同じ } pclose(pipe); // パイプを閉じる Computer Programming I (Adv.) 7th week 11

How to send data The former example code reads output of an auxiliary program. How to send data? Run an auxiliary program which can read data from the standard input. with an option which lets the program be able to do it, etc. Write data by fprintf(), etc. in your code. Computer Programming I (Adv.) 7th week 12

データを送るには 先ほどの例は 外部プログラムの出力を読み込んでいた データを送るには? 外部プログラムを標準入力からデータを読み込めるようにして起動 それ用のオプションを付ける等 fprintf() 等でデータを書き込む Computer Programming I (Adv.) 7th week 13

gnuplot A software to draw charts An isolated appricaton, not library By giving coordinate (x, y (, z)) data sets as text data, gnuplot draws a chart. Computer Programming I (Adv.) 7th week 14

gnuplot グラフを描くための独立したソフトウェア ライブラリではない テキストデータとして x 座標 y 座標 ( z 座標 ) の組み合わせのデータを与えることで グラフを描く Computer Programming I (Adv.) 7th week 15

Try running gnuplot (1) $ xterm (on xterm) $ gnuplot (snip) gnuplot> set terminal xterm gnuplot> plot sample1.txt gnuplot> plot sample1.txt with line gnuplot> plot sample1.txt with points gnuplot> plot sample1.txt with points pointtype 2 gnuplot> plot sample1.txt with points pointtype 3 gnuplot> plot sample1.txt with points pointtype 4 Computer Programming I (Adv.) 7th week 16

gnuplot を動かしてみる (1) $ xterm (xterm 上で ) $ gnuplot ( 省略 ) gnuplot> set terminal xterm gnuplot> plot sample1.txt gnuplot> plot sample1.txt with line gnuplot> plot sample1.txt with points gnuplot> plot sample1.txt with points pointtype 2 gnuplot> plot sample1.txt with points pointtype 3 gnuplot> plot sample1.txt with points pointtype 4 Computer Programming I (Adv.) 7th week 17

Try running gnuplot (2) $ gnuplot (snip) gnuplot> plot - input data( e ends) > 10 5 input data( e ends) > 20 10 input data( e ends) > 30 15 input data( e ends) > 40 20 input data( e ends) > 50 25 input data( e ends) > 60 30 input data( e ends) > e gnuplot> Computer Programming I (Adv.) 7th week 18

gnuplot を動かしてみる (2) $ gnuplot ( 省略 ) gnuplot> plot - input data( e ends) > 10 5 input data( e ends) > 20 10 input data( e ends) > 30 15 input data( e ends) > 40 20 input data( e ends) > 50 25 input data( e ends) > 60 30 input data( e ends) > e gnuplot> Computer Programming I (Adv.) 7th week 19

Requirements for exercise of this week Starting option -persist Not erase the graph window if the program finished. Without this option, the graph window will disappear when closing the pipe. This is maybe default behavior... Drawing charts set xrange [0:100], set yrange [0:100] Specifying chart ranges (for x- and y-coordinates) Do once at beginning - given as a plot command option instead of a file name Reads data from the standard input e should be sent when finishing the data transmission. By combining with pipe, you can send data from your code. Do input by your code instead of the keyboard input in the former example. Computer Programming I (Adv.) 7th week 20

今日の課題で必要なこと 起動時オプション -persist プログラムが終了してもグラフウィンドウを消さないようにする これを付けていないと パイプを閉じた段階でグラフウィンドウが消える デフォルトの動作になっているかも? グラフ描画時 set xrange [0:100] set yrange [0:100] グラフの範囲の指定 最初に 1 回だけやれば良い plot コマンドでファイル名のところを - とする 標準入力からデータを読むようになる データの最後を示すためには e のみを送る パイプと組み合わせることで プログラムからデータを流せる 先ほどの例でキーボードで入力した部分をプログラムにやらせる Computer Programming I (Adv.) 7th week 21

Overview of this week s exercise Game of Life Use gnuplot for displaysing graphically Your code must show the alternation of generations by sending data to gnuplot via pipe. Up and down, left and right of the cell area should be connected circulatedly. Computer Programming I (Adv.) 7th week 22

今日の課題概要 ライフゲーム グラフィカルに表示するために gnuplot を利用 pipe で gnuplot にデータを送って 世代交代の様子を見れるようにする セルのエリアは上下 左右が繋がって循環しているものとして作成すること Computer Programming I (Adv.) 7th week 23

Game of Life Here, we will treat the standard 23/3 Game of Life. Rule (from Wikipedia) The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. The initial pattern constitutes the seed of the system. The first generation is created by applying the below rules simultaneously to every cell in the seed births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called a tick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations. Every cell interacts with its eight neighbors, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur: Birth : Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction. Live : Any live cell with two or three live neighbors lives on to the next generation. Under-population : Birth : Any live cell with fewer than two live neighbors dies, as if caused by under-population. Over-population : Any live cell with more than three live neighbors dies, as if by overpopulation. Computer Programming I (Adv.) 7th week 24

ライフゲーム ここでは標準的な 23/3 ライフゲームを考える ルール (Wikipedia より ) 碁盤の格子状のものを考える その格子 1 つ 1 つをセルと呼ぶ セルには 生 死 の状態がある セルの生死は まず初期状態として与えられ その後は 以下のルールに沿って 1 世代ごとに変化していく あるセルに注目すると そのセルには 上下左右斜め方向に 8 個のセルがあり これらを 隣接するセル とする 誕生 : 死んでいるセルに隣接する生きたセルがちょうど 3 つあれば 次の世代でそのセルは生となる 生存 : 生きているセルに隣接する生きたセルが 2 つか 3 つならば そのセルは次の世代でも生きる 過疎 : 生きているセルに隣接する生きたセルが 1 つ以下ならば そのセルは過疎により次の世代で死ぬ 過密 : 生きているセルに隣接する生きたセルが 4 つ以上ならば そのセルは過密により次の世代で死ぬ Computer Programming I (Adv.) 7th week 25

Data format sample1.dat, sample2.dat, sample3.dat binary formatted files All data are int type. First and second data : Size of cell area maximum of x- and y-coordinates The origin is (0, 0). Third data and then : Initial live cell coordinates x-coordinate, y-coordinate Repeated the number of initial live cells. Read them by fread() sample1.txt has the same content of sample1.dat in text mode. Use this to check your code. Computer Programming I (Adv.) 7th week 26

データ形式 sample1.dat,sample2.dat,sample3.dat バイナリファイル 全て int 型 1 つ目と 2 つ目のデータ : セルのエリアの大きさ x 座標の最大値と y 座標の最大値 原点は (0,0) それ以降 : 初期配置の生きたセルの座標 x 座標値,y 座標値 初期配置の生きたセルの数だけ繰り返し fread() を使って読む sample1.txt の内容を上記に沿ってバイナリ化したものが sample1.dat 動作チェックに用いよ Computer Programming I (Adv.) 7th week 27

How to get a graph window of gnuplot The exercise program should be run on xterm as the same as the former example of gnuplot. Computer Programming I (Adv.) 7th week 28

gnuplot のグラフウィンドウが 出ないことへの対処 先ほどの gnuplot の例と同様 課題プログラムも xterm 上で実行しましょう Computer Programming I (Adv.) 7th week 29

Examination Date : June 16 (Thu) 2 nd time slot (10:30 12:00) Room:B1-201 We have the same examination for BASIC class and ADVANCED class simultaneously in one room. Written (paper) examination (not in Moodle) The examination topics is suited for BASIC class. The topics is limited from contents in ADVANCED class. Many basic topics will be questions of the exam. We don t have this class on June 3. From June 10, you will have the class of Computer Programming II a in this time slot. Computer Programming I (Adv.) 7th week 30

テスト 日時 :6 月 16 日 ( 木 ) 2 限目 10:30 12:00 場所 :B1-201 ベーシッククラスとアドバンスクラスのテストを 同じ部屋で同時に行います 筆記試験です (Moodle では実施しません ) 出題範囲はベーシックの方の内容に合わせます アドバンスでやった内容より狭く 基本的な内容が多くなります 6 月 3 日 ( 金 ) のこの講義はお休みです 6 月 10 日 ( 金 ) からはソフトウェア演習 Ⅱa です Computer Programming I (Adv.) 7th week 31