accessing-pieces-arrays/slides.tex
changeset 380 c17aa604468a
parent 348 3f70aeb1e115
equal deleted inserted replaced
379:4b3c0d8fffe2 380:c17aa604468a
     1 % Created 2010-10-26 Tue 12:11
     1 % Created 2010-11-02 Tue 17:47
     2 \documentclass[presentation]{beamer}
     2 \documentclass[presentation]{beamer}
     3 \usepackage[latin1]{inputenc}
     3 \usepackage[latin1]{inputenc}
     4 \usepackage[T1]{fontenc}
     4 \usepackage[T1]{fontenc}
     5 \usepackage{fixltx2e}
     5 \usepackage{fixltx2e}
     6 \usepackage{graphicx}
     6 \usepackage{graphicx}
     7 \usepackage{longtable}
     7 \usepackage{longtable}
     8 \usepackage{float}
     8 \usepackage{float}
     9 \usepackage{wrapfig}
     9 \usepackage{wrapfig}
    10 \usepackage{soul}
    10 \usepackage{soul}
    11 \usepackage{t1enc}
       
    12 \usepackage{textcomp}
    11 \usepackage{textcomp}
    13 \usepackage{marvosym}
    12 \usepackage{marvosym}
    14 \usepackage{wasysym}
    13 \usepackage{wasysym}
    15 \usepackage{latexsym}
    14 \usepackage{latexsym}
    16 \usepackage{amssymb}
    15 \usepackage{amssymb}
    26 
    25 
    27 \title{Accessing parts of arrays}
    26 \title{Accessing parts of arrays}
    28 \author{FOSSEE}
    27 \author{FOSSEE}
    29 \date{}
    28 \date{}
    30 
    29 
    31 \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
    30 \usetheme{Antibes}\usecolortheme{lily}\useoutertheme{infolines}\setbeamercovered{transparent}
    32 \begin{document}
    31 \begin{document}
    33 
    32 
    34 \maketitle
    33 \maketitle
    35 
    34 
    36 
    35 
    55 \end{frame}
    54 \end{frame}
    56 \begin{frame}[fragile]
    55 \begin{frame}[fragile]
    57 \frametitle{Sample Arrays}
    56 \frametitle{Sample Arrays}
    58 \label{sec-2}
    57 \label{sec-2}
    59 
    58 
    60 \begin{verbatim}
    59 \lstset{language=Python}
       
    60 \begin{lstlisting}
    61 In []: A = array([12, 23, 34, 45, 56])
    61 In []: A = array([12, 23, 34, 45, 56])
    62 
    62 
    63 In []: C = array([[11, 12, 13, 14, 15],
    63 In []: C = array([[11, 12, 13, 14, 15],
    64                   [21, 22, 23, 24, 25],
    64                   [21, 22, 23, 24, 25],
    65                   [31, 32, 33, 34, 35],
    65                   [31, 32, 33, 34, 35],
    66                   [41, 42, 43, 44, 45],
    66                   [41, 42, 43, 44, 45],
    67                   [51, 52, 53, 54, 55]])
    67                   [51, 52, 53, 54, 55]])
    68 \end{verbatim}
    68 \end{lstlisting}
    69 \end{frame}
    69 \end{frame}
    70 \begin{frame}
    70 \begin{frame}
    71 \frametitle{Question 1}
    71 \frametitle{Question 1}
    72 \label{sec-3}
    72 \label{sec-3}
    73 
    73 
    75 \end{frame}
    75 \end{frame}
    76 \begin{frame}[fragile]
    76 \begin{frame}[fragile]
    77 \frametitle{Solution 1}
    77 \frametitle{Solution 1}
    78 \label{sec-4}
    78 \label{sec-4}
    79 
    79 
    80 \begin{verbatim}
    80 \lstset{language=Python}
       
    81 \begin{lstlisting}
    81 In []:  C[:, -1] = 0
    82 In []:  C[:, -1] = 0
    82 \end{verbatim}
    83 \end{lstlisting}
    83 \end{frame}
    84 \end{frame}
    84 \begin{frame}
    85 \begin{frame}
    85 \frametitle{Question 2}
    86 \frametitle{Question 2}
    86 \label{sec-5}
    87 \label{sec-5}
    87 
    88 
    89 \end{frame}
    90 \end{frame}
    90 \begin{frame}[fragile]
    91 \begin{frame}[fragile]
    91 \frametitle{Solution 2}
    92 \frametitle{Solution 2}
    92 \label{sec-6}
    93 \label{sec-6}
    93 
    94 
    94 \begin{verbatim}
    95 \lstset{language=Python}
       
    96 \begin{lstlisting}
    95 In []:  A[:] = [11, 12, 13, 14, 15]
    97 In []:  A[:] = [11, 12, 13, 14, 15]
    96 \end{verbatim}
    98 \end{lstlisting}
    97 \end{frame}
    99 \end{frame}
    98 \begin{frame}
   100 \begin{frame}
    99 \frametitle{squares.png}
   101 \frametitle{squares.png}
   100 \label{sec-7}
   102 \label{sec-7}
   101 
   103 
   115 \end{frame}
   117 \end{frame}
   116 \begin{frame}[fragile]
   118 \begin{frame}[fragile]
   117 \frametitle{Solution 3}
   119 \frametitle{Solution 3}
   118 \label{sec-9}
   120 \label{sec-9}
   119 
   121 
   120 \begin{verbatim}
   122 \lstset{language=Python}
       
   123 \begin{lstlisting}
   121 In []:  C[1, 1:3]
   124 In []:  C[1, 1:3]
   122 In []:  C[0:4, 0]
   125 In []:  C[0:4, 0]
   123 In []:  C[1:5, 0]
   126 In []:  C[1:5, 0]
   124 \end{verbatim}
   127 \end{lstlisting}
   125 \end{frame}
   128 \end{frame}
   126 \begin{frame}
   129 \begin{frame}
   127 \frametitle{Question 4}
   130 \frametitle{Question 4}
   128 \label{sec-10}
   131 \label{sec-10}
   129 
   132 
   131 \end{frame}
   134 \end{frame}
   132 \begin{frame}[fragile]
   135 \begin{frame}[fragile]
   133 \frametitle{Solution 4}
   136 \frametitle{Solution 4}
   134 \label{sec-11}
   137 \label{sec-11}
   135 
   138 
   136 \begin{verbatim}
   139 \lstset{language=Python}
       
   140 \begin{lstlisting}
   137 In []:  C[1:3, 2:4]
   141 In []:  C[1:3, 2:4]
   138 \end{verbatim}
   142 \end{lstlisting}
   139 \end{frame}
   143 \end{frame}
   140 \begin{frame}
   144 \begin{frame}
   141 \frametitle{Question 5}
   145 \frametitle{Question 5}
   142 \label{sec-12}
   146 \label{sec-12}
   143 
   147 
   145 \end{frame}
   149 \end{frame}
   146 \begin{frame}[fragile]
   150 \begin{frame}[fragile]
   147 \frametitle{Solution 5}
   151 \frametitle{Solution 5}
   148 \label{sec-13}
   152 \label{sec-13}
   149 
   153 
   150 \begin{verbatim}
   154 \lstset{language=Python}
       
   155 \begin{lstlisting}
   151 In []: imshow(I[75:225, 75:225])
   156 In []: imshow(I[75:225, 75:225])
   152 \end{verbatim}
   157 \end{lstlisting}
   153 \end{frame}
   158 \end{frame}
   154 \begin{frame}[fragile]
   159 \begin{frame}[fragile]
   155 \frametitle{Question 6}
   160 \frametitle{Question 6}
   156 \label{sec-14}
   161 \label{sec-14}
   157 
   162 
   158   Obtain the following
   163   Obtain the following
   159 \begin{verbatim}
   164 \lstset{language=Python}
       
   165 \begin{lstlisting}
   160 [[12, 0], [42, 0]]
   166 [[12, 0], [42, 0]]
   161 [[12, 13, 14], [0, 0, 0]]
   167 [[12, 13, 14], [0, 0, 0]]
   162 \end{verbatim}
   168 \end{lstlisting}
   163 \end{frame}
   169 \end{frame}
   164 \begin{frame}[fragile]
   170 \begin{frame}[fragile]
   165 \frametitle{Solution 6}
   171 \frametitle{Solution 6}
   166 \label{sec-15}
   172 \label{sec-15}
   167 
   173 
   168 \begin{verbatim}
   174 \lstset{language=Python}
       
   175 \begin{lstlisting}
   169 In []: C[::3, 1::3]
   176 In []: C[::3, 1::3]
   170 In []: C[::4, 1:4]
   177 In []: C[::4, 1:4]
   171 \end{verbatim}
   178 \end{lstlisting}
   172 \end{frame}
   179 \end{frame}
   173 \begin{frame}
   180 \begin{frame}
   174 \frametitle{Summary}
   181 \frametitle{Summary}
   175 \label{sec-16}
   182 \label{sec-16}
   176 
   183 
   177   You should now be able to --
   184   You should now be able to --
   178 \begin{itemize}
   185 \begin{itemize}
   179 \item Manipulate 1D \& Multi dimensional arrays
   186 \item Manipulate single \& multi dimensional arrays
   180 
   187 
   181 \begin{itemize}
   188 \begin{itemize}
   182 \item Access and change individual elements
   189 \item Access and change individual elements
   183 \item Access and change rows and columns
   190 \item Access and change rows and columns
   184 \item Slice and stride on arrays
   191 \item Slice and stride on arrays