Corrected errata in Matrices slides.
authorPuneeth Chaganti <punchagan@fossee.in>
Mon, 16 Nov 2009 12:03:49 +0530
changeset 318 e75d3c993ed5
parent 306 57291186d598
child 319 cef948318842
Corrected errata in Matrices slides.
day1/session4.tex
--- a/day1/session4.tex	Wed Nov 11 17:08:32 2009 +0530
+++ b/day1/session4.tex	Mon Nov 16 12:03:49 2009 +0530
@@ -134,16 +134,15 @@
 \begin{frame}[fragile]
 \frametitle{Matrices: Initializing}
 \begin{lstlisting}
-In []: A = array([[ 1,  1,  2, -1],
-                  [ 2,  5, -1, -9],
-                  [ 2,  1, -1,  3],
-                  [ 1, -3,  2,  7]])
-In []: A
+In []: c = array([[1,1,2],
+                  [2,4,1],
+                  [-1,3,7]])
+
+In []: c
 Out[]: 
-array([[ 1,  1,  2, -1],
-       [ 2,  5, -1, -9],
-       [ 2,  1, -1,  3],
-       [ 1, -3,  2,  7]])
+array([[1,1,2],
+       [2,4,1],
+       [-1,3,7]])
 \end{lstlisting}
 \end{frame}
 
@@ -173,17 +172,17 @@
 \begin{frame}[fragile]
   \frametitle{Accessing elements}
   \begin{lstlisting}
-In []: C = array([[1,1,2],
-                  [2,4,1],
-                  [-1,3,7]])
+In []: c
+Out[]: 
+array([[1,1,2],
+       [2,4,1],
+       [-1,3,7]])
 
-In []: C[1][2]
+In []: c[1][2]
 Out[]: 1
-
-In []: C[1,2]
+In []: c[1,2]
 Out[]: 1
-
-In []: C[1]
+In []: c[1]
 Out[]: array([2, 4, 1])
   \end{lstlisting}
 \end{frame}
@@ -192,15 +191,15 @@
   \frametitle{Changing elements}
   \begin{small}
   \begin{lstlisting}
-In []: C[1,1] = -2
-In []: C
+In []: c[1,1] = -2
+In []: c
 Out[]: 
 array([[ 1,  1,  2],
        [ 2, -2,  1],
        [-1,  3,  7]])
 
-In []: C[1] = [0,0,0]
-In []: C
+In []: c[1] = [0,0,0]
+In []: c
 Out[]: 
 array([[ 1,  1,  2],
        [ 0,  0,  0],
@@ -214,18 +213,18 @@
   \frametitle{Slicing}
 \begin{small}
   \begin{lstlisting}
-In []: C[:,1]
+In []: c[:,1]
 Out[]: array([1, 0, 3])
 
-In []: C[1,:]
+In []: c[1,:]
 Out[]: array([0, 0, 0])
 
-In []: C[0:2,:]
+In []: c[0:2,:]
 Out[]: 
 array([[1, 1, 2],
        [0, 0, 0]])
 
-In []: C[1:3,:]
+In []: c[1:3,:]
 Out[]: 
 array([[ 0,  0,  0],
        [-1,  3,  7]])
@@ -237,17 +236,17 @@
   \frametitle{Slicing \ldots}
 \begin{small}
   \begin{lstlisting}
-In []: C[:2,:]
+In []: c[:2,:]
 Out[]: 
 array([[1, 1, 2],
        [0, 0, 0]])
 
-In []: C[1:,:]
+In []: c[1:,:]
 Out[]: 
 array([[ 0,  0,  0],
        [-1,  3,  7]])
 
-In []: C[1:,:2]
+In []: c[1:,:2]
 Out[]: 
 array([[ 0,  0],
        [-1,  3]])
@@ -260,18 +259,18 @@
   \frametitle{Striding}
   \begin{small}
   \begin{lstlisting}
-In []: C[::2,:]
+In []: c[::2,:]
 Out[]: 
 array([[ 1,  1,  2],
        [-1,  3,  7]])
 
-In []: C[:,::2]
+In []: c[:,::2]
 Out[]: 
 xarray([[ 1,  2],
        [ 0,  0],
        [-1,  7]])
 
-In []: C[::2,::2]
+In []: c[::2,::2]
 Out[]: 
 array([[ 1,  2],
        [-1,  7]])
@@ -283,12 +282,12 @@
   \frametitle{Slicing \& Striding Exercises}
 \begin{small}
   \begin{lstlisting}
-In []: A = imread('lena.png')
+In []: a = imread('lena.png')
 
-In []: imshow(A)
+In []: imshow(a)
 Out[]: <matplotlib.image.AxesImage object at 0xa0384cc>
 
-In []: A.shape 
+In []: a.shape 
 Out[]: (512, 512, 4)
   \end{lstlisting}
 \end{small}
@@ -303,13 +302,13 @@
   \frametitle{Solutions}
 \begin{small}
   \begin{lstlisting}
-In []: imshow(A[:256,:256])
+In []: imshow(a[:256,:256])
 Out[]: <matplotlib.image.AxesImage object at 0xb6f658c>
 
-In []: imshow(A[200:400,200:400])
+In []: imshow(a[200:400,200:400])
 Out[]: <matplotlib.image.AxesImage object at 0xb757c2c>
 
-In []: imshow(A[::2,::2])
+In []: imshow(a[::2,::2])
 Out[]: <matplotlib.image.AxesImage object at 0xb765c8c>
   \end{lstlisting}
 \end{small}
@@ -318,7 +317,7 @@
 \begin{frame}[fragile]
 \frametitle{Transpose of a Matrix}
 \begin{lstlisting}
-In []: A.T
+In []: a.T
 Out[]:
 array([[ 1,  2,  2,  1],
        [ 1,  5,  1, -3],
@@ -330,7 +329,7 @@
 \begin{frame}[fragile]
   \frametitle{Sum of all elements}
   \begin{lstlisting}
-In []: sum(A)
+In []: sum(a)
 Out[]: 12
   \end{lstlisting}
 \end{frame}
@@ -338,11 +337,11 @@
 \begin{frame}[fragile]
   \frametitle{Matrix Addition}
   \begin{lstlisting}
-In []: B = array([[3,2,-1,5],
+In []: b = array([[3,2,-1,5],
                   [2,-2,4,9],
                   [-1,0.5,-1,-7],
                   [9,-5,7,3]])
-In []: A + B
+In []: a + b
 Out[]: 
 array([[  4. ,   3. ,   1. ,   4. ],
        [  4. ,   3. ,   3. ,   0. ],
@@ -354,7 +353,7 @@
 \begin{frame}[fragile]
 \frametitle{Elementwise Multiplication}
 \begin{lstlisting}
-In []: A*B
+In []: a*b
 Out[]: 
 array([[  3. ,   2. ,  -2. ,  -5. ],
        [  4. , -10. ,  -4. , -81. ],
@@ -367,7 +366,7 @@
 \begin{frame}[fragile]
 \frametitle{Matrix Multiplication}
 \begin{lstlisting}
-In []: dot(A,B)
+In []: dot(a, b)
 Out[]: 
 array([[ -6. ,   6. ,  -6. ,  -3. ],
        [-64. ,  38.5, -44. ,  35. ],
@@ -379,7 +378,7 @@
 \begin{frame}[fragile]
 \frametitle{Inverse of a Matrix}
 \begin{lstlisting}
-In []: inv(A)
+In []: inv(a)
 \end{lstlisting}
 \begin{small}
 \begin{lstlisting}
@@ -395,7 +394,7 @@
 \begin{frame}[fragile]
 \frametitle{Determinant}
 \begin{lstlisting}
-In []: det(A)
+In []: det(a)
 Out[]: 80.0
 \end{lstlisting}
 \end{frame}
@@ -405,16 +404,16 @@
 \frametitle{Eigenvalues and Eigen Vectors}
 \begin{small}
 \begin{lstlisting}
-In []: E = array([[3,2,4],[2,0,2],[4,2,3]])
+In []: e = array([[3,2,4],[2,0,2],[4,2,3]])
 
-In []: eig(E)
+In []: eig(e)
 Out[]: 
 (array([-1.,  8., -1.]),
  array([[-0.74535599,  0.66666667, -0.1931126 ],
         [ 0.2981424 ,  0.33333333, -0.78664085],
         [ 0.59628479,  0.66666667,  0.58643303]]))
 
-In []: eigvals(E)
+In []: eigvals(e)
 Out[]: array([-1.,  8., -1.])
 \end{lstlisting}
 \end{small}
@@ -423,7 +422,7 @@
 %% \begin{frame}[fragile]
 %% \frametitle{Computing Norms}
 %% \begin{lstlisting}
-%% In []: norm(E)
+%% In []: norm(e)
 %% Out[]: 8.1240384046359608
 %% \end{lstlisting}
 %% \end{frame}
@@ -432,7 +431,7 @@
 %%   \frametitle{Singular Value Decomposition}
 %%   \begin{small}
 %%   \begin{lstlisting}
-%% In []: svd(E)
+%% In []: svd(e)
 %% Out[]: 
 %% (array(
 %% [[ -6.66666667e-01,  -1.23702565e-16,   7.45355992e-01],