D-BAUG Informatik I. Exercise session: week 5 HS 2018

Similar documents
Lab #10 Multi-dimensional Arrays

Partha Sarathi Manal

Matlab- Command Window Operations, Scalars and Arrays

Introduction to Parallel Programming Message Passing Interface Practical Session Part I

1. Represent each of these relations on {1, 2, 3} with a matrix (with the elements of this set listed in increasing order).

Chapter 18 out of 37 from Discrete Mathematics for Neophytes: Number Theory, Probability, Algorithms, and Other Stuff by J. M. Cargal.

Exercise Set Decide whether each matrix below is an elementary matrix. (a) (b) (c) (d) Answer:

Parallelizing The Matrix Multiplication. 6/10/2013 LONI Parallel Programming Workshop

Attendance (2) Performance (3) Oral (5) Total (10) Dated Sign of Subject Teacher

Lecture 5: Matrices. Dheeraj Kumar Singh 07CS1004 Teacher: Prof. Niloy Ganguly Department of Computer Science and Engineering IIT Kharagpur

Parallel Algorithms CSE /22/2015. Outline of this lecture: 1 Implementation of cilk for. 2. Parallel Matrix Multiplication

Agenda. Arrays 01/12/2009 INTRODUCTION TO VBA PROGRAMMING. Arrays Matrices.

Dynamic Programming II

Lecture 57 Dynamic Programming. (Refer Slide Time: 00:31)

Lecture 13: Chain Matrix Multiplication

Student Outcomes. Classwork. Opening Exercise (3 minutes) Example 1 (8 minutes)

12 Dynamic Programming (2) Matrix-chain Multiplication Segmented Least Squares

CS4620/5620. Professor: Kavita Bala. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

14 Dynamic. Matrix-chain multiplication. P.D. Dr. Alexander Souza. Winter term 11/12

Self-study session 1, Discrete mathematics

EXTENSION. a 1 b 1 c 1 d 1. Rows l a 2 b 2 c 2 d 2. a 3 x b 3 y c 3 z d 3. This system can be written in an abbreviated form as

Modified Distribution Method

CS 177. Lists and Matrices. Week 8

Solve the matrix equation AX B for X by using A.(1-3) Use the Inverse Matrix Calculator Link to check your work

CE 601: Numerical Methods Lecture 5. Course Coordinator: Dr. Suresh A. Kartha, Associate Professor, Department of Civil Engineering, IIT Guwahati.

Dynamic Programming part 2

MATLAB for Experimental Research. Fall 2018 Vectors, Matrices, Matrix Operations

Performance Optimization Tutorial. Labs

AMS526: Numerical Analysis I (Numerical Linear Algebra)

REGULAR GRAPHS OF GIVEN GIRTH. Contents

Section 26: Associativity and Order of Operations

FOR LOOP. for <indexmin:indexstep:indexmax> {statements} end

Matrix Transformations The position of the corners of this triangle are described by the vectors: 0 1 ] 0 1 ] Transformation:

Lecture 8. Dynamic Programming

CS 33. Caches. CS33 Intro to Computer Systems XVIII 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.

CSC-140 Assignment 5

n = 1 What problems are interesting when n is just 1?

Homework3: Dynamic Programming - Answers

Matrix Multiplication

So far... Finished looking at lower bounds and linear sorts.

Lecture 7: Divide & Conquer 2. Integer Multiplication. & Matrix Multiplication. CS 341: Algorithms. Tuesday, Jan 29 th 2019

Lecture 4: Principles of Parallel Algorithm Design (part 4)

Lesson 6.8. Activity Materials square tiles

Chain Matrix Multiplication

GRADE 7 MATH LEARNING GUIDE

INTRODUCTION TO FORTRAN PART II

2.3 Algorithms Using Map-Reduce

Exercise 4: Loops, Arrays and Files

UML CS Algorithms Qualifying Exam Fall, 2003 ALGORITHMS QUALIFYING EXAM

Finite Math - J-term Homework. Section Inverse of a Square Matrix

COSC2430: Programming and Data Structures Sparse Matrix Multiplication: Search and Sorting Algorithms

Lesson 13: Exploring Factored Form

DESIGN AND ANALYSIS OF ALGORITHMS (DAA 2017)

Lesson 20: Every Line is a Graph of a Linear Equation

Programming Problem for the 1999 Comprehensive Exam

LAB 2: Linear Equations and Matrix Algebra. Preliminaries

Workload Characterization Techniques

Linear Equation Systems Iterative Methods

7 Control Structures, Logical Statements

Vector: A series of scalars contained in a column or row. Dimensions: How many rows and columns a vector or matrix has.

COSC2430: Programming and Data Structures Sparse Matrix Addition 2 2: Non-recursive and recursive; arrays and linked lists

Computer Programming: C++

YEAR 11 GENERAL MATHEMATICS 2015 MATRICES TEST

Matrix Multiplication

Matrix Multiplication. (Dynamic Programming)

Tribhuvan University Institute of Science and Technology 2065

Matrix Multiplication

Vectors and Matrices. Chapter 2. Linguaggio Programmazione Matlab-Simulink (2017/2018)

Computer Project #2 (Matrix Operations)

Maximum Contiguous Subsequence Sum. Check out from SVN: MCSSRaces

Parallel Computing: Parallel Algorithm Design Examples Jin, Hai

Declaring and ini,alizing 2D arrays

General Instructions. You can use QtSpim simulator to work on these assignments.

1 Lab 2: C Programming II

Cache memories are small, fast SRAM based memories managed automatically in hardware.

Blocks, Grids, and Shared Memory

Homework # 2 Due: October 6. Programming Multiprocessors: Parallelism, Communication, and Synchronization

Spare Matrix Formats, and The Standard Template Library

Lectures 12 and 13 Dynamic programming: weighted interval scheduling

Matrix Inverse 2 ( 2) 1 = 2 1 2

Graph Theory: Starting Out

Optimization Problems. Optimization Problems

1 class Lecture5 { 2 3 "Arrays" 4. Zheng-Liang Lu Java Programming 136 / 174

COSC 6385 Computer Architecture - Exercises

More Complicated Recursion CMPSC 122

15-451/651: Design & Analysis of Algorithms January 26, 2015 Dynamic Programming I last changed: January 28, 2015

Mathematics 4330/5344 #1 Matlab and Numerical Approximation

Slightly revised version of Scilab and Matrices by David Arnold, College of the Redwoods, August 17, 1998.

Submission instructions (read carefully): SS17 / Assignment 4 Instructor: Markus Püschel. ETH Zurich

10/26/ Solving Systems of Linear Equations Using Matrices. Objectives. Matrices

Lecture 6: Parallel Matrix Algorithms (part 3)

Communicators and Topologies: Matrix Multiplication Example

Numerical Algorithms

Dynamic Programming Shabsi Walfish NYU - Fundamental Algorithms Summer 2006

1. (a) O(log n) algorithm for finding the logical AND of n bits with n processors

CSE 202 Divide-and-conquer algorithms. Fan Chung Graham UC San Diego

Learning objec-ves. Declaring and ini-alizing 2D arrays. Prin-ng 2D arrays. Using 2D arrays Decomposi-on of a solu-on into objects and methods

Agenda Cache memory organization and operation Chapter 6 Performance impact of caches Cache Memories

Object Oriented Programming 2013/14. Final Exam June 20, 2014

ECE 545 Fall 2013 Final Exam

Transcription:

1 D-BAUG Informatik I Exercise session: week 5 HS 2018

Homework 2 Questions?

Matrix and Vector in Java 3 Vector v of length n:

Matrix and Vector in Java 3 Vector v of length n: double[] v = new double[n]; Matrix M with n rows and m columns:

Matrix and Vector in Java 3 Vector v of length n: double[] v = new double[n]; Matrix M with n rows and m columns: double M[][] = new double[n][m]; (a vector of length n of vectors of length m)

Task 4 Write a program that reads an n m matrix of integers from the input. The input is top to bottom, left to right: elements of the first column, followed by elements of the second column, etc. Print the matrix in the typical orientation (a row on the matrix on each row of the output). 1 Allocate an n m matrix.

4 Task Write a program that reads an n m matrix of integers from the input. The input is top to bottom, left to right: elements of the first column, followed by elements of the second column, etc. Print the matrix in the typical orientation (a row on the matrix on each row of the output). 1 Allocate an n m matrix. 2 For each column j (m in total), row i (n in total), read an integer from input and store it in the matrix.

4 Task Write a program that reads an n m matrix of integers from the input. The input is top to bottom, left to right: elements of the first column, followed by elements of the second column, etc. Print the matrix in the typical orientation (a row on the matrix on each row of the output). 1 Allocate an n m matrix. 2 For each column j (m in total), row i (n in total), read an integer from input and store it in the matrix. 3 For each row i (n in total), column j (m in total), print M[i][j]. Print a new line at the end of each row.

Matrix-Matrix-Multiplication 5 Let an n m matrix A and an m p matrix B be given A 11 A 12 A 1m B 11 B 12 B 1p A = A 21 A 22 A 2m...... B = B 21 B 22 B 2p...... A n1 A n2 A nm B m1 B m2 B mp

Matrix-Matrix-Multiplication 6 The matrix product of n m matrix A and m p matrix B is a new n p matrix C C 11 C 12 C 1p A B = B =: C 21 C 22 C 2p...... C n1 C n2 C np

Matrix-Matrix-Multiplication 7 m m B n A p C = A B

Matrix-Matrix-Multiplication 8 m C ij = A ik B kj 1 i p, 1 j n k=1

Task 9 Write a program that you can use to multiply two matrices. 1 First think about the input: what kind of format do you use for input?

9 Task Write a program that you can use to multiply two matrices. 1 First think about the input: what kind of format do you use for input? 2 Now think about the output: what kind of format do you use for output?

9 Task Write a program that you can use to multiply two matrices. 1 First think about the input: what kind of format do you use for input? 2 Now think about the output: what kind of format do you use for output? 3 Write funtions for In- and Output and test them. Always test small parts. What do you write first: input or output function?

9 Task Write a program that you can use to multiply two matrices. 1 First think about the input: what kind of format do you use for input? 2 Now think about the output: what kind of format do you use for output? 3 Write funtions for In- and Output and test them. Always test small parts. What do you write first: input or output function? 4 Write the core function for matrix multiplication.

9 Task Write a program that you can use to multiply two matrices. 1 First think about the input: what kind of format do you use for input? 2 Now think about the output: what kind of format do you use for output? 3 Write funtions for In- and Output and test them. Always test small parts. What do you write first: input or output function? 4 Write the core function for matrix multiplication. 5 Test your function with some test cases. How do you choose the cases?

Challenge 10 Now use your working function in our setup for image transformation: consider the Main method and add your matrix-matrix- multiplication function accordingly.