Difference between revisions of "Python3.4.3/C3/AdvancedMatrixOperations/English"
Nancyvarkey (Talk  contribs) 
Nancyvarkey (Talk  contribs) 

Line 205:  Line 205:  
    
 style="backgroundcolor:#ffffff;bordertop:0.5pt solid #000001;borderbottom:0.5pt solid #000001;borderleft:0.5pt solid #000001;borderright:none;paddingtop:0cm;paddingbottom:0cm;paddingleft:0.095cm;paddingright:0.191cm;" Slide Assignment 2: Infinity norm   style="backgroundcolor:#ffffff;bordertop:0.5pt solid #000001;borderbottom:0.5pt solid #000001;borderleft:0.5pt solid #000001;borderright:none;paddingtop:0cm;paddingbottom:0cm;paddingleft:0.095cm;paddingright:0.191cm;" Slide Assignment 2: Infinity norm  
−   style="backgroundcolor:#ffffff;border:0.5pt solid #000001;paddingtop:0cm;paddingbottom:0cm;paddingleft:0.095cm;paddingright:0.191cm;" Find the infinity norm of the  +   style="backgroundcolor:#ffffff;border:0.5pt solid #000001;paddingtop:0cm;paddingbottom:0cm;paddingleft:0.095cm;paddingright:0.191cm;" Find the '''infinity norm''' of the '''matrix im.''' 
    
Line 257:  Line 257:  
−  We have unpacked these values into  +  We have unpacked these values into '''variable U, sigma''' and '''V''''' underscore '''''conjugate.''' 
    
Line 303:  Line 303:  
−  '''smat''' is a 2 by 3 zero matrix  +  '''smat''' is a 2 by 3 '''zero matrix''' 
    
Line 328:  Line 328:  
−  It means elements in '''m1''' and in product of''' U, sigma '''and''' V''''' underscore '''''conjugate '''are equal.  +  It means '''elements''' in '''m1''' and in product of''' U, sigma '''and''' V''''' underscore '''''conjugate '''are equal. 
   
Latest revision as of 18:37, 7 December 2018
Title of script: Advanced Matrix Operations
Author: Puneeth, Thirumalesh H S, Arun KP
Keywords: Python, IPython, array, matrices, norm, svd, video tutorial


Show Slide title  Welcome to the spoken tutorial on Advanced matrix operations. 
Show Slide
Objectives

In this tutorial, you will learn to,

Show Slide
System Specifications 
To record this tutorial, I am using

Show Slide
Prerequisites

To practise this tutorial, you should know about
If not, see the relevant Python tutorials on this website. 
Show Slide

First we will see about flatten function.

Open terminal  Let us start ipython.

Type,
ipython3 
Type, ipython3 and press Enter.

Type,
from numpy import asmatrix,arange

Now let us see how to create arrays

Type a

Then type, a

Highlight (arange(1,10).reshape(3,3))  Here, we can see 3 by 3 matrix is converted into one dimensional matrix. 
Show Slide
Frobenius norm of a matrix 
Next we will see about frobenius norm.
It is defined as the square root of the sum of the absolute squares of its elements. 
Pause the video.
 
Show Slide
Assignment 1: Frobenius norm 
Find out the frobenius norm of the inverse of the given 4 by 4 matrix. 
Switch to terminal  Switch back to the terminal for the solution. 
Type,
m = asmatrix(arange(1,17).reshape(4,4))

Type
m is equal to asmatrix inside brackets arange inside brackets 1 comma 17 dot reshape inside brackets 4 comma 4

Type,
m[0,1] = 0 m[1,3] =0 
Now type,
m inside square brackets 0 comma 1 is equal to 0 m inside square brackets 1 comma 3 is equal to 0 
Type m  Then type, m

Type,
from numpy.linalg import inv, norm im = inv(m) norm(im)

In order to find out the Frobenius norm of the inverse of matrix m, type as shown.

Show Slide
Infinity norm 
Next, we will see about infinity norm of a matrix.

Pause the video.
 
Slide Assignment 2: Infinity norm  Find the infinity norm of the matrix im. 
Switch to terminal  Switch back to the terminal for the solution. 
Type,
from numpy import infnorm(im,ord=inf) 
To find out the Infinity norm of the matrix im, type as shown.

Type, norm?  To know more about norms type norm question mark

Show Slide
Singular value decomposition 
Next we will see about singular value decomposition.

Type,
from numpy import matrix from numpy.linalg import svd m1 = matrix([[3,2,2],[2,3,2]]) U,sigma,V_conjugate = svd(m1)

The SVD of matrix m1 can be found using svd function available in the numpy.linalg module.
svd returns a tuple of 3 elements.

Type,
U sigma V_conjugate 
Type, Capital U

Narration only  We can validate the singular value decomposition by comparing the product of:
U, sigma and V underscore conjugate with m1

Type,
from numpy import diag,allclose from numpy.matlib import zeros smat = zeros((2,3)) 
Type as shown.

Type,
smat 
Type smat

Type,
smat[:2, :2] = diag(sigma) 
Now type,
smat inside square brackets colon 2 comma colon 2 is equal to diag inside brackets sigma 
Type smat  Then type smat

Type
allclose(m1, U * smat * V_conjugate) 
Type as shown.

Show Slide
Summary

This brings us to the end of this tutorial. Let us summarize.

Show Slide
Self assessment questions slide.

Here is a self assessment question for you to solve
1. norm inside brackets A comma ord is equal to inside single quotes fro is the same as norm inside brackets A True or False. 
Show Slide
Solution of self assessment questions on slide 
And the answer is True since the order is equal to inside single quotes fro stands for Frobenius norm. 
Show Slide Forum  Please post your timed queries in this forum. 
Show Slide Fossee Forum  Please post your general queries on Python in this forum. 
Slide TBC  FOSSEE team coordinates the TBC project. 
Show Slide
Acknowledgment 
Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.
For more details, visit this website. 
Previous slide  This is Priya from IIT Bombay signing off.
Thanks for watching. 