diff options
Diffstat (limited to 'getting_started_with_arrays/slides.tex')
-rw-r--r-- | getting_started_with_arrays/slides.tex | 275 |
1 files changed, 107 insertions, 168 deletions
diff --git a/getting_started_with_arrays/slides.tex b/getting_started_with_arrays/slides.tex index 7273c59..e35c35e 100644 --- a/getting_started_with_arrays/slides.tex +++ b/getting_started_with_arrays/slides.tex @@ -1,4 +1,4 @@ -% Created 2010-11-07 Sun 15:18 +% Created 2011-05-27 Fri 12:20 \documentclass[presentation]{beamer} \usepackage[latin1]{inputenc} \usepackage[T1]{fontenc} @@ -8,7 +8,6 @@ \usepackage{float} \usepackage{wrapfig} \usepackage{soul} -\usepackage{t1enc} \usepackage{textcomp} \usepackage{marvosym} \usepackage{wasysym} @@ -24,14 +23,13 @@ commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen}, showstringspaces=false, keywordstyle=\color{blue}\bfseries} \providecommand{\alert}[1]{\textbf{#1}} -\title{Getting started with arrays} +\title{} \author{FOSSEE} \date{} \usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent} \begin{document} -\maketitle @@ -41,244 +39,185 @@ showstringspaces=false, keywordstyle=\color{blue}\bfseries} -\begin{frame} -\frametitle{Outline} -\label{sec-1} - -\begin{itemize} -\item Arrays -\begin{itemize} -\item why arrays over lists -\end{itemize} +\begin{frame} -\item Creating arrays -\item Array operations -\end{itemize} +\begin{center} +\vspace{12pt} +\textcolor{blue}{\huge Getting started with Arrays} +\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{Overview of Arrays} +\frametitle{Objectives} \label{sec-2} -\begin{itemize} -\item Arrays are homogeneous data structures. - -\begin{itemize} -\item elements have to the same data type -\end{itemize} + At the end of this tutorial, you will be able to, -\item Arrays are faster compared to lists \begin{itemize} -\item at least \emph{80-100 times} faster than lists -\end{itemize} - +\item Create arrays using data. +\item Create arrays from lists. +\item Perform basic array operations. +\item Create identity matrix. +\item Use functions zeros(), zeros\_like(), ones(), ones\_like() \end{itemize} \end{frame} -\begin{frame}[fragile] -\frametitle{Creating Arrays} +\begin{frame} +\frametitle{Pre-requisite} \label{sec-3} + Spoken tutorial on - + \begin{itemize} -\item Creating a 1-dimensional array +\item Getting started with Lists. \end{itemize} - -\begin{verbatim} - In []: a1 = array([1, 2, 3, 4]) -\end{verbatim} - - \texttt{[1, 2, 3, 4]} is a list. \end{frame} -\begin{frame}[fragile] -\frametitle{Creating two-dimensional array} +\begin{frame} +\frametitle{Overview of Arrays} \label{sec-4} -\begin{itemize} -\item Creating a 2-dimensional array -\end{itemize} -\begin{verbatim} - In []: a2 = array([[1,2,3,4],[5,6,7,8]]) -\end{verbatim} - - here we convert a list of lists to an array making a 2-d array. \begin{itemize} -\item Easier method of creating array with consecutive elements. -\end{itemize} - -\begin{verbatim} - In []: ar = arange(1,9) -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{\texttt{reshape()} method} -\label{sec-5} - +\item Arrays are homogeneous data structures. \begin{itemize} -\item To reshape an array +\item elements have to the same data type \end{itemize} - -\begin{verbatim} - In []: ar.reshape(2, 4) - In []: ar.reshape(4, 2) - In []: ar = ar.reshape(2, 4) -\end{verbatim} -\end{frame} -\begin{frame}[fragile] -\frametitle{Creating \texttt{array} from \texttt{list}.} -\label{sec-6} - +\item Arrays are faster compared to lists \begin{itemize} -\item \texttt{array()} method accepts list as argument -\item Creating a list -\begin{verbatim} - In []: l1 = [1, 2, 3, 4] -\end{verbatim} - -\item Creating an array -\begin{verbatim} - In []: a3 = array(l1) -\end{verbatim} - +\item at least \emph{80-100 times} faster than lists +\end{itemize} \end{itemize} -\end{frame} -\begin{frame} -\frametitle{Exercise 1} -\label{sec-7} - - Create a 3-dimensional array of the order (2, 2, 4). \end{frame} \begin{frame}[fragile] -\frametitle{\texttt{.shape} of array} -\label{sec-8} +\frametitle{\verb~.shape~ of array} +\label{sec-5} + \begin{itemize} -\item \texttt{.shape} +\item \verb~.shape~ To find the shape of the array \begin{verbatim} - In []: a1.shape + In []: a2.shape \end{verbatim} -\item \texttt{.shape} +\item \verb~.shape~ returns a tuple of shape \end{itemize} \end{frame} \begin{frame} -\frametitle{Exercise 2} -\label{sec-9} - - Find out the shape of the other arrays(a2, a3, ar) that we have created. -\end{frame} -\begin{frame}[fragile] -\frametitle{Homogeneous data} -\label{sec-10} - -\begin{itemize} -\item All elements in array should be of same type -\begin{verbatim} - In []: a4 = array([1,2,3,'a string']) -\end{verbatim} - -\end{itemize} -\end{frame} -\begin{frame}[fragile] -\frametitle{Implicit type casting} -\label{sec-11} - -\begin{verbatim} - In []: a4 -\end{verbatim} +\frametitle{Exercise 1} +\label{sec-6} - All elements are type casted to string type + Find out the shape of the other arrays(a1, a3, ar) that we have created. \end{frame} \begin{frame} -\frametitle{\texttt{identity()}, \texttt{zeros()} methods} -\label{sec-12} +\frametitle{\verb~identity()~, \verb~zeros()~ methods} +\label{sec-7} + \begin{itemize} -\item \texttt{identity(n)} +\item \verb~identity(n)~ Creates an identity matrix, a square matrix of order (n, n) with diagonal elements 1 and others 0. -\item \texttt{zeros((m, n))} - Creates an \texttt{m X n} matrix with all elements 0. +\item \verb~zeros((m, n))~ + Creates an \verb~m X n~ matrix with all elements 0. \end{itemize} \end{frame} \begin{frame} \frametitle{Learning exercise} -\label{sec-13} +\label{sec-8} -\begin{itemize} -\item Find out about + Find out about \begin{itemize} -\item \texttt{zeros\_like()} -\item \texttt{ones()} -\item \texttt{ones\_like()} -\end{itemize} - +\item \verb~zeros\_like()~ +\item \verb~ones()~ +\item \verb~ones\_like()~ \end{itemize} \end{frame} \begin{frame} -\frametitle{Array operations} -\label{sec-14} +\frametitle{Summary} +\label{sec-9} -\begin{itemize} -\item \texttt{a1 * 2} - returns a new array with all elements of \texttt{a1} multiplied by \texttt{2}. + In this tutorial, we have learnt to, \begin{itemize} -\item Similarly \texttt{+}, \texttt{-} \& \texttt{/}. -\end{itemize} - -\item \texttt{a1 + 2} - returns a new array with all elements of \texttt{a1} summed with \texttt{2}. -\item \texttt{a1 += 2} - adds \texttt{2} to all elements of array \texttt{a1}. - +\item Create an array using the ``array()`` function. +\item Convert a list to an array. +\item Perform some basic operations on arrays like addition,multiplication. +\item Use functions like \begin{itemize} -\item Similarly \texttt{-=}, \texttt{*=} \& \texttt{/=}. +\item .shape +\item arrange() +\item .reshape +\item zeros() \& zeros\_like() +\item ones() \& ones\_like() \end{itemize} +\end{itemize} +\end{frame} +\begin{frame} +\frametitle{Evaluation} +\label{sec-10} -\item \texttt{a1 + a2} - does elements-wise addition. +\begin{enumerate} +\item ``x = array([1, 2, 3], [5, 6, 7])`` is a valid statement \begin{itemize} -\item Similarly \texttt{-}, \texttt{*} \& \texttt{/}. +\item True +\item False \end{itemize} +\vspace{4pt} +\item What does the ``ones\_like()`` function do? + + (A) Returns an array of ones with the same shape and type as a + given array.\\ + (B) Return a new array of given shape and type, filled with ones. +\vspace{6pt} -\item \texttt{a1 * a2} - does element-wise multiplication + Read the statements and answer, +\begin{itemize} +\item Only statement A is correct. +\item Only statement B is correct. +\item Both statement A and B are correct. +\item Both statement A and B are incorrect. \end{itemize} - - - \textbf{Note} - array(A) * array(B) does element wise multiplication and not matrix multiplication +\end{enumerate} \end{frame} \begin{frame} -\frametitle{Summary} -\label{sec-15} +\frametitle{Solutions} +\label{sec-11} - In this tutorial we covered, -\begin{itemize} -\item Basics of arrays -\item Creating arrays -\item Arrays from lists -\item Basic array operations -\end{itemize} + +\begin{enumerate} +\item False\\ + x = array([[1, 2, 3], [5, 6, 7]]) +\vspace{12pt} +\item Statement A - Returns an array of ones with the same shape and type as a + given array. +\end{enumerate} \end{frame} \begin{frame} -\frametitle{Thank you!} -\label{sec-16} \begin{block}{} \begin{center} - This spoken tutorial has been produced by the - \textcolor{blue}{FOSSEE} team, which is funded by the + \textcolor{blue}{\Large THANK YOU!} \end{center} + \end{block} +\begin{block}{} \begin{center} - \textcolor{blue}{National Mission on Education through \\ - Information \& Communication Technology \\ - MHRD, Govt. of India}. + For more Information, visit our website\\ + \url{http://fossee.in/} \end{center} \end{block} \end{frame} -\end{document} +\end{document}
\ No newline at end of file |