Arrays: computing with many numbers Some perspective We have so far - - PowerPoint PPT Presentation

arrays computing with many numbers some perspective
SMART_READER_LITE
LIVE PREVIEW

Arrays: computing with many numbers Some perspective We have so far - - PowerPoint PPT Presentation

Arrays: computing with many numbers Some perspective We have so far (mostly) looked at what we can do with single numbers (and functions that return single numbers). Things can get much more interesting once we allow not just one, but many


slide-1
SLIDE 1

Arrays: computing with many numbers

slide-2
SLIDE 2

Some perspective

— We have so far (mostly) looked at what we can do with single

numbers (and functions that return single numbers).

— Things can get much more interesting once we allow not just one,

but many numbers together.

— It is natural to view an array of numbers as one object with its

  • wn rules.

— The simplest such set of rules is that of a vector.

slide-3
SLIDE 3

A vector is an element of a Vector Space

x = 8 > > > < > > > : x1 x2 . . . xn 9 > > > = > > > ; = [x1 x2 · · · xn]T

Vector space !: A vector space is a set " of vectors and a field ℱ of scalars with two

  • perations:

1) addition: $ + & ∈ ", and $, & ∈ " 2) multiplication : α * $ ∈ ", and $ ∈ " , α ∈ ℱ

Vectors

+-vector:

k

d

se

slide-4
SLIDE 4

The addition and multiplication operations must satisfy: (for ,, - ∈ ℱ and $,& ∈ ") Associativity: $ + & + . = $ + & + . Commutativity: $ + & = & + $ Additive identity: & + 0 = & Additive inverse: & + −& = 0 Associativity wrt scalar multiplication: , * - * & = , * - * & Distributive wrt scalar addition: , + - * & = , * & + - * & Distributive wrt vector addition: , * $ + & = , * $ + , * & Scalar multiplication identity: 1 * $ = $

Vector Space

slide-5
SLIDE 5

Linear Functions

Function: The function ! takes vectors " ∈ $ and transforms into vectors % ∈ & A function f is a linear function if (1) f (u+v) = f (u)+ f (v) (2) f (au) = a f (u) for any scalar a set $ (“input data”) set & (“output data”)

00

Ida

a

slide-6
SLIDE 6

Linear functions?

3 4 = 5 4 + 6, 3: ℛ → ℛ, 5, 6 ∈ ℛ and 5, 6 ≠ 0 3 4 = |"|

" , 3: ℛ → ℛ

Hutu) -

  • lute

Uto

f-(a) =#

fCo2

f-(Utv) f- flu) t f-Co)

flu) = a ut b } au ta v t 2b

flu)

= a Vtb = a cutv)t2b

Hutu

)

= a (ut Gtb 2¥

=

slide-7
SLIDE 7

Matrices

  • ;×+-matrix
  • Linear functions 3(>) can be represented by a Matrix-Vector

multiplication.

  • Think of a matrix @ as a linear function that takes vectors >

and transforms them into vectors A A = 3(>) → A = @ >

  • Hence we have:

@ B + C = @ B + @ C @ , B = , @ B @ = D## D#$ … D#% D$# D$$ … D$% ⋮ ⋮ ⋱ ⋮ D&# D&$ … D&%

  • -0

a -

mm

  • no

} A

slide-8
SLIDE 8

Matrix-Vector multiplication

  • Recall summation notation for matrix-vector multiplication % = ( "

)! = ∑"#$

%

+!","

  • = 1,2, … , 2
  • You can think about matrix-vector multiplication as:

Linear combination of column vectors of A Dot product of " with rows of A % = ,$ 3 : , 1 + ,& 3 : , 2 + ⋯ + ,% 3[: , 8] % = 3 1, : : " ⋮ 3 2, : : " MXN

l

meh

txt

← ① €=

=

=

=

slide-9
SLIDE 9

Matrices operating on data

Data set: " Data set: % Rotation

A = H >

  • r

A = @ >

rs

M

I

slide-10
SLIDE 10

Example: Shear operator

Matrix-vector multiplication for each vector (point representation in 2D):

!! !"

(Iathis)

.

"" ":*:i÷." ,

to

  • Miao

,

a:O,

*

¥:: H¥¥¥

slide-11
SLIDE 11

Matrices as operators

  • Data: grid of 2D points
  • Transform the data using matrix multiply

What can matrices do? 1. Shear 2. Rotate 3. Scale 4. Reflect 5. Can they translate?

slide-12
SLIDE 12

Rotation operator

I# I$ = cos(M) −sin(M) sin(M) cos(M) 4# 4$

' = )/6
slide-13
SLIDE 13

Scale operator

I# I$ = 5 6 4# 4$

3/2 1 3/2 3/2 3/2 2/3
slide-14
SLIDE 14

Reflection operator

I# I$ = −5 −6 4# 4$

−1 1 Reflect about y-axis Reflect about x and y-axis −1 −1
slide-15
SLIDE 15

Translation (shift)

I# I$ = 1 1 4# 4$ + 5 6

) = 0.6; . = 1.1
slide-16
SLIDE 16

Matrices operating on data

Data set: ( Data set: < Rotation

slide-17
SLIDE 17

Norms

O

,

. I

slide-18
SLIDE 18

Example of Norms

Demo “Vector Norms”

O

O

p-4

:

I

x,ltlxzlt---.tlxn1p=2

i

N xft XE t

  • r l Xnf

p=D

:

H X Hoo = mfex I Xi I

slide-19
SLIDE 19

Unit Ball:

Set of vectors > with norm > = 1

t÷÷i÷ ÷÷÷9÷÷

slide-20
SLIDE 20

Norms and Errors

#

= =

slide-21
SLIDE 21

Absolute and Relative Errors

Her Hp,

= Health

Xtrue = ( 40.114 , -88.224)

llxtruellp-2

Xmea = (40, -88)

=

0.2513

  • §a
= ( 0.114 , -0.224)

I 40.1142+88.2242

Heallp .

  • zedo.1142to.22.TT
=

0.2513 Her

22593×10-3

slide-22
SLIDE 22

Matrix Norms

slide-23
SLIDE 23 I

f¥÷÷÷i÷÷÷÷÷÷÷÷

:::

vena

:

÷÷÷÷÷i÷÷÷:

slide-24
SLIDE 24

Matrix Norms

slide-25
SLIDE 25

Matrix Norms

slide-26
SLIDE 26

Induced Matrix Norms

@ # = max

,

S

  • .#
%

D-, @ / = max

  • S
,.# %

D-, @ $ = max T0

=' are the singular value of the matrix ( Maximum absolute column sum of the matrix ( Maximum absolute row sum of the matrix (

±:

  • mash

=

±nE¥÷"÷÷:*

Kimm"ax

slide-27
SLIDE 27

Properties of Matrix Norms

slide-28
SLIDE 28

Examples

Determine the norm of the following matrices: 1) 2) II.①

H

Hoo = 7

1¥41 ⇒ it

up.

  • 6
slide-29
SLIDE 29

{

"

III.

"

fight .tt#T3

= {

10 , 5,30}

HAH →

30

slide-30
SLIDE 30
  • T = [ 100 ,

13

,

0.5]

HAftp.z-m.at

Ti

=

100

slide-31
SLIDE 31

" a-

'

" m

¥77::: :::D

T = [Too

' Ts 'T →

slide-32
SLIDE 32

Notation and special matrices

  • Square matrix: / = 0
  • Zero matrix:
  • Identity matrix
  • Symmetric matrix:
  • Permutation matrix:
  • Permutation of the identity matrix
  • Permutes (swaps) rows
  • Diagonal matrix: 1!" = 0, ∀4, 5 | 4 ≠ 5
  • Triangular matrix:

⇢ 6 Aij = Aji [A] = [A]T

  • Aij = 0

[I] = [δij] ⇢

δij = ⇢ 1 i = j i 6= j

1 1 1 ) . 8 = 8 ) . Lower triangular: 9!" = :9!" , 4 ≥ 5 0, 4 < 5 Upper triangular: =!" = :=!" , 4 ≤ 5 0, 4 > 5
slide-33
SLIDE 33

More about matrices

  • Rank: the rank of a matrix @ is the dimension of the vector space generated
by its columns, which is equivalent to the number of linearly independent columns of the matrix.
  • Suppose @ has shape /×0:
  • C)0D @ ≤ min(/, 0)
  • Matrix @ is full rank: C)0D @ = min(/, 0). Otherwise, matrix @ is
rank deficient.
  • Singular matrix: a square matrix @ is invertible if there exists a square matrix
J such that @K = K@ = L. If the matrix is not invertible, it is called singular.