
% this file is called up by thesis.tex
% content in this file will be fed into the main document

%: ----------------------- introduction file header -----------------------
\chapter{Algorithms}\label{A:algorithms}

\begin{algorithm}[H]
\label{alg:HITS}
  \SetAlgoLined
 {\bf HITS algorithm, adapted from \cite[p.~118]{Pagerank}}\\
  \KwIn{$A$: adjacency matrix; ${\bf x}^{(0)}$: starting vector; $\epsilon$: convergence tolerance}
  \KwOut{${\bf x}$: authority vector; ${\bf y}$: hub vector}
   initialization:  ${\bf x} = {\bf x}^{(0)}$\;
 $r = 1$ \;
 \While{$ r \geq \epsilon$}{
 ${\bf x}_o = {\bf x}$ \;
 ${\bf x} = A{\bf x}$ \;
 ${\bf x} = A^T{\bf x}$ \;
 ${\bf x} = \frac{1}{\|{\bf x}\|_2}{\bf x}$ \;
 $r = \|{\bf x} - {\bf x}_{o}\|_1$\;
 }
  $y=A{\bf x}$\;
  \caption{HITS Algorithm}
\end{algorithm}

\clearpage

\begin{algorithm}[H]
\label{alg:PageRank}
 \SetAlgoLined
{\bf PageRank Algorithm, adapted from \cite[p.~42]{Pagerank}} \\
  \KwIn{$H$: a row normalized hyperlink matrix; $\boldsymbol\pi^{(0)}$: starting vector; $\alpha$: scaling parameter ; $\epsilon$: convergence tolerance}
  \KwOut{$\pi$: PageRank vector}
  initialization:  $\boldsymbol\pi = \boldsymbol\pi^{(0)}$\;
 $r = 1$ \;
Replace zero rows of $H$ with $\frac{1}{n} {\bf 1}^T$ \;
  \While{$r \geq \epsilon$}{
    ${\bf x} = \boldsymbol\pi$ \;
    $\boldsymbol\pi^T = \alpha \boldsymbol\pi^T H + (1-\alpha) \frac{1}{n} {\bf 1}^T\bf{1}$ \;
	$r = \|\boldsymbol\pi -{\bf x}\|_1$ \;
    } 
  \caption{PageRank Algorithm}
\end{algorithm}

\clearpage

\begin{algorithm}[H]
\label{alg:Lanczos}
  \SetAlgoLined
{\bf Lanczos Algorithm, adapted from \cite[p.~8]{Me06}}
 \KwIn{$A$: a real, symmetric matrix; ${\bf v}$: starting vector}
\KwOut{entries of a symmetric tridiagonal matrix $T_k$: $\alpha_k = [T_k]_{k,k}$ and $\mu_k = [T_k]_{k,k-1}$}
${\bf v}_1 = \frac{1}{\|{\bf v}\|} {\bf v}$ \;
$\alpha_1 = {\bf v}_1^T A {\bf v}_1$ \;
$\tilde{{\bf v}_2} =  A{\bf v}_1 - \alpha_1{\bf v}_1$ \;
\For{$k=2,3,\ldots$}{
$\mu_k = \|\tilde{{\bf v}_k}\|$ \;
${\bf v}_k = \frac{1}{\mu_k}\tilde{{\bf v}_k}$ \;
${\bf u}_k = A{\bf v}_k - \mu_k {\bf v}_{k-1}$ \;
$\alpha_k = {\bf v}_k^T {\bf u}_k$ \;
$\tilde{{\bf v}_{k+1}} = {\bf u}_k -\alpha_k {\bf v}_k$ \;
}
  \caption{Lanczos Algorithm}
\end{algorithm}

% the code below specifies where the figures are stored

%: ----------------------- HELP: references
% References can be links to figures, tables, sections, or references.
% For figures, tables, and text you define the target of the link with \label{XYZ}. Then you call cross-link with the command \ref{XYZ}, as above
% Citations are bound in a very similar way with \cite{XYZ}. You store your references in a BibTex file with a programme like BibDesk.

%\section{Motivation}
%%%%%%%%%%%%%%%%%%%%%%%%
%In this thesis we are interested in efficient methods for the numerical solution of saddle point systems arising from finite element discretization of two important classes of fluid dynamic problems, namely the \emph{incompressible Navier-Stokes equations} and the \emph{Brinkman equations}. 

%: ----------------------- HELP: adding figures with macros
% \figuremacro{1}{2}{3}{4} calls up a series of commands formating your image.
% 1 = name of the file without extension; PNG, JPEG is ok; GIF doesn't work
% 2 = title of the figure AND the name of the label for cross-linking
% 3 = caption text for the figure
% 4 = size relative to text width which is 1; use this to reduce figures




