matrix_primer

matrix_primer - Matrix Primer Add two 3x3 matrices...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Matrix Primer Add two 3x3 matrices Pre-conditions: two non-empty 3x3 matrices of integer/ real / complex type Post-conditions: a new 3x3 matrix of the same type with the elements added Pseudo-code: 1. Let the matrices A, B be the input matrices 2. Let the matrix holding the sum be called Sum. 3. For I in 1. . 3 loop i. For J in 1. . 3 loop 1. Sum(I,J) := A(I,J) + B(I,J) 4. Return matrix Sum Multiply two 3x3 matrices Suppose that A and B are two matrices and that A is an m x n matrix (m rows and n columns) and that B is a p x q matrix. To be able to multiply A and B together, A must have the same number of columns as B has rows (i.e., n=p). The product will be a matrix with m rows and q columns. To find the entry in row r and column c of the new matrix we take the "dot product" of row r of matrix A and column c of matrix B (pair up the elements of row r with column c, multiply these pairs together individually, and then add their products). Mathematically,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

matrix_primer - Matrix Primer Add two 3x3 matrices...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online