day2/session2.tex
changeset 97 555237dbce44
parent 96 a749db24e73b
--- a/day2/session2.tex	Sat Oct 10 08:03:50 2009 +0530
+++ b/day2/session2.tex	Mon Oct 12 11:56:07 2009 +0530
@@ -75,7 +75,7 @@
 % Title page
 \title[]{Numerical Computing with Numpy \& Scipy}
 
-\author[FOSSEE Team] {Asokan Pichai\\Prabhu Ramachandran}
+\author[FOSSEE Team] {FOSSEE}
 
 \institute[IIT Bombay] {Department of Aerospace Engineering\\IIT Bombay}
 \date[] {11, October 2009}
@@ -121,11 +121,11 @@
 \begin{frame}[fragile]
   \frametitle{Broadcasting}
   \begin{lstlisting}
-    >>> a = np.arange(4)
-    >>> b = np.arange(5)
+    >>> a = arange(4)
+    >>> b = arange(5)
     >>> a+b #Does this work?
     >>> a+3
-    >>> c=np.array([3])
+    >>> c = array([3])
     >>> a+c #Works!
     >>> b+c #But how?
     >>> a.shape, b.shape, c.shape
@@ -141,29 +141,21 @@
     \column{0.65\textwidth}
     \hspace*{-1.5in}
     \begin{lstlisting}
-      >>> a = np.arange(4)
+      >>> a = arange(4)
       >>> a+3
       array([3, 4, 5, 6])
     \end{lstlisting}
     \column{0.35\textwidth}
     \includegraphics[height=0.7in, interpolate=true]{data/broadcast_scalar}
   \end{columns}
-  \begin{itemize}
-    \item Allows functions to take inputs that are not of the same shape
-    \item 2 rules -
-      \begin{enumerate}
-      \item 1 is (repeatedly) prepended to shapes of smaller arrays
-      \item Size 1 in a dimension changed to Largest size in that dimension
-      \end{enumerate}
-  \end{itemize}
 \end{frame}
 
 \begin{frame}[fragile]
   \frametitle{Broadcasting in 3D}
     \begin{lstlisting}
-      >>> x = np.ones((3, 5))
-      >>> y = np.ones(8)
-      >>> (x[..., None] + y).shape
+      >>> x = ones((3, 5, 1))
+      >>> y = ones(8)
+      >>> (x + y).shape
       (3, 5, 8)
     \end{lstlisting}
     \begin{figure}
@@ -177,7 +169,7 @@
   \frametitle{Copies \& Views}
   \vspace{-0.1in}
   \begin{lstlisting}
-    >>> a = np.arange(1,9); a.shape=3,3
+    >>> a = arange(1,9); a.shape=3,3
     >>> b = a
     >>> b is a
     >>> b[0,0]=0; print a
@@ -211,12 +203,10 @@
 \begin{frame}[fragile]
   \frametitle{Copies contd \ldots}
   \begin{lstlisting}
-    >>> b = a[np.array([0,1,2])]
-    array([[1, 2, 3],
-           [4, 5, 6],
-           [7, 8, 9]])
+    >>> a = arange(1, 10, 2)
+    >>> b = a[array([0,2,3])]
     >>> b.flags.owndata
-    >>> abool=np.greater(a,2)
+    >>> abool=a>5
     >>> c = a[abool]
     >>> c.flags.owndata
   \end{lstlisting}
@@ -326,7 +316,7 @@
   Calculate the area under $(sin(x) + x^2)$ in the range $(0,1)$
   \begin{lstlisting}
     >>> def f(x):
-            return np.sin(x)+x**2
+            return sin(x)+x**2
     >>> integrate.quad(f, 0, 1)
   \end{lstlisting}
 \end{frame}
@@ -340,8 +330,8 @@
   \end{align*}
   \begin{lstlisting}
 >>> def dx_dt(x,t):
-        return -np.exp(-t)*x**2
->>> t = np.linspace(0,2,100)
+        return -exp(-t)*x**2
+>>> t = linspace(0,2,100)
 >>> x = integrate.odeint(dx_dt, 2, t)
 >>> plt.plot(x,t)
   \end{lstlisting}
@@ -354,14 +344,14 @@
   \begin{lstlisting}
 >>> from scipy import interpolate
 >>> interpolate.interp1d?
->>> x = np.arange(0,2*np.pi,np.pi/4)
->>> y = np.sin(x)
+>>> x = arange(0,2*pi,pi/4)
+>>> y = sin(x)
 >>> fl = interpolate.interp1d(
             x,y,kind='linear')
 >>> fc = interpolate.interp1d(
              x,y,kind='cubic')
->>> fl(np.pi/3)
->>> fc(np.pi/3)
+>>> fl(pi/3)
+>>> fc(pi/3)
   \end{lstlisting}
 \end{frame}
 
@@ -370,7 +360,7 @@
   Plot the Cubic Spline of $sin(x)$
   \begin{lstlisting}
 >>> tck = interpolate.splrep(x,y)
->>> xs = np.arange(0,2*np.pi,np.pi/50)
+>>> xs = arange(0,2*pi,pi/50)
 >>> ys = interpolate.splev(X,tck,der=0)
 >>> plt.plot(x,y,'o',x,y,xs,ys)
 >>> plt.show()
@@ -383,15 +373,12 @@
   \frametitle{Signal \& Image Processing}
     \begin{itemize}
      \item Convolution
-     \item B-splines
      \item Filtering
      \item Filter design
      \item IIR filter design
      \item Linear Systems
-     \item LTI Reresentations
-     \item Waveforms
+     \item LTI Representations
      \item Window functions
-     \item Wavelets
     \end{itemize}
 \end{frame}
 
@@ -409,6 +396,7 @@
   \begin{lstlisting}
 >>> b = ndimage.zoom(A,0.5)
 >>> imshow(b)
+>>> b = ndimage.zoom(A,2)
   \end{lstlisting}
     \inctime{5}
 \end{frame}