Difference between revisions of "Python-3.4.3/C3/Advanced-Matrix-Operations/English"
(Created page with "'''Title of script''': '''Advanced Matrix Operations''' '''Author: Puneeth, Thirumalesh H S, Arun KP''' '''Keywords: Python, IPython, array, matrices, norm, svd, video tutor...") |
|||
Line 191: | Line 191: | ||
− | We changed value of element at row 0 column 1 and row 1 column 3 to 0. | + | We changed the value of element at row 0 column 1 and row 1 column 3 to 0. |
|- | |- | ||
Line 294: | Line 294: | ||
− | We have unpacked these | + | We have unpacked these values into variable '''U''', '''sigma''' and '''V''''' underscore '''''conjugate.''' |
Line 367: | Line 367: | ||
− | '''smat''' is a '''2 '''by''' 3''' matrix created for multiplication by placing values of '''sigma''' as diagonal elements and | + | '''smat''' is a '''2 '''by''' 3''' matrix created for multiplication by placing values of '''sigma''' as diagonal elements and zero elsewhere. |
Revision as of 13:07, 8 November 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
Pre-requisites
|
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
from numpy import asmatrix,arange
|
Show Slide
Frobenius norm of a matrix |
Next we will see about frobenius norm.
|
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))
m[0,1] = 0 m[1,3] =0
|
Type
m is equal to asmatrix inside brackets arange inside brackets 1 comma 17 dot reshape inside brackets 4 comma 4
m inside square brackets 0 comma 1 is equal to 0 m inside square brackets 1 comma 3 is equal to 0
|
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)
U sigma V_conjugate |
The SVD of matrix m1 can be found using svd function available in the numpy.linalg module.
|
Type,
from numpy import diag,allclose from numpy.matlib import zeros smat = zeros((2,3))
smat
allclose(m1, U * smat * V_conjugate)
|
We can validate the singular value decomposition by comparing the product of:
U, sigma and V underscore conjugate with m1
smat
smat inside square brackets colon 2 comma colon 2 is equal to diag inside brackets sigma
smat
|
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. |