#LyX 1.5.2 created this file. For more info see http://www.lyx.org/ \lyxformat 276 \begin_document \begin_header \textclass article \begin_preamble \usepackage{geometry} %\geometry{verbose,letterpaper,tmargin=1.5in,bmargin=1.25in,lmargin=1in,rmargin=1in,headheight=1in,headsep=1in,footskip=1in} \input{macros} \makeatletter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands. %% Bold symbol macro for standard LaTeX users %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. \usepackage{wasysym} \AtBeginDocument{ \renewcommand{\labelitemii}{\(\blacktriangleright\)} } \makeatother \end_preamble \options 12pt \language english \inputencoding latin1 \font_roman default \font_sans default \font_typewriter default \font_default_family default \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100 \graphics default \paperfontsize default \spacing single \papersize default \use_geometry false \use_amsmath 1 \use_esint 0 \cite_engine basic \use_bibtopic false \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \author "" \author "" \end_header \begin_body \begin_layout Title Foundations I \end_layout \begin_layout Date \end_layout \begin_layout Author Sanjay Rajopadhye \end_layout \begin_layout Standard \begin_inset LatexCommand tableofcontents \end_inset \end_layout \begin_layout Section Introduction & Motivation \end_layout \begin_layout Standard \begin_inset LatexCommand label name "sec:intro" \end_inset \end_layout \begin_layout Standard These notes describe the mathematical foundations of some of the the important concepts that we encounter in this class. We will cover (i) specification of computations as equations; (ii) a taxonomy of equations; (iii) manipulation/transformation of equations; (iii) \begin_inset Quotes eld \end_inset executing \begin_inset Quotes erd \end_inset equations (i.e., deriving code from equations); (iv) polyhedra, their representat ion and their manipulations. \end_layout \begin_layout Subsection Why Equations? \end_layout \begin_layout Standard A large class of algorithms, especially those of interest to this class, can be described cleanly and concisely as mathematical equations. Here are a few examples. \end_layout \begin_layout Paragraph Forward Substitution \end_layout \begin_layout Standard Given an \begin_inset Formula $n\times n$ \end_inset lower triangular matrix \begin_inset Formula $L$ \end_inset (whose diagonal elements are unity), and an \begin_inset Formula $m$ \end_inset -vector, \begin_inset Formula $b$ \end_inset , solve for the vector \begin_inset Formula $x$ \end_inset in \begin_inset Formula $Lx=b$ \end_inset . \end_layout \begin_layout Standard Let us write down the definition of matrix-vector product: \end_layout \begin_layout Standard \begin_inset Formula \[ b_{i}=\sum_{j=1}^{n}L_{i,j}x_{j}\] \end_inset \end_layout \begin_layout Standard But since \begin_inset Formula $L$ \end_inset is lower triangular, every row \begin_inset Quotes eld \end_inset ends \begin_inset Quotes erd \end_inset at the diagonal, so the summation can be truncated at \begin_inset Formula $i$ \end_inset , as follows: \end_layout \begin_layout Standard \begin_inset Formula \[ b_{i}=\sum_{j=1}^{i}L_{i,j}x_{j}\] \end_inset \end_layout \begin_layout Standard Now we take the \begin_inset Quotes eld \end_inset last term outside the summation \begin_inset Quotes erd \end_inset to get (after some obvious simplification): \end_layout \begin_layout Standard \begin_inset Formula \[ b_{i}=\left\{ \begin{array}{lcl} i=1 & : & x_{i}\\ i>1 & : & {\displaystyle x_{i}+\sum_{j=1}^{i-1}L_{i,j}x_{j}}\end{array}\right.\] \end_inset \end_layout \begin_layout Standard Now we want to use this equation to \begin_inset Quotes eld \end_inset solve \begin_inset Quotes erd \end_inset for \begin_inset Formula $x$ \end_inset . We do this simply by \begin_inset Quotes eld \end_inset taking \begin_inset Formula $x$ \end_inset to the left hand side (lhs), \begin_inset Quotes erd \end_inset yielding: \begin_inset Formula \begin{equation} x_{i}=\left\{ \begin{array}{lcl} i=1 & : & b_{i}\\ i>1 & : & {\displaystyle b_{i}-\sum_{j=1}^{i-1}L_{i,j}x_{j}}\end{array}\right.\label{eq:fs}\end{equation} \end_inset \end_layout \begin_layout Standard Is this a \emph on program \emph default to solve a lower triangular system of equations? \end_layout \begin_layout Subsection Equations as programs \end_layout \begin_layout Standard We have made the case that the mathematical reasoning needed to solve many problems leads to equations, and these equations are in some sense, a very high level specification of an algorithm. The next step would be to actually make these equations the program itself. It is therefore useful to \begin_inset Quotes eld \end_inset codify \begin_inset Quotes erd \end_inset these equations so that they define a programming language (or rather, a sublanguage, since not everything that we want to program---such as file I/O---can be written as equations). Before we do this however, let us recap some of the advantages and issues that arise when viewing equations as programs. \end_layout \begin_layout Standard A primary advantage is that equations are amenable to formal resoning: we can prove properties of equations, analyze the dependence properties, and as we shall see later on, determine how to parallelize them, and how, starting from equations, to generate code (which may be sequential or parallel) or even hardware descriptions (VHDL) of parallel circuits that can be implement ed on FPGA platforms. We now illustrate some examples of such reasoning. \end_layout \begin_layout Paragraph Program complexity \end_layout \begin_layout Standard Consider the example for foward substitution (Eqn.\InsetSpace ~ \begin_inset LatexCommand ref reference "eq:fs" \end_inset ). Notice that for an \begin_inset Formula $n\times n$ \end_inset matrix, \begin_inset Formula $L$ \end_inset , there are \begin_inset Formula $n$ \end_inset values of \begin_inset Formula $x$ \end_inset that need to be determined (for \begin_inset Formula $i=1\ldots n$ \end_inset , the subscripts on the lhs). Further, for any given \begin_inset Formula $i$ \end_inset , the values that \begin_inset Formula $j$ \end_inset can take can be deduced from the bounds of the summation: \begin_inset Formula $j=1\ldots(i-1)$ \end_inset . Hence the set of \begin_inset Quotes eld \end_inset index values \begin_inset Quotes erd \end_inset where we need to do an \begin_inset Quotes eld \end_inset elementary \begin_inset Quotes erd \end_inset computation (here a multiply-accumulate) can be viewed as a triangle defined by \begin_inset Formula $\{\langle i,j\rangle\mid1\leq j