% Created 2011-06-06 Mon 13:56
\documentclass[presentation]{beamer}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{float}
\usepackage{wrapfig}
\usepackage{soul}
\usepackage{textcomp}
\usepackage{marvosym}
\usepackage{wasysym}
\usepackage{latexsym}
\usepackage{amssymb}
\usepackage{hyperref}
\tolerance=1000
\usepackage[english]{babel} \usepackage{ae,aecompl}
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
\usepackage{listings}
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
\providecommand{\alert}[1]{\textbf{#1}}

\title{}
\author{FOSSEE}
\date{}

\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
\begin{document}











\begin{frame}

\begin{center}
\vspace{12pt}
\textcolor{blue}{\huge Matrices}
\end{center}
\vspace{18pt}
\begin{center}
\vspace{10pt}
\includegraphics[scale=0.95]{../images/fossee-logo.png}\\
\vspace{5pt}
\scriptsize Developed by FOSSEE Team, IIT-Bombay. \\ 
\scriptsize Funded by National Mission on Education through ICT\\
\scriptsize  MHRD,Govt. of India\\
\includegraphics[scale=0.30]{../images/iitb-logo.png}\\
\end{center}
\end{frame}
\begin{frame}
\frametitle{Objectives}
\label{sec-2}

  At the end of this tutorial, you will be able to, 


\begin{itemize}
\item Create matrices using data.
\item Create matrices from lists.
\item Do basic matrix operations like addition,multiplication.
\item Perform operations to find out the --
\begin{itemize}
\item inverse of a matrix
\item determinant of a matrix
\item eigen values and eigen vectors of a matrix
\item norm of a matrix
\item singular value decomposition of a matrix.
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Pre-requisite}
\label{sec-3}

  Spoken tutorial on -

\begin{itemize}
\item Getting started with Lists.
\item Getting started with Arrays.
\item Accessing parts of Arrays.
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Creating a matrix}
\label{sec-4}


\begin{itemize}
\item Creating a matrix using direct data
\end{itemize}
\begin{verbatim}
   In []: m1 = array([1, 2, 3, 4])
\end{verbatim}


\begin{itemize}
\item Creating a matrix using lists
\end{itemize}
\begin{verbatim}
   In []: l1 = [[1,2,3,4],[5,6,7,8]]
   In []: m2 = array(l1)
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 1}
\label{sec-5}

  Create a (2, 4) matrix \verb~m3~
\begin{verbatim}
   m3 = [[5,  6,  7,  8],
         [9, 10, 11, 12
\end{verbatim}
\end{frame}
\begin{frame}[fragile]
\frametitle{Matrix operations}
\label{sec-6}


\begin{itemize}
\item Element-wise addition (both matrix should be of order \verb~mXn~)
\begin{verbatim}
     In []: m3 + m2
\end{verbatim}

\item Element-wise subtraction (both matrix should be of order \verb~mXn~)
\begin{verbatim}
     In []: m3 - m2
\end{verbatim}

\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Recall from \verb~array~}
\label{sec-7}


\begin{itemize}
\item The functions
\begin{itemize}
\item \verb~identity(n)~ - 
      creates an identity matrix of order \verb~nXn~
\item \verb~zeros((m,n))~ - 
      creates a matrix of order \verb~mXn~ with 0's
\item \verb~zeros_like(A)~ - 
      creates a matrix with 0's similar to the shape of matrix \verb~A~
\item \verb~ones((m,n))~
      creates a matrix of order \verb~mXn~ with 1's
\item \verb~ones_like(A)~
      creates a matrix with 1's similar to the shape of matrix \verb~A~
\end{itemize}
\end{itemize}
  Can also be used with matrices
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 2 : Frobenius norm \& inverse}
\label{sec-8}

   Find out the Frobenius norm of inverse of a \verb~4 X 4~ matrix.
\begin{verbatim}
   
\end{verbatim}

  The matrix is
\begin{verbatim}
   m5 = arange(1,17).reshape(4,4)
\end{verbatim}


\begin{itemize}
\item Inverse of A,
\begin{itemize}
\item $A^{-1} = inv(A)$
\end{itemize}
\item Frobenius norm is defined as,
\begin{itemize}
\item $||A||_F = [\sum_{i,j} abs(a_{i,j})^2]^{1/2}$
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Exercise 3 : Infinity norm}
\label{sec-9}

  Find the infinity norm of the matrix \verb~im5~
\begin{verbatim}
   
\end{verbatim}


\begin{itemize}
\item Infinity norm is defined as,
       $max([\sum_{i} abs(a_{i})^2])$
\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{\verb~norm()~ method}
\label{sec-10}


\begin{itemize}
\item Frobenius norm
\begin{verbatim}
     In []: norm(im5)
\end{verbatim}

\item Infinity norm
\begin{verbatim}
     In []: norm(im5, ord=inf)
\end{verbatim}

\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{eigen values \& eigen vectors}
\label{sec-11}

  Find out the eigen values and eigen vectors of the matrix \verb~m5~.
\begin{verbatim}
   
\end{verbatim}


\begin{itemize}
\item eigen values and vectors can be found out using
\begin{verbatim}
     In []: eig(m5)
\end{verbatim}

    returns a tuple of \emph{eigen values} and \emph{eigen vectors}
\item \emph{eigen values} in tuple
\begin{itemize}
\item \verb~In []: eig(m5)[0]~
\end{itemize}
\item \emph{eigen vectors} in tuple
\begin{itemize}
\item \verb~In []: eig(m5)[1]~
\end{itemize}
\item Computing \emph{eigen values} using \verb~eigvals()~
\begin{verbatim}
     In []: eigvals(m5)
\end{verbatim}

\end{itemize}
\end{frame}
\begin{frame}[fragile]
\frametitle{Singular Value Decomposition (\verb~svd~)}
\label{sec-12}

    $M = U \Sigma V^*$

\begin{itemize}
\item U, an \verb~mXm~ unitary matrix over K.
\item $\Sigma$
        , an \verb~mXn~ diagonal matrix with non-negative real numbers on diagonal.
\item $V^*$
        , an \verb~nXn~ unitary matrix over K, denotes the conjugate transpose of V.
\item SVD of matrix \verb~m5~ can be found out as,
\end{itemize}
\begin{verbatim}
     In []: svd(m5)
\end{verbatim}
\end{frame}
\begin{frame}
\frametitle{Summary}
\label{sec-13}

  In this tutorial, we have learnt to, 


\begin{itemize}
\item Create matrices using arrays.
\item Add and multiply the elements of matrix.
\item Find out the inverse of a matrix,using the function ``inv()``.
\item Use the function ``det()`` to find the determinant of a matrix.
\item Calculate the norm of a matrix using the for loop and also using 
    the function ``norm()``.
\item Find out the eigen vectors and eigen values of a matrix, using 
    functions ``eig()`` and ``eigvals()``.
\item Calculate singular value decomposition(SVD) of a matrix using the 
    function ``svd()``.
\end{itemize}
 
\end{frame}
\begin{frame}

  \begin{block}{}
  \begin{center}
  \textcolor{blue}{\Large THANK YOU!} 
  \end{center}
  \end{block}
\begin{block}{}
  \begin{center}
    For more Information, visit our website\\
    \url{http://fossee.in/}
  \end{center}  
  \end{block}
\end{frame}

\end{document}