Chapter 15 C-implementation PA = LU Speaker: Lung-Sheng Chien.

Slides:



Advertisements
Similar presentations
Chapter 12: File System Implementation
Advertisements

SYMBOL TABLES &CODE GENERATION FOR EXECUTABLES. SYMBOL TABLES Compilers that produce an executable (or the representation of an executable in object module.
Chapter 6 Queues and Deques.
Block LU Factorization Lecture 24 MA471 Fall 2003.
Programming and Data Structure
Chapter 11 Gaussian Elimination (I)
Data Structures: A Pseudocode Approach with C
Chapter 13 Gaussian Elimination (III) Bunch-Parlett diagonal pivoting
MATH 685/ CSI 700/ OR 682 Lecture Notes
Speaker: Lung-Sheng Chien
Chapter 11: File System Implementation
Engineering Problem Solving With C++ An Object Based Approach Fundamental Concepts Chapter 1 Engineering Problem Solving.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
Chapter 16 high precision package Speaker: Lung-Sheng Chien Reference: high precision package in and
Main Index Contents 11 Main Index Contents Pointer Illustration Pointer Illustration Vertical / Horizontal View. Vertical / Horizontal View. Data Addresses.
Review Chapter 10 Speaker: Lung-Sheng Chien parse configuration file of Linear programming.
Object (Data and Algorithm) Analysis Cmput Lecture 5 Department of Computing Science University of Alberta ©Duane Szafron 1999 Some code in this.
Lecture 7 Sept 19, 11 Goals: two-dimensional arrays (continued) matrix operations circuit analysis using Matlab image processing – simple examples Chapter.
Chapter 20 rounding error Speaker: Lung-Sheng Chien.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
Lecture 6 Sept 15, 09 Goals: two-dimensional arrays matrix operations circuit analysis using Matlab image processing – simple examples.
Structured Data Types and Encapsulation Mechanisms to create new data types: –Structured data Homogeneous: arrays, lists, sets, Non-homogeneous: records.
Introduction of Arrays. Arrays Array form an important part of almost all programming language. It provides a powerful feature and can be used as such.
Chapter 17 C-implementation PAP’ = LDL’ Speaker: Lung-Sheng Chien Reference: [1] H. M. Deitel, P. J. Deitel, C++ How to Program 5-th edition.
Chapter 12 Gaussian Elimination (II) Speaker: Lung-Sheng Chien Reference book: David Kincaid, Numerical Analysis Reference lecture note: Wen-wei Lin, chapter.
Here’s how to start the Microsoft Visual C++ program; click on start, then programsclick on start, then programs Choose Microsoft Visual C++ or Microsoft.
Scientific Computing Linear Systems – LU Factorization.
Data Structures Using C++ 2E Chapter 7 Stacks. Data Structures Using C++ 2E2 Objectives Learn about stacks Examine various stack operations Learn how.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Custom Templatized Data Structures.
Scott Marino MSMIS Kean University MSAS5104 Programming with Data Structures and Algorithms Week 10 Scott Marino.
Introduction to Numerical Analysis I MATH/CMPSC 455 PA=LU.
MA/CS 375 Fall MA/CS 375 Fall 2003 Lecture 19.
Lecture 6: Computer Languages. Programming Environments (IDE) COS120 Software Development Using C++ AUBG, COS dept.
ZONG Wen Department of Computer Science and Engineering The Chinese University of Hong Kong
Efficiency and Flexibility of Jagged Arrays Geir Gundersen Department of Informatics University of Bergen Norway Joint work with Trond Steihaug.
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 21.
N from what language did C++ originate? n what’s input, output device? n what’s main memory, memory location, memory address? n what’s a program, data?
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 11: File System Implementation.
Chapter 4. INTERNAL REPRESENTATION OF FILES
1 Getting Started with C++. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Visual Studio 2008.
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved Stacks.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 18: Stacks and Queues (part 2)
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
Swap Space and Other Memory Management Issues Operating Systems: Internals and Design Principles.
Assembly - Arrays תרגול 7 מערכים.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
The Development Process Compilation. Compilation - Dr. Craig A. Struble 2 Programming Process Problem Solving Phase We will spend significant time on.
ENEE150 – 0102 ANDREW GOFFIN More With Pointers. Importance of Pointers Dynamic Memory (relevant with malloc) Passing By Reference Pointer Arithmetic.
1. So far, one thread is responsible for one data element, can you change this, say one thread takes care of several data entries ? test N = 512*10 We.
Data Structure and Algorithms
1 Data Structures and Algorithms Outline This topic will describe: –The concrete data structures that can be used to store information –The basic forms.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
1 ENERGY 211 / CME 211 Lecture 4 September 29, 2008.
LDL’ = PAP’ Speaker : 高崇閔. Program structure[1] Use high precision Main function 1_1 pivot do 1_1 pivot in case_1 to case_3 main.cpp test_matrix.cpp test.
Unit #1 Linear Systems Fall Dr. Jehad Al Dallal.
Fall 2011 Nassau Community College ITE153 – Operating Systems 1 Session 5 Files.
Operating Systems A Biswas, Dept. of Information Technology.
Numerical Computation Lecture 6: Linear Systems – part II United International College.
File-System Management
Data Structures Using C++ 2E
MODERN OPERATING SYSTEMS Third Edition ANDREW S
Computer Terms Review from what language did C++ originate?
MA/CS 375 Spring 2002 Lecture 19 MA/CS 375 Fall 2002.
Operation System Program 4
Chapter 1: An Overview of Computers and Programming Languages
1. Open Visual Studio 2008.
Chapter 16 Tree Implementations
Functions continued.
Computer Terms Review from what language did C++ originate?
Computer Simulation Lab
Presentation transcript:

Chapter 15 C-implementation PA = LU Speaker: Lung-Sheng Chien

OutLine Data structure of full matrix Implementation of PA=LU Visual Studio 2005: How To Linux machine: How to compile

Logical index : 2D row-major based col-major based row-major versus col-major We choose col-major representation

col-major based col-major: C starts index from 0 is useless 1 2 is forbidden legal matrix.h 3

Relaxation for high precision package Large 1D array, “int” is 4-byte, only supports up to 2G elements We use col-major, however you can implement both. global.h

matrix.h Data structure of matrix and its method 1 constructor ( 建構子 ): zeros 2 destructor ( 解構子 ): dealloc 3 Index rule: we do it explicitly 4 Arithmetic: matvec, matsub, norm 5 I/O: disp

matrix.cpp 1 empty handler contiguous memory block constructor [1] 5 set parameter

matrix.cpp constructor [2] 4 4 pointer arithmetic low high

destructor matrix.cpp free physic storage 2 free pointer array 3 free matrix handler

matrix.cpp Input/Output Show in standard form: human readable

main.cpp Simple driver Execution result

matrix.cpp duplicate of a matrix / vector We require matrix handler to verify configuration, this is very important for debugging. verification

y = Ax matrix.cpp Outer-product formulation

Matrix / vector norm matrix.cpp Maximum of absolute column sum Maximum of absolute row sum 2-norm is difficult to compute, we will discuss this later

OutLine Data structure of full matrix Implementation of PA=LU Visual Studio 2005: How To Linux machine: How to compile

Algorithm ( PA = LU ) [1] Given full matrix, construct initial lower triangle matrix use permutation vector to record permutation matrix (1) we store lower triangle matrix L into storage of matrix A (2) The reason to construct type int_matrix is for permutation matrix P, since we can check dimension between A and P. verification

we have compute update original matrix stores in lower triangle matrix for let,and Algorithm ( PA = LU ) [2] Note that P is a column vector

Algorithm ( PA = LU ) [3] find a such that 1 swap rowand row 2 define permutation matrix then after swapping rows, we have, NOT efficient

computefor 3 Algorithm ( PA = LU ) [4] compute by swappingand then ifthen endif 4

Algorithm ( PA = LU ) [5] we store lower triangle matrix into storage of matrix A, this code is different from code in MATLAB. decompose 5 How to computeefficiently?

Algorithm ( PA = LU ) [6] component-wise update : Observation: we implement with column-major form, column-wise update is good

Algorithm ( PA = LU ) [7] endfor by updating by updating matrix then where (recursion is done)

/111/ / Algorithm ( PA = LU ) [8] Store L and U into original A Question 1: how to write down a test driver Question 2: how to do backward and forward

main.cpp Test driver [1] Remember to duplicate matrix A since A is modified when execute LU decomposition. 1

Test driver [2] Linear solver: do backward and forward

Exercise Implement PA = LU. Implement forward and backward. Write a driver to test your linear solver. Any other implementation for full matrix?

OutLine Data structure of full matrix Implementation of PA=LU Visual Studio 2005: How To Linux machine: How to compile

Visual Studio 2005: How To [1] Create a new project: File  Project

Visual Studio 2005: How To [2] Choose Win32 console application, this is the same as what we do in VC 6.0 Project name: vc 2005 will create a directory, the same name as project name

Visual Studio 2005: How To [3] We choose “next” bottom to set an empty project, DO NOT press Finish bottom.

Visual Studio 2005: How To [4] Empty project, this is very important

Visual Studio 2005: How To [5] 1 Empty project 2 Add new item (source file or header file) to this project 3 Add “main.cpp” to this project

Visual Studio 2005: How To [6] Write source code “hello world” Compile: Build  Build matrix

Visual Studio 2005: How To [7] Result of compilation, including linking: success Additional directory “debug” appears Executable file “matrix.exe” in this debug directory

Visual Studio 2005: How To [8] Execute matrix.exe: Debug  Start Without Debugging Execution in VC 6.0

Visual Studio 2005: How To [9] Suppose we want to add several source files into this project. Copy files into directory /matrix/matrix 1 2 Add source files into the project by Project  Add Existing item

Visual Studio 2005: How To [10] Select the files you want to add All souce files in this project

Visual Studio 2005: How To [11] Remember that executable file is in directory /matrix/debug, you can use command window to execute matrix.exe

Visual Studio 2005: How To [12] There is another “debug” directory in /matrix/matrix, this directory contains object files, no executable file

OutLine Data structure of full matrix Implementation of PA=LU Visual Studio 2005: How To Linux machine: How to compile

Linux machine: How to compile [1] Suppose we put all source file into directory matrix_constructor and upload to workstation. 1 2 Remove all VC related files. 3 use command “qmake -project” to generate project file

Linux machine: How to compile [2] 4 use command “qmake matrix_constructor.pro” to generate Makefile Later on, we will introduce Makefile 5 use command “make” to compile your codes and generate executable file

6 Execute executable file by “./matrix_constructor” Linux machine: How to compile [3]