C++ For Science and Engineering Lecture 14

Size: px
Start display at page:

Download "C++ For Science and Engineering Lecture 14"

Transcription

1 C++ For Science and Engineering Lecture 14 John Chrispell Tulane University Monday September 27, 2010

2 File Input and Output Recall writing text to standard out You must include the iostream header file. The iostream header file declares an ostream variable, or object, called cout. You must account for the std namespace. (Use the using namespace directive, or the std:: prefix for elements such as cout and endl). You can use cout with the >> operator to read a variety of data types. John Chrispell, Monday September 27, 2010 slide 3/17

3 File Input and Output File output parallels this. You must include the fstream header file. The fstream header file defines an ofstream class for handling output. You need to declare one or more ofstream variables or objects, which you may name as you wish. You must account for the std namespace. This can be done using the namespace directive or using the std:: prefix for elements such as ofstream. You need to associate a specific ofstream object with a specific file. One way is to use the open() method. When your done you close the file using the close() method. You can use the >> operator with the ofstream object to output a variety of data types. John Chrispell, Monday September 27, 2010 slide 5/17

4 File Input and Output The syntax is as follows: o f s t r e a m o u t F i l e ; // o u t F i l e an o f s t r e a m o b j e c t o f s t r e a m f o u t ; // a second o f s t r e a m ; / a s s o c i a t e the stream with a f i l e / o u t F i l e. open ( M y f i l e. t x t ) ; // o u t F i l e can now be used l / a second way below / c i n >> f i l e n a m e ; f o u t. open ( f i l e n a m e ) ; / G i v e s a s p e c f i c out f i l e name / Consider the following example: John Chrispell, Monday September 27, 2010 slide 7/17

5 outfile.cpp #i n c lude <iostream > #i n c lude <fstream > // f o r f i l e I /O i n t main ( ) { using namespace std ; char automobile [ 5 0 ] ; i n t year ; double a p r i c e ; double d p r i c e ; ofstream o u t F i l e ; // create object for output o u t F i l e. open ( c a r i n f o. txt ) ; // a s s o c i a t e with a f i l e cout << Enter the make and model of automobile : ; c i n. g e t l i n e ( automobile, 5 0 ) ; cout << Enter the model year : ; c i n >> year ; cout << Enter the o r i g i n a l asking p r i c e : ; cin >> a p r i c e ; d p r i c e = a p r i c e ; / ======================================= / / d i s p l a y i n f o r m a t i o n on s c r e e n with cout / / ======================================= / cout << f i x e d ; cout. p r e c i s i o n ( 2 ) ; cout. s e t f ( i o s b a s e : : showpoint ) ; cout << Make and model : << automobile << endl ; cout << Year : << y e a r << e n d l ; cout << Was asking $ << a p r i c e << endl ; cout << Now asking $ << d p r i c e << endl ; / ====================================================== / / now do e x a c t same t h i n g s u s i n g o u t F i l e i n s t e a d o f cout / / ====================================================== / out F ile << f i x e d ; o u t F i l e. p r e c i s i o n (4); o u t F i l e. s e t f ( i o s b a s e : : showpoint ) ; o u t F i l e << Make and model : << automobile << endl ; o u t F i l e << Year : << y e a r << e n d l ; o u t F i l e << Was asking $ << a p r i c e << endl ; o u t F i l e << Now asking $ << d p r i c e << endl ; o u t F i l e. c l o s e ( ) ; // done with f i l e return 0 ; John Chrispell, Monday September 27, 2010 slide 9/17

6 Reading Text from a file To read text from a file you must: Include the fstream header file defining an ifstream class for handeling input. You declare an ifstream variable. Name it as you please. You must account for the std namespace. Associate an ifstream object with the file. We will use the open() method to do this and close() when we are done. Now you can use the << operator to read a variety of data types. You may also use the get() method to read individual characters and the getline() method for a line of characters at a time. You may use eof() and fail() to monitor the success of input attempts. Note the ifstream object when used as a test condition is a Boolean type. Ture when reads are successful. John Chrispell, Monday September 27, 2010 slide 11/17

7 sumafile.cpp #i n c lude <iostream > #i n c lude <fstream> // f i l e I /O suppport #i n c lude <c s t d l i b > // s u p p o r t f o r e x i t ( ) const i n t SIZE = 6 0 ; i n t main ( ) { using namespace std ; char f i l e n a m e [ SIZE ] ; ifstream infile ; // object for handling f i l e input cout << Enter name o f data f i l e : ; cin. getline ( filename, SIZE ) ; infile. open ( filename ) ; // associate infile with a f i l e / Test to see i f it opens / i f (! i n F i l e. i s o p e n ( ) ) { cout << Could not open the f i l e << filename << endl ; cout << Program t e r m i n a t i n g. \ n ; e x i t ( EXIT FAILURE ) ; double v a l u e ; // Place h o l d e r f o r f a l u e read. double sum = 0. 0 ; // Sum o f v a l u e s read i n t count = 0 ; // c o u n t e r f o r number o f i t e m s read / Read f i l e v a l u e s / i n F i l e >> v a l u e ; // get f i r s t v a l u e while ( infile. good ( ) ) { // while input good and not at EOF count++; // one more item read sum += value ; // c a l c u l a t e running t o t a l i n F i l e >> value ; // get next value John Chrispell, Monday September 27, 2010 slide 13/17

8 sumafile.cpp count / End t h i n g s i n some manner / i f ( i n F i l e. e o f ( ) ) { cout << End o f f i l e r e a c h e d. \ n ; e l s e i f ( i n F i l e. f a i l ( ) ) { cout << Input terminated by data mismatch. \ n ; e l s e { cout << Input terminated f o r unknown reason. \ n ; / Make a c o n c l u s i o n / i f ( count == 0){ cout << No data p r o c e s s e d. \ n ; e l s e { cout << Items read : << count << endl ; cout << Sum : << sum << endl ; cout << Average : << sum / count << e n d l ; i n F i l e. c l o s e ( ) ; // f i n i s h e d with the f i l e return 0 ; John Chrispell, Monday September 27, 2010 slide 15/17

9 Plain Pixel Map Files One particular image format is the plain pixel map or.ppm file. P John Chrispell, Monday September 27, 2010 slide 17/17

C++ For Science and Engineering Lecture 10

C++ For Science and Engineering Lecture 10 C++ For Science and Engineering Lecture 10 John Chrispell Tulane University Wednesday 15, 2010 Introducing for loops Often we want programs to do the same action more than once. #i n c l u d e

More information

C++ For Science and Engineering Lecture 17

C++ For Science and Engineering Lecture 17 C++ For Science and Engineering Lecture 17 John Chrispell Tulane University Monday October 4, 2010 Functions and C-Style Strings Three methods for representing the C-style string: An array of char A quoted

More information

C++ For Science and Engineering Lecture 13

C++ For Science and Engineering Lecture 13 C++ For Science and Engineering Lecture 13 John Chrispell Tulane University Wednesday September 22, 2010 Logical Expressions: Sometimes you want to use logical and and logical or (even logical not) in

More information

C++ For Science and Engineering Lecture 8

C++ For Science and Engineering Lecture 8 C++ For Science and Engineering Lecture 8 John Chrispell Tulane University Friday 10, 2010 Arrays Structures are ways of storing more than one type of information together. A structure is a vesatile data

More information

2. Write a recursive function to add the first n terms of the alternating harmonic series:

2. Write a recursive function to add the first n terms of the alternating harmonic series: CS 7B - Spring 2014 - Midterm 2. 5/8/14 Write responses on separate paper. 1. Write a recursive method that uses only addition, subtraction, and comparison to multiply two numbers. The basic engine for

More information

Numerical solution of the time-independent 1-D Schrödinger equation. Matthias E. Möbius. September 24, 2010

Numerical solution of the time-independent 1-D Schrödinger equation. Matthias E. Möbius. September 24, 2010 Numerical solution of the time-independent 1-D Schrödinger equation Matthias E. Möbius September 24, 2010 1 Aim of the computational lab Numerical solution of the one-dimensional stationary Schrödinger

More information

CS 7B - Fall Final Exam (take-home portion). Due Wednesday, 12/13 at 2 pm

CS 7B - Fall Final Exam (take-home portion). Due Wednesday, 12/13 at 2 pm CS 7B - Fall 2017 - Final Exam (take-home portion). Due Wednesday, 12/13 at 2 pm Write your responses to following questions on separate paper. Use complete sentences where appropriate and write out code

More information

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess!

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess! The Big Picture Announcements Problem Set 9 due right now. We'll release solutions right after lecture. Congratulations you're done with CS103 problem sets! Practice final exam is Monday, December 8 from

More information

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ;

import java. u t i l. ;... Scanner sc = new Scanner ( System. in ) ; CPSC 490 Input Input will always arrive on stdin. You may assume input is well-formed with respect to the problem specification; inappropriate input (e.g. text where a number was specified, number out

More information

In this approach, the ground state of the system is found by modeling a diffusion process.

In this approach, the ground state of the system is found by modeling a diffusion process. The Diffusion Monte Carlo (DMC) Method In this approach, the ground state of the system is found by modeling a diffusion process. Diffusion and random walks Consider a random walk on a lattice with spacing

More information

ENS Lyon Camp. Day 5. Basic group. C October

ENS Lyon Camp. Day 5. Basic group. C October ENS Lyon Camp. Day 5. Basic group. C++. 30 October Contents 1 Input/Output 1 1.1 C-style.......................................... 1 1. C++-style........................................ Stack Overflow

More information

CS 7B - Fall Assignment 4: Exploring Wumpus (Linked Rooms). Due 12/13/18

CS 7B - Fall Assignment 4: Exploring Wumpus (Linked Rooms). Due 12/13/18 CS 7B - Fall 2018 - Assignment 4: Exploring Wumpus (Linked Rooms). Due 12/13/18 In this project we ll build, investigate and augment the the game Hunt the Wumpus, as described in exercise 12 or PPP2, Chapter

More information

Molecular Dynamics Simulation of Argon

Molecular Dynamics Simulation of Argon Molecular Dynamics Simulation of Argon The fundamental work on this problem was done by A. Rahman, Phys. Rev. 136, A405 (1964). It was extended in many important ways by L. Verlet, Phys. Rev. 159, 98 (1967),

More information

Numerical differentiation

Numerical differentiation Chapter 3 Numerical differentiation 3.1 Introduction Numerical integration and differentiation are some of the most frequently needed methods in computational physics. Quite often we are confronted with

More information

The Monte Carlo Algorithm

The Monte Carlo Algorithm The Monte Carlo Algorithm This algorithm was invented by N. Metropolis, A.W. Rosenbluth, M.N. Rosenbluth, A.H. Teller, and E. Teller, J. Chem. Phys., 21, 1087 (1953). It was listed as one of the The Top

More information

Root Tutorial: Plotting the Z mass

Root Tutorial: Plotting the Z mass Root Tutorial: Plotting the Z mass African School of Fundamental Physics and Applications, Kigali, Rwanda Nikolina Ilic Stanford University with material from Heather Gray 1 Introduction Z and W are weak

More information

Yod field statistics for tachyon interactions

Yod field statistics for tachyon interactions Yod field statistics for tachyon interactions Joe Helmick Ohio State University, College of Arts and Sciences, 5253 E. Broad St. 109, Columbus, Ohio 43213 Email: joehelmick@hotmail.com Abstract A dynamic

More information

An (incomplete) Introduction to FreeFem++

An (incomplete) Introduction to FreeFem++ An (incomplete) Introduction to FreeFem++ Nathaniel Mays Wheeling Jesuit University November 12, 2011 Nathaniel Mays (Wheeling Jesuit University)An (incomplete) Introduction to FreeFem++ November 12, 2011

More information

CS 7B - Spring Assignment: Ramsey Theory with Matrices and SFML. due 5/23/18

CS 7B - Spring Assignment: Ramsey Theory with Matrices and SFML. due 5/23/18 CS 7B - Spring 2018 - Assignment: Ramsey Theory with Matrices and SFML. due 5/23/18 Background Theory Ramsey theory, named after the British mathematician and philosopher Frank P. Ramsey, is a branch of

More information

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess!

Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess! The Big Picture Announcements Problem Set 9 due right now. We'll release solutions right after lecture. Congratulations you're done with CS103 problem sets! Please evaluate this course on Axess! Your feedback

More information

Programsystemkonstruktion med C++: Övning 1. Karl Palmskog Translated by: Siavash Soleimanifard. September 2011

Programsystemkonstruktion med C++: Övning 1. Karl Palmskog Translated by: Siavash Soleimanifard. September 2011 Programsystemkonstruktion med C++: Övning 1 Karl Palmskog palmskog@kth.se Translated by: Siavash Soleimanifard September 2011 Programuppbyggnad Klassens uppbyggnad A C++ class consists of a declaration

More information

Computational Physics (6810): Session 2

Computational Physics (6810): Session 2 Computational Physics (6810): Session 2 Dick Furnstahl Nuclear Theory Group OSU Physics Department January 13, 2017 Session 1 follow-ups Types of error Reminder of power laws Session 1 follow-ups Session

More information

Cluster Algorithms to Reduce Critical Slowing Down

Cluster Algorithms to Reduce Critical Slowing Down Cluster Algorithms to Reduce Critical Slowing Down Monte Carlo simulations close to a phase transition are affected by critical slowing down. In the 2-D Ising system, the correlation length ξ becomes very

More information

Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA === Homework submission instructions ===

Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA   === Homework submission instructions === Data Structure and Algorithm Homework #1 Due: 2:20pm, Tuesday, March 12, 2013 TA email: dsa1@csie.ntu.edu.tw === Homework submission instructions === For Problem 1, submit your source code, a Makefile

More information

Laboratory Exercise #10 An Introduction to High-Speed Addition

Laboratory Exercise #10 An Introduction to High-Speed Addition Laboratory Exercise #10 An Introduction to High-Speed Addition ECEN 248: Introduction to Digital Design Department of Electrical and Computer Engineering Texas A&M University 2 Laboratory Exercise #10

More information

Computational Simulations of Magnets at High Temperatures Utilizing the Ising Model and the Monte Carlo Technique

Computational Simulations of Magnets at High Temperatures Utilizing the Ising Model and the Monte Carlo Technique Computational Simulations of Magnets at High Temperatures Utilizing the Ising Model and the Monte Carlo Technique Project SEED Dr. Ken Ahn Mayrolin Garcia Introduction How does the property of magnetism

More information

2 2 mω2 x 2 ψ(x) = Eψ(x),

2 2 mω2 x 2 ψ(x) = Eψ(x), Topic 5 Quantum Monte Carlo Lecture 1 Variational Quantum Monte Carlo for the Harmonic Oscillator In this topic, we will study simple quantum mechanical systems of particles which have bound states. The

More information

Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach

Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach Introduction to 3D Game Programming with DirectX 90c: A Shader Approach Part I Solutions Note : Please email to frank@moon-labscom if ou find an errors Note : Use onl after ou have tried, and struggled

More information

Slides from FYS3150/FYS4150 Lectures

Slides from FYS3150/FYS4150 Lectures Slides from FYS3150/FYS4150 Lectures Morten Hjorth-Jensen Department of Physics and Center of Mathematics for Applications University of Oslo, N-0316 Oslo, Norway Fall 2006 Week 34, 21-25 August Monday:

More information

Example problem: Adaptive solution of the 2D advection diffusion equation

Example problem: Adaptive solution of the 2D advection diffusion equation Chapter 1 Example problem: Adaptive solution of the 2D advection diffusion equation In this example we discuss the adaptive solution of the 2D advection-diffusion problem Solve Two-dimensional advection-diffusion

More information

Machine Learning 9/2/2015. What is machine learning. Advertise a customer s favorite products. Search the web to find pictures of dogs

Machine Learning 9/2/2015. What is machine learning. Advertise a customer s favorite products. Search the web to find pictures of dogs 9//5 What is machine learning Machine Learning CISC 58 Dr Daniel Leeds Finding patterns in data Adapting program behavior Advertise a customer s favorite products Search the web to find pictures of dogs

More information

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions

Introduction to Language Theory and Compilation: Exercises. Session 2: Regular expressions Introduction to Language Theory and Compilation: Exercises Session 2: Regular expressions Regular expressions (RE) Finite automata are an equivalent formalism to regular languages (for each regular language,

More information

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from

Lecture 44. Better and successive approximations x2, x3,, xn to the root are obtained from Lecture 44 Solution of Non-Linear Equations Regula-Falsi Method Method of iteration Newton - Raphson Method Muller s Method Graeffe s Root Squaring Method Newton -Raphson Method An approximation to the

More information

APPENDIX A FASTFLOW A.1 DESIGN PRINCIPLES

APPENDIX A FASTFLOW A.1 DESIGN PRINCIPLES APPENDIX A FASTFLOW A.1 DESIGN PRINCIPLES FastFlow 1 has been designed to provide programmers with efficient parallelism exploitation patterns suitable to implement (fine grain) stream parallel applications.

More information

Applied C Fri

Applied C Fri Applied C++11 2013-01-25 Fri Outline Introduction Auto-Type Inference Lambda Functions Threading Compiling C++11 C++11 (formerly known as C++0x) is the most recent version of the standard of the C++ Approved

More information

Switch-Case & Break. Example 24. case 1 : p r i n t f ( January \n ) ; break ; case 2 : p r i n t f ( F e b r u a r y \n ) ; break ;

Switch-Case & Break. Example 24. case 1 : p r i n t f ( January \n ) ; break ; case 2 : p r i n t f ( F e b r u a r y \n ) ; break ; Example 24 s w i t c h ( month ) { case 1 : p r i n t f ( January \n ) ; case 2 : p r i n t f ( F e b r u a r y \n ) ; case 3 : p r i n t f ( March\n ) ; case 4 : p r i n t f ( A p r i l \n ) ; case 5

More information

Discrete Random Variables (cont.) Discrete Distributions the Geometric pmf

Discrete Random Variables (cont.) Discrete Distributions the Geometric pmf Discrete Random Variables (cont.) ECE 313 Probability with Engineering Applications Lecture 10 - September 29, 1999 Professor Ravi K. Iyer University of Illinois the Geometric pmf Consider a sequence of

More information

Simulating Gravity. AiS Challenge Final Report April 7 th, Team 28 Farmington High School

Simulating Gravity. AiS Challenge Final Report April 7 th, Team 28 Farmington High School Simulating Gravity AiS Challenge Final Report April 7 th, 2004 Team 28 Farmington High School Team Members Leonard Biemer Michael Blount Brian Geistwhite Kasra Manavi Amelia Symmonds Teachers Mr. Mike

More information

The Euler Method for the Initial Value Problem

The Euler Method for the Initial Value Problem The Euler Method for the Initial Value Problem http://people.sc.fsu.edu/ jburkardt/isc/week10 lecture 18.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt

More information

MA204/MA284 : Discrete Mathematics Week 2: Counting with sets; The Principle of Inclusion and Exclusion (PIE) 19 & 21 September 2018

MA204/MA284 : Discrete Mathematics Week 2: Counting with sets; The Principle of Inclusion and Exclusion (PIE) 19 & 21 September 2018 Annotated slides from Wednesday (1/29) MA204/MA284 : Discrete Mathematics Week 2: Counting with sets; The Principle of Inclusion and Exclusion (PIE) Dr Niall Madden 19 & 21 September 2018 A B A B C Tutorials

More information

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course.

INTRODUCTION. This is not a full c-programming course. It is not even a full 'Java to c' programming course. C PROGRAMMING 1 INTRODUCTION This is not a full c-programming course. It is not even a full 'Java to c' programming course. 2 LITTERATURE 3. 1 FOR C-PROGRAMMING The C Programming Language (Kernighan and

More information

Introduction to ANTLR (ANother Tool for Language Recognition)

Introduction to ANTLR (ANother Tool for Language Recognition) Introduction to ANTLR (ANother Tool for Language Recognition) Jon Eyolfson University of Waterloo September 27 - October 1, 2010 Outline Introduction Usage Example Demonstration Conclusion Jon Eyolfson

More information

THEORY OF COMPILATION

THEORY OF COMPILATION Lecture 04 Syntax analysis: top-down and bottom-up parsing THEORY OF COMPILATION EranYahav 1 You are here Compiler txt Source Lexical Analysis Syntax Analysis Parsing Semantic Analysis Inter. Rep. (IR)

More information

Tensor calculus with Lorene

Tensor calculus with Lorene Tensor calculus with Lorene Eric Gourgoulhon Laboratoire de l Univers et de ses Théories (LUTH) CNRS / Observatoire de Paris F-92195 Meudon, France eric.gourgoulhon@obspm.fr based on a collaboration with

More information

Lecture 4: September 19

Lecture 4: September 19 CSCI1810: Computational Molecular Biology Fall 2017 Lecture 4: September 19 Lecturer: Sorin Istrail Scribe: Cyrus Cousins Note: LaTeX template courtesy of UC Berkeley EECS dept. Disclaimer: These notes

More information

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 16 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 16 Programming in the λ-calculus 30 September 2016 Review: Church Booleans 2 We can encode TRUE, FALSE, and IF, as: TRUE λx. λy. x FALSE λx. λy. y IF λb.

More information

Tools for Feature Extraction: Exploring essentia

Tools for Feature Extraction: Exploring essentia Tools for Feature Extraction: Exploring essentia MUS-15 Andrea Hanke July 5, 2017 Introduction In the research on Music Information Retrieval, it is attempted to automatically classify a piece of music

More information

DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR

DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR DAILY QUESTIONS 28 TH JUNE 18 REASONING - CALENDAR LEAP AND NON-LEAP YEAR *A non-leap year has 365 days whereas a leap year has 366 days. (as February has 29 days). *Every year which is divisible by 4

More information

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3

Notater: INF3331. Veronika Heimsbakk December 4, Introduction 3 Notater: INF3331 Veronika Heimsbakk veronahe@student.matnat.uio.no December 4, 2013 Contents 1 Introduction 3 2 Bash 3 2.1 Variables.............................. 3 2.2 Loops...............................

More information

Project 4/5 - Molecular dynamics part II: advanced study of Lennard-Jones fluids, deadline December 1st (noon)

Project 4/5 - Molecular dynamics part II: advanced study of Lennard-Jones fluids, deadline December 1st (noon) Format for delivery of report and programs The format of the project is that of a printed file or hand-written report. The programs should also be included with the report. Write only your candidate number

More information

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n

Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion: power(m,n) = m n German University in Cairo Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Mohammed Abdel Megeed Introduction to Computer Programming, Spring Term 2018 Practice Assignment 5 Discussion:

More information

Gascoigne 3D High Performance Adaptive Finite Element Toolkit

Gascoigne 3D High Performance Adaptive Finite Element Toolkit Introduction to Gascoigne 3D High Performance Adaptive Finite Element Toolkit Tutorial and manuscript by Thomas Richter thomas.richter@iwr.uni-heidelberg.de April 25, 2014 2 Contents 1 Introduction 5 1.1

More information

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University

ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University ECEN 449: Microprocessor System Design Department of Electrical and Computer Engineering Texas A&M University Prof. Sunil P Khatri (Lab exercise created and tested by Ramu Endluri, He Zhou and Sunil P

More information

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad

Supplemental Materials. In the main text, we recommend graphing physiological values for individual dyad 1 Supplemental Materials Graphing Values for Individual Dyad Members over Time In the main text, we recommend graphing physiological values for individual dyad members over time to aid in the decision

More information

Multimedia. Multimedia Data Compression (Lossless Compression Algorithms)

Multimedia. Multimedia Data Compression (Lossless Compression Algorithms) Course Code 005636 (Fall 2017) Multimedia Multimedia Data Compression (Lossless Compression Algorithms) Prof. S. M. Riazul Islam, Dept. of Computer Engineering, Sejong University, Korea E-mail: riaz@sejong.ac.kr

More information

Lecture 5: The Shift-And Method

Lecture 5: The Shift-And Method Biosequence Algorithms, Spring 2005 Lecture 5: The Shift-And Method Pekka Kilpeläinen University of Kuopio Department of Computer Science BSA Lecture 5: Shift-And p.1/19 Seminumerical String Matching Most

More information

DISCRETE RANDOM VARIABLES EXCEL LAB #3

DISCRETE RANDOM VARIABLES EXCEL LAB #3 DISCRETE RANDOM VARIABLES EXCEL LAB #3 ECON/BUSN 180: Quantitative Methods for Economics and Business Department of Economics and Business Lake Forest College Lake Forest, IL 60045 Copyright, 2011 Overview

More information

Lecture 3: Finite Automata

Lecture 3: Finite Automata Administrivia Lecture 3: Finite Automata Everyone should now be registered electronically using the link on our webpage. If you haven t, do so today! I d like to have teams formed by next Monday at the

More information

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015

NP Completeness. CS 374: Algorithms & Models of Computation, Spring Lecture 23. November 19, 2015 CS 374: Algorithms & Models of Computation, Spring 2015 NP Completeness Lecture 23 November 19, 2015 Chandra & Lenny (UIUC) CS374 1 Spring 2015 1 / 37 Part I NP-Completeness Chandra & Lenny (UIUC) CS374

More information

Mechanized Operational Semantics

Mechanized Operational Semantics Mechanized Operational Semantics J Strother Moore Department of Computer Sciences University of Texas at Austin Marktoberdorf Summer School 2008 (Lecture 5: Boyer-Moore Fast String Searching) 1 The Problem

More information

Bfh Ti Control F Ws 2008/2009 Lab Matlab-1

Bfh Ti Control F Ws 2008/2009 Lab Matlab-1 Bfh Ti Control F Ws 2008/2009 Lab Matlab-1 Theme: The very first steps with Matlab. Goals: After this laboratory you should be able to solve simple numerical engineering problems with Matlab. Furthermore,

More information

T Reactive Systems: Temporal Logic LTL

T Reactive Systems: Temporal Logic LTL Tik-79.186 Reactive Systems 1 T-79.186 Reactive Systems: Temporal Logic LTL Spring 2005, Lecture 4 January 31, 2005 Tik-79.186 Reactive Systems 2 Temporal Logics Temporal logics are currently the most

More information

A NEW ALGORITHM FOR FINDING HAMILTONIAN CIRCUITS

A NEW ALGORITHM FOR FINDING HAMILTONIAN CIRCUITS BY ASHAY DHARWADKER INSTITUTE OF MATHEMATICS H-501 PALAM VIHAR DISTRICT GURGAON HARYANA 1 2 2 0 1 7 INDIA ashay@dharwadker.org ABSTRACT We present a new polynomial-time algorithm for finding Hamiltonian

More information

AGEC 621 Lecture 16 David Bessler

AGEC 621 Lecture 16 David Bessler AGEC 621 Lecture 16 David Bessler This is a RATS output for the dummy variable problem given in GHJ page 422; the beer expenditure lecture (last time). I do not expect you to know RATS but this will give

More information

Measuring lateness. Definition of Measurement (Fenton)

Measuring lateness. Definition of Measurement (Fenton) When you can measure what you are speaking about, and express it in numbers, you know something about it; but when you cannot measure it, when you cannot express it in numbers, your knowledge is of a meagre

More information

CS 7B - Spring Assignment: Adapting the calculator for bitwise expressions. due 2/21/18

CS 7B - Spring Assignment: Adapting the calculator for bitwise expressions. due 2/21/18 CS 7B - Spring 2018 - Assignment: Adapting the calculator for bitwise expressions. due 2/21/18 Background Theory A bitwise number is a number in base 2. In base 2, place values are either a 1 or 0, depending

More information

CS 151 Complexity Theory Spring Solution Set 5

CS 151 Complexity Theory Spring Solution Set 5 CS 151 Complexity Theory Spring 2017 Solution Set 5 Posted: May 17 Chris Umans 1. We are given a Boolean circuit C on n variables x 1, x 2,..., x n with m, and gates. Our 3-CNF formula will have m auxiliary

More information

CHAPTER 2. The Derivative

CHAPTER 2. The Derivative CHAPTER The Derivative Section.1 Tangent Lines and Rates of Change Suggested Time Allocation: 1 to 1 1 lectures Slides Available on the Instructor Companion Site for this Text: Figures.1.1,.1.,.1.7,.1.11

More information

CS 311 Sample Final Examination

CS 311 Sample Final Examination Name: CS 311 Sample Final Examination Time: One hour and fifty minutes This is the (corrected) exam from Fall 2009. The real exam will not use the same questions! 8 December 2009 Instructions Attempt all

More information

15 Monte Carlo methods

15 Monte Carlo methods 15 Monte Carlo methods 15.1 The Monte Carlo method The Monte Carlo method is simple, robust, and useful. It was invented by Enrico Fermi and developed by Metropolis (Metropolis et al., 1953). It has many

More information

SAMPLE ANSWERS MARKER COPY

SAMPLE ANSWERS MARKER COPY Page 1 of 12 School of Computer Science 60-265-01 Computer Architecture and Digital Design Fall 2012 Midterm Examination # 1 Tuesday, October 23, 2012 SAMPLE ANSWERS MARKER COPY Duration of examination:

More information

More Example Using Loops

More Example Using Loops Loops and Repetitive Computations For More Example Using Loops Example 35 (contd) printing of first row print the first day i= i+1 no i < 7? yes printf("%6d", i) exit no i < =n? i = i+7 printf("\n") printing

More information

CS 591, Lecture 9 Data Analytics: Theory and Applications Boston University

CS 591, Lecture 9 Data Analytics: Theory and Applications Boston University CS 591, Lecture 9 Data Analytics: Theory and Applications Boston University Babis Tsourakakis February 22nd, 2017 Announcement We will cover the Monday s 2/20 lecture (President s day) by appending half

More information

Comp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33

Comp 11 Lectures. Mike Shah. July 12, Tufts University. Mike Shah (Tufts University) Comp 11 Lectures July 12, / 33 Comp 11 Lectures Mike Shah Tufts University July 12, 2017 Mike Shah (Tufts University) Comp 11 Lectures July 12, 2017 1 / 33 Please do not distribute or host these slides without prior permission. Mike

More information

ACM-ICPC South Western European Regional SWERC 2008

ACM-ICPC South Western European Regional SWERC 2008 ACM-ICPC South Western European Regional SWERC 2008 FAU Contest Team icpc@i2.informatik.uni-erlangen.de Friedrich-Alexander Universität Erlangen-Nürnberg November, 23 2008 FAU Contest Team ACM-ICPC South

More information

Mimir NIR Spectroscopy Data Processing Cookbook V2.0 DPC

Mimir NIR Spectroscopy Data Processing Cookbook V2.0 DPC Mimir NIR Spectroscopy Data Processing Cookbook V2.0 DPC - 20111130 1. Fetch and install the software packages needed a. Get the MSP_WCT, MSP_CCS, MSP_SXC packages from the Mimir/Software web site: http://people.bu.edu/clemens/mimir/software.html

More information

Accumulators. A Trivial Example in Oz. A Trivial Example in Prolog. MergeSort Example. Accumulators. Declarative Programming Techniques

Accumulators. A Trivial Example in Oz. A Trivial Example in Prolog. MergeSort Example. Accumulators. Declarative Programming Techniques Declarative Programming Techniques Accumulators, Difference Lists (VRH 3.4.3-3.4.4) Carlos Varela RPI Adapted with permission from: Seif Haridi KTH Peter Van Roy UCL September 13, 2007 Accumulators Accumulator

More information

How to write proofs - II

How to write proofs - II How to write proofs - II Problem (Ullman and Hopcroft, Page 104, Exercise 4.8). Let G be the grammar Prove that S ab ba A a as baa B b bs abb L(G) = { x {a, b} x contains equal number of a s and b s }.

More information

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV

G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV G54FOP: Lecture 17 & 18 Denotational Semantics and Domain Theory III & IV Henrik Nilsson University of Nottingham, UK G54FOP: Lecture 17 & 18 p.1/33 These Two Lectures Revisit attempt to define denotational

More information

ENEE 459E/CMSC 498R In-class exercise February 10, 2015

ENEE 459E/CMSC 498R In-class exercise February 10, 2015 ENEE 459E/CMSC 498R In-class exercise February 10, 2015 In this in-class exercise, we will explore what it means for a problem to be intractable (i.e. it cannot be solved by an efficient algorithm). There

More information

8: Statistical Distributions

8: Statistical Distributions : Statistical Distributions The Uniform Distribution 1 The Normal Distribution The Student Distribution Sample Calculations The Central Limit Theory Calculations with Samples Histograms & the Normal Distribution

More information

CS415 Compilers Syntax Analysis Top-down Parsing

CS415 Compilers Syntax Analysis Top-down Parsing CS415 Compilers Syntax Analysis Top-down Parsing These slides are based on slides copyrighted by Keith Cooper, Ken Kennedy & Linda Torczon at Rice University Announcements Midterm on Thursday, March 13

More information

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University

Intelligent Agents. Formal Characteristics of Planning. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University Intelligent Agents Formal Characteristics of Planning Ute Schmid Cognitive Systems, Applied Computer Science, Bamberg University Extensions to the slides for chapter 3 of Dana Nau with contributions by

More information

The file may not actually come from a bank, but could be given by the customer (typically very large customers). File Layout

The file may not actually come from a bank, but could be given by the customer (typically very large customers). File Layout Lockbox Specs Contents 1 What is Lockbox? 2 File Layout 3 Spooler Cash Receipts screen 3.1 The Data Layout fields 3.2 The TEST hotkey 4 Example Lockbox File 5 Another example Lockbox file What is Lockbox?

More information

Propositional Logic: Semantics and an Example

Propositional Logic: Semantics and an Example Propositional Logic: Semantics and an Example CPSC 322 Logic 2 Textbook 5.2 Propositional Logic: Semantics and an Example CPSC 322 Logic 2, Slide 1 Lecture Overview 1 Recap: Syntax 2 Propositional Definite

More information

Mass Transfer Operations I Prof. Bishnupada Mandal Department of Chemical Engineering Indian Institute of Technology, Guwahati

Mass Transfer Operations I Prof. Bishnupada Mandal Department of Chemical Engineering Indian Institute of Technology, Guwahati Mass Transfer Operations I Prof. Bishnupada Mandal Department of Chemical Engineering Indian Institute of Technology, Guwahati Module - 4 Absorption Lecture - 3 Packed Tower Design Part 2 (Refer Slide

More information

Mobile Video Identification

Mobile Video Identification Mobile Video Identification Alex Burman Department of Electrical and Computer Engineering Rutgers, The State University of New Jersey New Brunswick, NJ 08901 Seiler Hill Department of Electrical and Computer

More information

Session 5 (last revised: January 24, 2010) 5 1

Session 5 (last revised: January 24, 2010) 5 1 782 Session 5 (last revised: January 24, 21) 5 1 5 782 Session 5 a Follow-up to Numerical Derivative Round-Off Errors In Session 4, we looked at error plots for various ways to calculate numerical derivatives

More information

Electric Fields and Equipotentials

Electric Fields and Equipotentials OBJECTIVE Electric Fields and Equipotentials To study and describe the two-dimensional electric field. To map the location of the equipotential surfaces around charged electrodes. To study the relationship

More information

Instructions for use of molly to prepare files for Doppler or Modmap

Instructions for use of molly to prepare files for Doppler or Modmap Instructions for use of molly to prepare files for Doppler or Modmap In the following instructions, computer output is in small type, prompts end with : or >, comments are in boldface and that which the

More information

Introduction to Turing Machines. Reading: Chapters 8 & 9

Introduction to Turing Machines. Reading: Chapters 8 & 9 Introduction to Turing Machines Reading: Chapters 8 & 9 1 Turing Machines (TM) Generalize the class of CFLs: Recursively Enumerable Languages Recursive Languages Context-Free Languages Regular Languages

More information

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in Oracle Turing Machines Nondeterministic OTM defined in the same way (transition relation, rather than function) oracle is like a subroutine, or function in your favorite PL but each call counts as single

More information

COSE312: Compilers. Lecture 2 Lexical Analysis (1)

COSE312: Compilers. Lecture 2 Lexical Analysis (1) COSE312: Compilers Lecture 2 Lexical Analysis (1) Hakjoo Oh 2017 Spring Hakjoo Oh COSE312 2017 Spring, Lecture 2 March 12, 2017 1 / 15 Lexical Analysis ex) Given a C program float match0 (char *s) /* find

More information

Compiling Techniques

Compiling Techniques Lecture 5: Top-Down Parsing 26 September 2017 The Parser Context-Free Grammar (CFG) Lexer Source code Scanner char Tokeniser token Parser AST Semantic Analyser AST IR Generator IR Errors Checks the stream

More information

Intro (Stefan

Intro (Stefan Advanced Programming in Engineering Intro (Stefan s.luding@utwente.nl) Wouter den Otter, Vanessa Magnanimo, Thomas Weinhart, Anthony Thornton, Stefan Luding MSM, CTW, MESA+, UTwente, NL Contents Why is

More information

Computability, Undeciability and the Halting Problem

Computability, Undeciability and the Halting Problem Computability, Undeciability and the Halting Problem 12/01/16 http://www.michael-hogg.co.uk/game_of_life.php Discrete Structures (CS 173) Lecture B Gul Agha 1 Based on slides by Derek Hoiem, University

More information

Introduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee

Introduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee Introduction to Cryptology Dr. Sugata Gangopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Roorkee Lecture 05 Problem discussion on Affine cipher and perfect secrecy

More information

15-451/651: Design & Analysis of Algorithms September 13, 2018 Lecture #6: Streaming Algorithms last changed: August 30, 2018

15-451/651: Design & Analysis of Algorithms September 13, 2018 Lecture #6: Streaming Algorithms last changed: August 30, 2018 15-451/651: Design & Analysis of Algorithms September 13, 2018 Lecture #6: Streaming Algorithms last changed: August 30, 2018 Today we ll talk about a topic that is both very old (as far as computer science

More information

4.4 The Calendar program

4.4 The Calendar program 4.4. THE CALENDAR PROGRAM 109 4.4 The Calendar program To illustrate the power of functions, in this section we will develop a useful program that allows the user to input a date or a month or a year.

More information

Turing Machines Part III

Turing Machines Part III Turing Machines Part III Announcements Problem Set 6 due now. Problem Set 7 out, due Monday, March 4. Play around with Turing machines, their powers, and their limits. Some problems require Wednesday's

More information