Introduction to Programming (in C++) Multi-dimensional vectors. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Size: px
Start display at page:

Download "Introduction to Programming (in C++) Multi-dimensional vectors. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC"

Transcription

1 Introduction to Programming (in C++) Multi-dimensional vectors Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

2 Matrices A matrix can be considered a two-dimensional vector, i.e. a vector of vectors. my_matrix: // Declaration of a matrix with 3 rows and 4 columns vector< vector<int> > my_matrix(3,vector<int>(4)); // A more elegant declaration typedef vector<int> Row; // One row of the matrix typedef vector<row> Matrix; // Matrix: a vector of rows Matrix my_matrix(3,row(4)); // The same matrix as above Introduction to Programming Dept. CS, UPC 2

3 Matrices A matrix can be considered as a 2-dimensional vector, i.e., a vector of vectors. my_matrix: my_matrix[0][2] my_matrix[1][3] my_matrix[2] Introduction to Programming Dept. CS, UPC 3

4 n-dimensional vectors Vectors with any number of dimensions can be declared: typedef vector<int> Dim1; typedef vector<dim1> Dim2; typedef vector<dim2> Dim3; typedef vector<dim3> Matrix4D; Matrix4D my_matrix(5,dim3(i+1,dim2(n,dim1(9)))); Introduction to Programming Dept. CS, UPC 4

5 Sum of matrices Design a function that calculates the sum of two n m matrices = typedef vector< vector<int> > Matrix; Matrix matrix_sum(const Matrix& a, const Matrix& b); Introduction to Programming Dept. CS, UPC 5

6 How are the elements of a matrix visited? By rows j By columns j i i For every row i For every column j Visit Matrix[i][j] For every column j For every row i Visit Matrix[i][j] Introduction to Programming Dept. CS, UPC 6

7 Sum of matrices (by rows) typedef vector< vector<int> > Matrix; // Pre: a and b are non-empty matrices and have the same size. // Returns a+b (sum of matrices). Matrix matrix_sum(const Matrix& a, const Matrix& b) { int nrows = a.size(); int ncols = a[0].size(); Matrix c(nrows, vector<int>(ncols)); for (int i = 0; i < nrows; ++i) { for (int j = 0; j < ncols; ++j) { c[i][j] = a[i][j] + b[i][j]; return c; Introduction to Programming Dept. CS, UPC 7

8 Sum of matrices (by columns) typedef vector< vector<int> > Matrix; // Pre: a and b are non-empty matrices and have the same size. // Returns a+b (sum of matrices). Matrix matrix_sum(const Matrix& a, const Matrix& b) { int nrows = a.size(); int ncols = a[0].size(); Matrix c(nrows, vector<int>(ncols)); for (int j = 0; j < ncols; ++j) { for (int i = 0; i < nrows; ++i) { c[i][j] = a[i][j] + b[i][j]; return c; Introduction to Programming Dept. CS, UPC 8

9 Transpose a matrix Design a procedure that transposes a square matrix in place: void Transpose (Matrix& m); Observation: we need to swap the upper with the lower triangular matrix. The diagonal remains intact. Introduction to Programming Dept. CS, UPC 9

10 Transpose a matrix // Interchanges two values void swap(int& a, int& b) { int c = a; a = b; b = c; // Pre: m is a square matrix // Post: m contains the transpose of the input matrix void Transpose(Matrix& m) { int n = m.size(); for (int i = 0; i < n - 1; ++i) { for (int j = i + 1; j < n; ++j) { swap(m[i][j], m[j][i]); Introduction to Programming Dept. CS, UPC 10

11 Is a matrix symmetric? Design a procedure that indicates whether a matrix is symmetric: bool is_symmetric(const Matrix& m); symmetric not symmetric Observation: we only need to compare the upper with the lower triangular matrix. Introduction to Programming Dept. CS, UPC 11

12 Is a matrix symmetric? // Pre: m is a square matrix // Returns true if m is symmetric, and false otherwise bool is_symmetric(const Matrix& m) { int n = m.size(); for (int i = 0; i < n 1; ++i) { for (int j = i + 1; j < n; ++j) { if (m[i][j]!= m[j][i]) return false; return true; Introduction to Programming Dept. CS, UPC 12

13 Search in a matrix Design a procedure that finds a value in a matrix. If the value belongs to the matrix, the procedure will return the location (i, j) at which the value has been found. // Pre: m is a non-empty matrix // Post: i and j define the location of a cell // that contains the value x in m. // In case x is not in m, then i = j = -1. void search(const Matrix& m, int x, int& i, int& j); Introduction to Programming Dept. CS, UPC 13

14 Search in a matrix // Pre: m is a non-empty matrix // Post: i and j define the location of a cell // that contains the value x in M. // In case x is not in m, then i = j = -1 void search(const Matrix& m, int x, int& i, int& j) { int nrows = m.size(); int ncols = m[0].size(); for (i = 0; i < nrows; ++i) { for (j = 0; j < ncols; ++j) { if (m[i][j] == x) return; i = -1; j = -1; Introduction to Programming Dept. CS, UPC 14

15 Search in a sorted matrix A sorted matrix m is one in which m[i][j] m[i][j+1] m[i][j] m[i+1][j] Introduction to Programming Dept. CS, UPC 15

16 Search in a sorted matrix Example: let us find 10 in the matrix. We look at the lower left corner of the matrix. Since 13 > 10, the value cannot be found in the last row Introduction to Programming Dept. CS, UPC 16

17 Search in a sorted matrix We look again at the lower left corner of the remaining matrix. Since 11 > 10, the value cannot be found in the row Introduction to Programming Dept. CS, UPC 17

18 Search in a sorted matrix Since 9 < 10, the value cannot be found in the column Introduction to Programming Dept. CS, UPC 18

19 Search in a sorted matrix Since 11 > 10, the value cannot be found in the row Introduction to Programming Dept. CS, UPC 19

20 Search in a sorted matrix Since 7 < 10, the value cannot be found in the column Introduction to Programming Dept. CS, UPC 20

21 Search in a sorted matrix The element has been found! Introduction to Programming Dept. CS, UPC 21

22 Search in a sorted matrix Invariant: if the element is in the matrix, then it is located in the sub-matrix [0 i, j ncols-1] j i Introduction to Programming Dept. CS, UPC 22

23 Search in a sorted matrix // Pre: m is non-empty and sorted by rows and columns // in ascending order. // Post: i and j define the location of a cell that contains the value // x in m. In case x is not in m, then i=j=-1. void search(const Matrix& m, int x, int& i, int& j) { int nrows = m.size(); int ncols = m[0].size(); i = nrows - 1; j = 0; // Invariant: x can only be found in M[0..i,j..ncols-1] while (i >= 0 and j < ncols) { if (m[i][j] < x) j = j + 1; else if (m[i][j] > x) i = i 1; else return; i = -1; j = -1; Introduction to Programming Dept. CS, UPC 23

24 Search in a sorted matrix What is the largest number of iterations of a search algorithm in a matrix? Unsorted matrix Sorted matrix nrows ncols nrows + ncols The search algorithm in a sorted matrix cannot start in all of the corners of the matrix. Which corners are suitable? Introduction to Programming Dept. CS, UPC 24

25 Matrix multiplication Design a function that returns the multiplication of two matrices = // Pre: a is a non-empty n m matrix, // b is a non-empty m p matrix // Returns a b (an n p matrix) Matrix multiply(const Matrix& a, const Matrix& b); Introduction to Programming Dept. CS, UPC 25

26 Matrix multiplication // Pre: a is a non-empty n m matrix, b is a non-empty m p matrix. // Returns a b (an n p matrix). Matrix multiply(const Matrix& a, const Matrix& b) { int n = a.size(); int m = a[0].size(); int p = b[0].size(); Matrix c(n, vector<int>(p)); for (int i = 0; i < n; ++i) { for (int j = 0; j < p; ++j) { int sum = 0; for (int k = 0; k < m; ++k) { sum = sum + a[i][k] b[k][j]; c[i][j] = sum; return c; Introduction to Programming Dept. CS, UPC 26

27 Matrix multiplication // Pre: a is a non-empty n m matrix, b is a non-empty m p matrix. // Returns a b (an n p matrix). Matrix multiply(const Matrix& a, const Matrix& b) { int n = a.size(); Initialized int m = a[0].size(); to zero int p = b[0].size(); Matrix c(n, vector<int>(p, 0)); for (int i = 0; i < n; ++i) { for (int j = 0; j < p; ++j) { for (int k = 0; k < m; ++k) { c[i][j] += a[i][k] b[k][j]; return c; Accumulation The loops can be in any order Introduction to Programming Dept. CS, UPC 27

28 Matrix multiplication // Pre: a is a non-empty n m matrix, b is a non-empty m p matrix. // Returns a b (an n p matrix). Matrix multiply(const Matrix& a, const Matrix& b) { int n = a.size(); int m = a[0].size(); int p = b[0].size(); Matrix c(n, vector<int>(p, 0)); for (int j = 0; j < p; ++j) { for (int k = 0; k < m; ++k) { for (int i = 0; i < n; ++i) { c[i][j] += a[i][k] b[k][j]; return c; Introduction to Programming Dept. CS, UPC 28

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

Matrix Multiplication

Matrix Multiplication CPS343 Parallel and High Performance Computing Spring 2016 CPS343 (Parallel and HPC) Matrix Multiplication Spring 2016 1 / 32 Outline 1 Matrix operations Importance Dense and sparse

Introduction to Programming (in C++) Sorting. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Sorting Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Sorting Let elem be a type with a operation, which is a total order A vector

Linear Algebra Review. Vectors

Linear Algebra Review By Tim K. Marks UCSD Borrows heavily from: Jana Kosecka kosecka@cs.gmu.edu http://cs.gmu.edu/~kosecka/cs682.html Virginia de Sa Cogsci 8F Linear Algebra review UCSD Vectors The length

18.06 Problem Set 4 Solution Due Wednesday, 11 March 2009 at 4 pm in 2-106. Total: 175 points.

806 Problem Set 4 Solution Due Wednesday, March 2009 at 4 pm in 2-06 Total: 75 points Problem : A is an m n matrix of rank r Suppose there are right-hand-sides b for which A x = b has no solution (a) What

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM!

1.4 Arrays Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 2/6/11 12:33 PM! A Foundation for Programming any program you might want

1 Introduction to Matrices

1 Introduction to Matrices In this section, important definitions and results from matrix algebra that are useful in regression analysis are introduced. While all statements below regarding the columns

Notes on Determinant

ENGG2012B Advanced Engineering Mathematics Notes on Determinant Lecturer: Kenneth Shum Lecture 9-18/02/2013 The determinant of a system of linear equations determines whether the solution is unique, without

1 VECTOR SPACES AND SUBSPACES

1 VECTOR SPACES AND SUBSPACES What is a vector? Many are familiar with the concept of a vector as: Something which has magnitude and direction. an ordered pair or triple. a description for quantities such

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B. KITCHENS

December 4, 2013 MATH 171 BASIC LINEAR ALGEBRA B KITCHENS The equation 1 Lines in two-dimensional space (1) 2x y = 3 describes a line in two-dimensional space The coefficients of x and y in the equation

15.062 Data Mining: Algorithms and Applications Matrix Math Review

.6 Data Mining: Algorithms and Applications Matrix Math Review The purpose of this document is to give a brief review of selected linear algebra concepts that will be useful for the course and to develop

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS. + + x 2. x n. a 11 a 12 a 1n b 1 a 21 a 22 a 2n b 2 a 31 a 32 a 3n b 3. a m1 a m2 a mn b m

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS 1. SYSTEMS OF EQUATIONS AND MATRICES 1.1. Representation of a linear system. The general system of m equations in n unknowns can be written a 11 x 1 + a 12 x 2 +

6. Cholesky factorization

6. Cholesky factorization EE103 (Fall 2011-12) triangular matrices forward and backward substitution the Cholesky factorization solving Ax = b with A positive definite inverse of a positive definite matrix

High Performance Cloud: a MapReduce and GPGPU Based Hybrid Approach

High Performance Cloud: a MapReduce and GPGPU Based Hybrid Approach Beniamino Di Martino, Antonio Esposito and Andrea Barbato Department of Industrial and Information Engineering Second University of Naples

Arrays. number: Motivation. Prof. Stewart Weiss. Software Design Lecture Notes Arrays

Motivation Suppose that we want a program that can read in a list of numbers and sort that list, or nd the largest value in that list. To be concrete about it, suppose we have 15 numbers to read in from

13 MATH FACTS 101. 2 a = 1. 7. The elements of a vector have a graphical interpretation, which is particularly easy to see in two or three dimensions.

3 MATH FACTS 0 3 MATH FACTS 3. Vectors 3.. Definition We use the overhead arrow to denote a column vector, i.e., a linear segment with a direction. For example, in three-space, we write a vector in terms

AP Computer Science Java Mr. Clausen Program 9A, 9B

AP Computer Science Java Mr. Clausen Program 9A, 9B PROGRAM 9A I m_sort_of_searching (20 points now, 60 points when all parts are finished) The purpose of this project is to set up a program that will

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS

MATRIX ALGEBRA AND SYSTEMS OF EQUATIONS Systems of Equations and Matrices Representation of a linear system The general system of m equations in n unknowns can be written a x + a 2 x 2 + + a n x n b a

Parallel Algorithm for Dense Matrix Multiplication

Parallel Algorithm for Dense Matrix Multiplication CSE633 Parallel Algorithms Fall 2012 Ortega, Patricia Outline Problem definition Assumptions Implementation Test Results Future work Conclusions Problem

Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

Solution to Homework 2

Solution to Homework 2 Olena Bormashenko September 23, 2011 Section 1.4: 1(a)(b)(i)(k), 4, 5, 14; Section 1.5: 1(a)(b)(c)(d)(e)(n), 2(a)(c), 13, 16, 17, 18, 27 Section 1.4 1. Compute the following, if

7 Gaussian Elimination and LU Factorization

7 Gaussian Elimination and LU Factorization In this final section on matrix factorization methods for solving Ax = b we want to take a closer look at Gaussian elimination (probably the best known method

Section 5.3. Section 5.3. u m ] l jj. = l jj u j + + l mj u m. v j = [ u 1 u j. l mj

Section 5. l j v j = [ u u j u m ] l jj = l jj u j + + l mj u m. l mj Section 5. 5.. Not orthogonal, the column vectors fail to be perpendicular to each other. 5..2 his matrix is orthogonal. Check that

Similar matrices and Jordan form

Similar matrices and Jordan form We ve nearly covered the entire heart of linear algebra once we ve finished singular value decompositions we ll have seen all the most central topics. A T A is positive

Hybrid Programming with MPI and OpenMP

Hybrid Programming with and OpenMP Ricardo Rocha and Fernando Silva Computer Science Department Faculty of Sciences University of Porto Parallel Computing 2015/2016 R. Rocha and F. Silva (DCC-FCUP) Programming

Section 6.1 - Inner Products and Norms

Section 6.1 - Inner Products and Norms Definition. Let V be a vector space over F {R, C}. An inner product on V is a function that assigns, to every ordered pair of vectors x and y in V, a scalar in F,

Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix multiplication).

MAT 2 (Badger, Spring 202) LU Factorization Selected Notes September 2, 202 Abstract: We describe the beautiful LU factorization of a square matrix (or how to write Gaussian elimination in terms of matrix

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set.

MATH 304 Linear Algebra Lecture 9: Subspaces of vector spaces (continued). Span. Spanning set. Vector space A vector space is a set V equipped with two operations, addition V V (x,y) x + y V and scalar

What is Multi Core Architecture?

What is Multi Core Architecture? When a processor has more than one core to execute all the necessary functions of a computer, it s processor is known to be a multi core architecture. In other words, a

LINEAR ALGEBRA. September 23, 2010

LINEAR ALGEBRA September 3, 00 Contents 0. LU-decomposition.................................... 0. Inverses and Transposes................................. 0.3 Column Spaces and NullSpaces.............................

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix.

MATH 304 Linear Algebra Lecture 18: Rank and nullity of a matrix. Nullspace Let A = (a ij ) be an m n matrix. Definition. The nullspace of the matrix A, denoted N(A), is the set of all n-dimensional column

Solving Problems Recursively

Solving Problems Recursively Recursion is an indispensable tool in a programmer s toolkit Allows many complex problems to be solved simply Elegance and understanding in code often leads to better programs:

Lecture Notes on Linear Search

Lecture Notes on Linear Search 15-122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is

STATISTICS AND DATA ANALYSIS IN GEOLOGY, 3rd ed. Clarificationof zonationprocedure described onpp. 238-239

STATISTICS AND DATA ANALYSIS IN GEOLOGY, 3rd ed. by John C. Davis Clarificationof zonationprocedure described onpp. 38-39 Because the notation used in this section (Eqs. 4.8 through 4.84) is inconsistent

Chapter 19. General Matrices. An n m matrix is an array. a 11 a 12 a 1m a 21 a 22 a 2m A = a n1 a n2 a nm. The matrix A has n row vectors

Chapter 9. General Matrices An n m matrix is an array a a a m a a a m... = [a ij]. a n a n a nm The matrix A has n row vectors and m column vectors row i (A) = [a i, a i,..., a im ] R m a j a j a nj col

Math 115A HW4 Solutions University of California, Los Angeles. 5 2i 6 + 4i. (5 2i)7i (6 + 4i)( 3 + i) = 35i + 14 ( 22 6i) = 36 + 41i.

Math 5A HW4 Solutions September 5, 202 University of California, Los Angeles Problem 4..3b Calculate the determinant, 5 2i 6 + 4i 3 + i 7i Solution: The textbook s instructions give us, (5 2i)7i (6 + 4i)(

AMATH 352 Lecture 3 MATLAB Tutorial Starting MATLAB Entering Variables

AMATH 352 Lecture 3 MATLAB Tutorial MATLAB (short for MATrix LABoratory) is a very useful piece of software for numerical analysis. It provides an environment for computation and the visualization. Learning

MATH10212 Linear Algebra. Systems of Linear Equations. Definition. An n-dimensional vector is a row or a column of n numbers (or letters): a 1.

MATH10212 Linear Algebra Textbook: D. Poole, Linear Algebra: A Modern Introduction. Thompson, 2006. ISBN 0-534-40596-7. Systems of Linear Equations Definition. An n-dimensional vector is a row or a column

DATA ANALYSIS II. Matrix Algorithms

DATA ANALYSIS II Matrix Algorithms Similarity Matrix Given a dataset D = {x i }, i=1,..,n consisting of n points in R d, let A denote the n n symmetric similarity matrix between the points, given as where

Using row reduction to calculate the inverse and the determinant of a square matrix

Using row reduction to calculate the inverse and the determinant of a square matrix Notes for MATH 0290 Honors by Prof. Anna Vainchtein 1 Inverse of a square matrix An n n square matrix A is called invertible

Orthogonal Diagonalization of Symmetric Matrices

MATH10212 Linear Algebra Brief lecture notes 57 Gram Schmidt Process enables us to find an orthogonal basis of a subspace. Let u 1,..., u k be a basis of a subspace V of R n. We begin the process of finding

Lecture 3. Optimising OpenCL performance

Lecture 3 Optimising OpenCL performance Based on material by Benedict Gaster and Lee Howes (AMD), Tim Mattson (Intel) and several others. - Page 1 Agenda Heterogeneous computing and the origins of OpenCL

Math 312 Homework 1 Solutions

Math 31 Homework 1 Solutions Last modified: July 15, 01 This homework is due on Thursday, July 1th, 01 at 1:10pm Please turn it in during class, or in my mailbox in the main math office (next to 4W1) Please

Introduction to Matrix Algebra

Psychology 7291: Multivariate Statistics (Carey) 8/27/98 Matrix Algebra - 1 Introduction to Matrix Algebra Definitions: A matrix is a collection of numbers ordered by rows and columns. It is customary

Recursion. Slides. Programming in C++ Computer Science Dept Va Tech Aug., 2001. 1995-2001 Barnette ND, McQuain WD

1 Slides 1. Table of Contents 2. Definitions 3. Simple 4. Recursive Execution Trace 5. Attributes 6. Recursive Array Summation 7. Recursive Array Summation Trace 8. Coding Recursively 9. Recursive Design

8 Square matrices continued: Determinants

8 Square matrices continued: Determinants 8. Introduction Determinants give us important information about square matrices, and, as we ll soon see, are essential for the computation of eigenvalues. You

The Determinant: a Means to Calculate Volume

The Determinant: a Means to Calculate Volume Bo Peng August 20, 2007 Abstract This paper gives a definition of the determinant and lists many of its well-known properties Volumes of parallelepipeds are

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors. Jordan canonical form (continued).

MATH 423 Linear Algebra II Lecture 38: Generalized eigenvectors Jordan canonical form (continued) Jordan canonical form A Jordan block is a square matrix of the form λ 1 0 0 0 0 λ 1 0 0 0 0 λ 0 0 J = 0

1 0 5 3 3 A = 0 0 0 1 3 0 0 0 0 0 0 0 0 0 0

Solutions: Assignment 4.. Find the redundant column vectors of the given matrix A by inspection. Then find a basis of the image of A and a basis of the kernel of A. 5 A The second and third columns are

ANALYTIC HIERARCHY PROCESS (AHP) TUTORIAL

Kardi Teknomo ANALYTIC HIERARCHY PROCESS (AHP) TUTORIAL Revoledu.com Table of Contents Analytic Hierarchy Process (AHP) Tutorial... 1 Multi Criteria Decision Making... 1 Cross Tabulation... 2 Evaluation

Manifold Learning Examples PCA, LLE and ISOMAP

Manifold Learning Examples PCA, LLE and ISOMAP Dan Ventura October 14, 28 Abstract We try to give a helpful concrete example that demonstrates how to use PCA, LLE and Isomap, attempts to provide some intuition

Vector and Matrix Norms

Chapter 1 Vector and Matrix Norms 11 Vector Spaces Let F be a field (such as the real numbers, R, or complex numbers, C) with elements called scalars A Vector Space, V, over the field F is a non-empty

For example, we have seen that a list may be searched more efficiently if it is sorted.

Sorting 1 Many computer applications involve sorting the items in a list into some specified order. For example, we have seen that a list may be searched more efficiently if it is sorted. To sort a group

Solution of Linear Systems

Chapter 3 Solution of Linear Systems In this chapter we study algorithms for possibly the most commonly occurring problem in scientific computing, the solution of linear systems of equations. We start

Systems of Linear Equations

Systems of Linear Equations Beifang Chen Systems of linear equations Linear systems A linear equation in variables x, x,, x n is an equation of the form a x + a x + + a n x n = b, where a, a,, a n and

The Characteristic Polynomial

Physics 116A Winter 2011 The Characteristic Polynomial 1 Coefficients of the characteristic polynomial Consider the eigenvalue problem for an n n matrix A, A v = λ v, v 0 (1) The solution to this problem

MAT188H1S Lec0101 Burbulla

Winter 206 Linear Transformations A linear transformation T : R m R n is a function that takes vectors in R m to vectors in R n such that and T (u + v) T (u) + T (v) T (k v) k T (v), for all vectors u

MAT 200, Midterm Exam Solution. a. (5 points) Compute the determinant of the matrix A =

MAT 200, Midterm Exam Solution. (0 points total) a. (5 points) Compute the determinant of the matrix 2 2 0 A = 0 3 0 3 0 Answer: det A = 3. The most efficient way is to develop the determinant along the

Solving Linear Systems, Continued and The Inverse of a Matrix

, Continued and The of a Matrix Calculus III Summer 2013, Session II Monday, July 15, 2013 Agenda 1. The rank of a matrix 2. The inverse of a square matrix Gaussian Gaussian solves a linear system by reducing

Introduction to Matlab

Introduction to Matlab Social Science Research Lab American University, Washington, D.C. Web. www.american.edu/provost/ctrl/pclabs.cfm Tel. x3862 Email. SSRL@American.edu Course Objective This course provides

Basic Concepts in Matlab

Basic Concepts in Matlab Michael G. Kay Fitts Dept. of Industrial and Systems Engineering North Carolina State University Raleigh, NC 769-7906, USA kay@ncsu.edu September 00 Contents. The Matlab Environment.

Inner Product Spaces and Orthogonality

Inner Product Spaces and Orthogonality week 3-4 Fall 2006 Dot product of R n The inner product or dot product of R n is a function, defined by u, v a b + a 2 b 2 + + a n b n for u a, a 2,, a n T, v b,

October 3rd, 2012. Linear Algebra & Properties of the Covariance Matrix

Linear Algebra & Properties of the Covariance Matrix October 3rd, 2012 Estimation of r and C Let rn 1, rn, t..., rn T be the historical return rates on the n th asset. rn 1 rṇ 2 r n =. r T n n = 1, 2,...,

Name: Section Registered In:

Name: Section Registered In: Math 125 Exam 3 Version 1 April 24, 2006 60 total points possible 1. (5pts) Use Cramer s Rule to solve 3x + 4y = 30 x 2y = 8. Be sure to show enough detail that shows you are

Excel supplement: Chapter 7 Matrix and vector algebra

Excel supplement: Chapter 7 atrix and vector algebra any models in economics lead to large systems of linear equations. These problems are particularly suited for computers. The main purpose of this chapter

Matrix Algebra in R A Minimal Introduction

A Minimal Introduction James H. Steiger Department of Psychology and Human Development Vanderbilt University Regression Modeling, 2009 1 Defining a Matrix in R Entering by Columns Entering by Rows Entering

Direct Methods for Solving Linear Systems. Matrix Factorization

Direct Methods for Solving Linear Systems Matrix Factorization Numerical Analysis (9th Edition) R L Burden & J D Faires Beamer Presentation Slides prepared by John Carroll Dublin City University c 2011

[1] Diagonal factorization

8.03 LA.6: Diagonalization and Orthogonal Matrices [ Diagonal factorization [2 Solving systems of first order differential equations [3 Symmetric and Orthonormal Matrices [ Diagonal factorization Recall:

5 Arrays and Pointers

5 Arrays and Pointers 5.1 One-dimensional arrays Arrays offer a convenient way to store and access blocks of data. Think of arrays as a sequential list that offers indexed access. For example, a list of

Unit 18 Determinants

Unit 18 Determinants Every square matrix has a number associated with it, called its determinant. In this section, we determine how to calculate this number, and also look at some of the properties of

Mehtap Ergüven Abstract of Ph.D. Dissertation for the degree of PhD of Engineering in Informatics

INTERNATIONAL BLACK SEA UNIVERSITY COMPUTER TECHNOLOGIES AND ENGINEERING FACULTY ELABORATION OF AN ALGORITHM OF DETECTING TESTS DIMENSIONALITY Mehtap Ergüven Abstract of Ph.D. Dissertation for the degree

Applied Linear Algebra I Review page 1

Applied Linear Algebra Review 1 I. Determinants A. Definition of a determinant 1. Using sum a. Permutations i. Sign of a permutation ii. Cycle 2. Uniqueness of the determinant function in terms of properties

Analysis of Binary Search algorithm and Selection Sort algorithm

Analysis of Binary Search algorithm and Selection Sort algorithm In this section we shall take up two representative problems in computer science, work out the algorithms based on the best strategy to

Binary search algorithm

Binary search algorithm Definition Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than

OPTIMAL BINARY SEARCH TREES

OPTIMAL BINARY SEARCH TREES 1. PREPARATION BEFORE LAB DATA STRUCTURES An optimal binary search tree is a binary search tree for which the nodes are arranged on levels such that the tree cost is minimum.

SPECIAL PERTURBATIONS UNCORRELATED TRACK PROCESSING

AAS 07-228 SPECIAL PERTURBATIONS UNCORRELATED TRACK PROCESSING INTRODUCTION James G. Miller * Two historical uncorrelated track (UCT) processing approaches have been employed using general perturbations

Logistic Regression. Jia Li. Department of Statistics The Pennsylvania State University. Logistic Regression

Logistic Regression Department of Statistics The Pennsylvania State University Email: jiali@stat.psu.edu Logistic Regression Preserve linear classification boundaries. By the Bayes rule: Ĝ(x) = arg max

CS3220 Lecture Notes: QR factorization and orthogonal transformations

CS3220 Lecture Notes: QR factorization and orthogonal transformations Steve Marschner Cornell University 11 March 2009 In this lecture I ll talk about orthogonal matrices and their properties, discuss

Solving Systems of Linear Equations

LECTURE 5 Solving Systems of Linear Equations Recall that we introduced the notion of matrices as a way of standardizing the expression of systems of linear equations In today s lecture I shall show how

1.2 Solving a System of Linear Equations

1.. SOLVING A SYSTEM OF LINEAR EQUATIONS 1. Solving a System of Linear Equations 1..1 Simple Systems - Basic De nitions As noticed above, the general form of a linear system of m equations in n variables

Lecture Notes 2: Matrices as Systems of Linear Equations

2: Matrices as Systems of Linear Equations 33A Linear Algebra, Puck Rombach Last updated: April 13, 2016 Systems of Linear Equations Systems of linear equations can represent many things You have probably

Answers to Review Questions Chapter 7

Answers to Review Questions Chapter 7 1. The size declarator is used in a definition of an array to indicate the number of elements the array will have. A subscript is used to access a specific element

Computing Orthonormal Sets in 2D, 3D, and 4D

Computing Orthonormal Sets in 2D, 3D, and 4D David Eberly Geometric Tools, LLC http://www.geometrictools.com/ Copyright c 1998-2016. All Rights Reserved. Created: March 22, 2010 Last Modified: August 11,

F Matrix Calculus F 1

F Matrix Calculus F 1 Appendix F: MATRIX CALCULUS TABLE OF CONTENTS Page F1 Introduction F 3 F2 The Derivatives of Vector Functions F 3 F21 Derivative of Vector with Respect to Vector F 3 F22 Derivative

CS 5614: (Big) Data Management Systems. B. Aditya Prakash Lecture #18: Dimensionality Reduc7on

CS 5614: (Big) Data Management Systems B. Aditya Prakash Lecture #18: Dimensionality Reduc7on Dimensionality Reduc=on Assump=on: Data lies on or near a low d- dimensional subspace Axes of this subspace

Joint models for classification and comparison of mortality in different countries.

Joint models for classification and comparison of mortality in different countries. Viani D. Biatat 1 and Iain D. Currie 1 1 Department of Actuarial Mathematics and Statistics, and the Maxwell Institute

5. Orthogonal matrices

L Vandenberghe EE133A (Spring 2016) 5 Orthogonal matrices matrices with orthonormal columns orthogonal matrices tall matrices with orthonormal columns complex matrices with orthonormal columns 5-1 Orthonormal

2.2/2.3 - Solving Systems of Linear Equations

c Kathryn Bollinger, August 28, 2011 1 2.2/2.3 - Solving Systems of Linear Equations A Brief Introduction to Matrices Matrices are used to organize data efficiently and will help us to solve systems of

Linear Algebra Notes

Linear Algebra Notes Chapter 19 KERNEL AND IMAGE OF A MATRIX Take an n m matrix a 11 a 12 a 1m a 21 a 22 a 2m a n1 a n2 a nm and think of it as a function A : R m R n The kernel of A is defined as Note

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

VB.NET Programming Fundamentals

Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

Linear Programming. March 14, 2014

Linear Programming March 1, 01 Parts of this introduction to linear programming were adapted from Chapter 9 of Introduction to Algorithms, Second Edition, by Cormen, Leiserson, Rivest and Stein [1]. 1

R Language Fundamentals

R Language Fundamentals Data Frames Steven Buechler Department of Mathematics 276B Hurley Hall; 1-6233 Fall, 2007 Tabular Data Frequently, experimental data are held in tables, an Excel worksheet, for

340368 - FOPR-I1O23 - Fundamentals of Programming

Coordinating unit: 340 - EPSEVG - Vilanova i la Geltrú School of Engineering Teaching unit: 723 - CS - Department of Computer Science Academic year: Degree: 2015 BACHELOR'S DEGREE IN INFORMATICS ENGINEERING

The PageRank Citation Ranking: Bring Order to the Web

The PageRank Citation Ranking: Bring Order to the Web presented by: Xiaoxi Pang 25.Nov 2010 1 / 20 Outline Introduction A ranking for every page on the Web Implementation Convergence Properties Personalized

Linear Algebra and TI 89

Linear Algebra and TI 89 Abdul Hassen and Jay Schiffman This short manual is a quick guide to the use of TI89 for Linear Algebra. We do this in two sections. In the first section, we will go over the editing

Torgerson s Classical MDS derivation: 1: Determining Coordinates from Euclidean Distances

Torgerson s Classical MDS derivation: 1: Determining Coordinates from Euclidean Distances It is possible to construct a matrix X of Cartesian coordinates of points in Euclidean space when we know the Euclidean