getting-started-with-arrays/slides.tex
author anand
Sun, 07 Nov 2010 01:18:26 +0530
changeset 390 69f285b3a5ed
parent 304 d98f554bbec0
child 393 f99254fc7d70
permissions -rw-r--r--
checklist OK for `accessing pieces arrays`
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
304
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     1
% Created 2010-10-12 Tue 00:20
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     2
\documentclass[presentation]{beamer}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     3
\usepackage[latin1]{inputenc}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     4
\usepackage[T1]{fontenc}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     5
\usepackage{fixltx2e}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     6
\usepackage{graphicx}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     7
\usepackage{longtable}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     8
\usepackage{float}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
     9
\usepackage{wrapfig}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    10
\usepackage{soul}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    11
\usepackage{t1enc}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    12
\usepackage{textcomp}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    13
\usepackage{marvosym}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    14
\usepackage{wasysym}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    15
\usepackage{latexsym}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    16
\usepackage{amssymb}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    17
\usepackage{hyperref}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    18
\tolerance=1000
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    19
\usepackage[english]{babel} \usepackage{ae,aecompl}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    20
\usepackage{mathpazo,courier,euler} \usepackage[scaled=.95]{helvet}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    21
\usepackage{listings}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    22
\lstset{language=Python, basicstyle=\ttfamily\bfseries,
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    23
commentstyle=\color{red}\itshape, stringstyle=\color{darkgreen},
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    24
showstringspaces=false, keywordstyle=\color{blue}\bfseries}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    25
\providecommand{\alert}[1]{\textbf{#1}}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    26
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    27
\title{Getting started with arrays}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    28
\author{FOSSEE}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    29
\date{}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    30
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    31
\usetheme{Warsaw}\usecolortheme{default}\useoutertheme{infolines}\setbeamercovered{transparent}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    32
\begin{document}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    33
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    34
\maketitle
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    35
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    36
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    37
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    38
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    39
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    40
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    41
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    42
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    43
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    44
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    45
\frametitle{Outline}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    46
\label{sec-1}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    47
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    48
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    49
\item Arrays
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    50
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    51
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    52
\item why arrays over lists
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    53
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    54
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    55
\item Creating arrays
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    56
\item Array operations
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    57
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    58
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    59
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    60
\frametitle{Overview of Arrays}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    61
\label{sec-2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    62
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    63
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    64
\item Arrays are homogeneous data structures.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    65
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    66
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    67
\item elements have to the same data type
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    68
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    69
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    70
\item Arrays are faster compared to lists
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    71
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    72
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    73
\item at least \emph{80-100 times} faster than lists
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    74
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    75
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    76
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    77
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    78
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    79
\frametitle{Creating Arrays}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    80
\label{sec-3}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    81
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    82
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    83
\item Creating a 1-dimensional array
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    84
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    85
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    86
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    87
   In []: a1 = array([1, 2, 3, 4])
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    88
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    89
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    90
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    91
\item Creating a 2-dimensional array
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    92
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    93
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    94
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    95
   In []: a2 = array([[1,2,3,4],[5,6,7,8]])
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    96
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    97
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    98
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
    99
\item Easier method of creating array with consecutive elements.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   100
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   101
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   102
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   103
   In []: ar = arange(1,9)
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   104
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   105
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   106
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   107
\frametitle{\texttt{reshape()} method}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   108
\label{sec-4}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   109
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   110
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   111
\item To reshape an array
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   112
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   113
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   114
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   115
   In []: ar.reshape(2, 4)
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   116
   In []: ar.reshape(4, 2)
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   117
   In []: ar = ar.reshape(2, 4)
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   118
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   119
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   120
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   121
\frametitle{Creating \texttt{array} from \texttt{list}.}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   122
\label{sec-5}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   123
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   124
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   125
\item \texttt{array()} method accepts list as argument
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   126
\item Creating a list
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   127
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   128
    In []: l1 = [1, 2, 3, 4]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   129
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   130
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   131
\item Creating an array
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   132
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   133
     In []: a3 = array(l1)
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   134
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   135
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   136
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   137
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   138
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   139
\frametitle{Exercise 1}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   140
\label{sec-6}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   141
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   142
  Create a 3-dimensional array of the order (2, 2, 4).
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   143
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   144
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   145
\frametitle{\texttt{.shape} of array}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   146
\label{sec-7}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   147
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   148
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   149
\item \texttt{.shape}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   150
    To find the shape of the array
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   151
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   152
     In []: a1.shape
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   153
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   154
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   155
\item \texttt{.shape}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   156
    returns a tuple of shape
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   157
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   158
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   159
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   160
\frametitle{Exercise 2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   161
\label{sec-8}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   162
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   163
  Find out the shape of the other arrays(a2, a3, ar) that we have created.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   164
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   165
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   166
\frametitle{Homogeneous data}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   167
\label{sec-9}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   168
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   169
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   170
\item All elements in array should be of same type
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   171
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   172
     In []: a4 = array([1,2,3,'a string'])
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   173
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   174
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   175
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   176
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   177
\begin{frame}[fragile]
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   178
\frametitle{Implicit type casting}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   179
\label{sec-10}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   180
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   181
\begin{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   182
    In []: a4
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   183
\end{verbatim}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   184
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   185
    All elements are type casted to string type
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   186
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   187
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   188
\frametitle{\texttt{identity()}, \texttt{zeros()} methods}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   189
\label{sec-11}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   190
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   191
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   192
\item \texttt{identity(n)}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   193
    Creates an identity matrix, a square matrix of order (n, n) with diagonal elements 1 and others 0.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   194
\item \texttt{zeros((m, n))}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   195
    Creates an \texttt{m X n} matrix with all elements 0.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   196
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   197
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   198
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   199
\frametitle{Learning exercise}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   200
\label{sec-12}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   201
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   202
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   203
\item Find out about
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   204
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   205
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   206
\item \texttt{zeros\_like()}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   207
\item \texttt{ones()}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   208
\item \texttt{ones\_like()}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   209
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   210
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   211
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   212
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   213
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   214
\frametitle{Array operations}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   215
\label{sec-13}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   216
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   217
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   218
\item \texttt{a1 * 2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   219
    returns a new array with all elements of \texttt{a1} multiplied by \texttt{2}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   220
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   221
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   222
\item Similarly \texttt{+}, \texttt{-} \& \texttt{/}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   223
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   224
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   225
\item \texttt{a1 + 2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   226
    returns a new array with all elements of \texttt{a1} summed with \texttt{2}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   227
\item \texttt{a1 += 2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   228
    adds \texttt{2} to all elements of array \texttt{a1}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   229
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   230
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   231
\item Similarly \texttt{-=}, \texttt{*=} \& \texttt{/=}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   232
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   233
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   234
\item \texttt{a1 + a2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   235
    does elements-wise addition.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   236
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   237
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   238
\item Similarly \texttt{-}, \texttt{*} \& \texttt{/}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   239
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   240
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   241
\item \texttt{a1 * a2}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   242
    does element-wise multiplication
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   243
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   244
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   245
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   246
  \textbf{Note} - array(A) * array(B) does element wise multiplication and not matrix multiplication
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   247
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   248
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   249
\frametitle{Summary}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   250
\label{sec-14}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   251
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   252
  In this tutorial we covered,
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   253
\begin{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   254
\item Basics of arrays
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   255
\item Creating arrays
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   256
\item Arrays from lists
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   257
\item Basic array operations
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   258
\end{itemize}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   259
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   260
\begin{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   261
\frametitle{Thank you!}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   262
\label{sec-15}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   263
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   264
  \begin{block}{}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   265
  \begin{center}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   266
  This spoken tutorial has been produced by the
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   267
  \textcolor{blue}{FOSSEE} team, which is funded by the 
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   268
  \end{center}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   269
  \begin{center}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   270
    \textcolor{blue}{National Mission on Education through \\
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   271
      Information \& Communication Technology \\ 
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   272
      MHRD, Govt. of India}.
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   273
  \end{center}  
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   274
  \end{block}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   275
\end{frame}
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   276
d98f554bbec0 added slides for getting-started-with-arrays.
Anoop Jacob Thomas<anoop@fossee.in>
parents:
diff changeset
   277
\end{document}