Lecture 13 - Math 350

Block matrices

{{A, B}, {C,D}} -> A is n by n so B must be n by m
this means that C has r rows and n columns and D is r by m

A={{a11, a12},{a21, a22}}

A//MatrixForm

B = {{b11, b12, b13},{b21, b22, b23}}

B//MatrixForm

{{A, B}}//MatrixForm

ArrayFlatten[{{A, B}}]//MatrixForm

Cee= {{c11, c12}}

Dee={{d11, d12, d12}}

ArrayFlatten[{{A, B},{Cee,Dee}}]//MatrixForm

R = RandomInteger[{0,9},{5,5}]

R//MatrixForm

IdentityMatrix[3]//MatrixForm

TensorProduct[R, IdentityMatrix[3]]//MatrixForm

R eye //MatrixForm

ArrayFlatten[R eye /. 0 -> ConstantArray[0,{3,3}] /. eye -> IdentityMatrix[3]] //MatrixForm

R//MatrixForm

Singular Value Decomposition

A = U Σ (SuperStar[V]) (why?) - like an eigenvalue decomp but for rectangular matrices

T= RandomInteger[{0,9},{3,5}]

{{5,3,0,6,9},{6,5,5,3,0},{1,7,9,8,7}}

{u, s, v} = SingularValueDecomposition[T];

u//N//MatrixForm

usmall = N[u][[All, 1;;2]]

usmall//MatrixForm

s //N//MatrixForm

ssmall = N[s][[1;;2,1;;2]]

v //N//MatrixForm

vsmall = N[v][[All,1;;2]]

usmall.ssmall.Transpose[vsmall] //MatrixForm

T//MatrixForm

u.s.Transpose[v]//N//MatrixForm

Mathematica and image compression with with SVD

i = Import["ExampleData/ocelot.jpg"]

ImageData[i][[30;;35, 30;;35]]//MatrixForm

idata = ImageData[i]

Dimensions[idata]

{u, s, v} = SingularValueDecomposition[idata];

s[[100;;110, 100;;110]] //MatrixForm

usmall = u[[All,1;;50]];
ssmall = s[[1;;50, 1;;50]];

vsmall = v[[All, 1;;50]];

Dimensions[usmall]

Image[usmall.ssmall.Transpose[vsmall]]