\chapter{The BLAS Interface (\module{cvxopt.blas})}\label{chap:blas} 
The \module{cvxopt.blas} module provides an interface to the 
double-precision real and complex Basic Linear Algebra Subprograms 
(BLAS).  The names and calling sequences of the Python functions in 
the interface closely match the corresponding Fortran BLAS routines 
(described in the references below) and their functionality is exactly 
the same.  

Many of the operations performed by the BLAS routines can be 
implemented in a more straightforward way by using the matrix 
arithmetic of section~\ref{s-arithmetic}, combined with the slicing 
and indexing of section~\ref{s-indexing}.
As an example, \samp{C = A*B} gives the same result as the BLAS
call \samp{gemm(A,B,C)}.
The BLAS interface offers two advantages.  First, some of the 
functions it includes are not easily implemented using the basic 
matrix arithmetic.  For example, BLAS includes functions that 
efficiently exploit symmetry or triangular matrix structure.
Second, there is a performance difference that can be significant for 
large matrices.   Although our implementation of the basic matrix 
arithmetic makes internal calls to BLAS, it also often requires 
creating temporary matrices to store intermediate results.  
The BLAS functions on the other hand always operate directly
on their matrix arguments and never require any copying to temporary 
matrices.  Thus they can be viewed as generalizations of the in-place 
matrix addition and scalar multiplication of 
section~\ref{s-arithmetic} to more complicated operations.

\textbf{See also:}
\BIT
\item \seetext{C. L. Lawson, R. J. Hanson, D. R. Kincaid, F. T. Krogh, 
Basic Linear Algebra Subprograms for Fortran Use,
ACM Transactions on Mathematical Software, 5(3), 309-323, 1975.}
\item \seetext{J. J. Dongarra, J. Du Croz, S. Hammarling, R. J. Hanson,
An Extended Set of Fortran Basic Linear Algebra Subprograms,
ACM Transactions on Mathematical Software, 14(1), 1-17, 1988.}
\item \seetext{J. J. Dongarra, J. Du Croz, S. Hammarling, I. Duff,
A Set of Level 3 Basic Linear Algebra Subprograms,
ACM Transactions on Mathematical Software, 16(1), 1-17, 1990.}
\EIT

\section{Matrix Classes} \label{s-conventions}

The BLAS exploit several types of matrix structure: symmetric, 
Hermitian, triangular, and banded.   We represent all these matrix 
classes by dense real or complex \mtrx\ objects, with additional 
arguments that specify the structure.

\begin{description}
\item[Vector] 
A real or complex \tm{n}-vector is represented by a \mtrx\ of type 
\dtc\ or \ztc\ and length \tm{n}, with the entries of the vector stored in 
column-major order. 

\item[General matrix]
A general real or complex \tm{m} by \tm{n} matrix is represented by 
a real or complex \mtrx\ of size (\tm{m}, \tm{n}).

\item[Symmetric matrix]
A real or complex symmetric matrix of order \tm{n} is represented
by a real or complex \mtrx\ of size (\tm{n}, \tm{n}), and a character 
argument \var{uplo} with two possible values:  
\code{'L'} and \code{'U'}.
If \var{uplo} is \code{'L'}, the lower triangular part of the
symmetric matrix is stored; if \var{uplo} is \code{'U'}, the upper
triangular part is stored.  A square \mtrx\ {\var X} of size 
({\it n}, {\it n}) can therefore be used to represent the symmetric 
matrices
\BEAS
&  \left[\begin{array}{ccccc}
X[0,0]   & X[1,0]   & X[2,0]   & \cdots & X[n-1,0] \\
X[1,0]   & X[1,1]   & X[2,1]   & \cdots & X[n-1,1] \\
X[2,0]   & X[2,1]   & X[2,2]   & \cdots & X[n-1,2] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
X[n-1,0] & X[n-1,1] & X[n-1,2] & \cdots & X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = 'L'}, \\
& \left[\begin{array}{ccccc}
X[0,0]   & X[0,1]   & X[0,2]   & \cdots & X[0,n-1] \\
X[0,1]   & X[1,1]   & X[1,2]   & \cdots & X[1,n-1] \\
X[0,2]   & X[1,2]   & X[2,2]   & \cdots & X[2,n-1] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
X[0,n-1] & X[1,n-1] & X[2,n-1] & \cdots & X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = U'}. 
\EEAS

\item[Complex Hermitian matrix]
A complex Hermitian matrix of order \tm{n} is represented
by a \mtrx\ of type \ztc\ and size (\tm{n}, \tm{n}), and
a character argument \var{uplo} with the same meaning as for symmetric 
matrices.
A complex \mtrx\ {\var X} of size (\tm{n}, \tm{n}) can represent the 8
Hermitian  matrices
\BEAS
&
\left[\begin{array}{ccccc}
\Re X[0,0]   & \bar X[1,0]   & \bar X[2,0]   & \cdots & \bar X[n-1,0] \\
X[1,0]   & \Re X[1,1]   & \bar X[2,1]   & \cdots & \bar X[n-1,1] \\
X[2,0]   & X[2,1]   & \Re X[2,2]   & \cdots & \bar X[n-1,2] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
X[n-1,0] & X[n-1,1] & X[n-1,2] & \cdots & \Re X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = 'L'}, \\
& \left[\begin{array}{ccccc}
\Re X[0,0]   & X[0,1]   & X[0,2]   & \cdots & X[0,n-1] \\
\bar X[0,1]   & \Re X[1,1]   & X[1,2]   & \cdots & X[1,n-1] \\
\bar X[0,2]   & \bar X[1,2]   & \Re X[2,2]   & \cdots & X[2,n-1] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
\bar X[0,n-1] & \bar X[1,n-1] & \bar X[2,n-1] & \cdots & \Re X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = 'U'}.
\EEAS

\item[Triangular matrix]
A real or complex triangular matrix of order \tm{n} is represented
by a real or complex \mtrx\ of size (\tm{n}, \tm{n}), and two 
character arguments: an argument \var{uplo} with possible values 
\code{'L'} and \code{'U'} to distinguish between lower and upper 
triangular matrices, and an argument \var{diag} with possible values 
\code{'U'} and \code{'N'} to distinguish between unit and non-unit 
triangular matrices.  A square \mtrx\ {\var X} of size 
(\tm{n}, \tm{n}) can represent the triangular matrices
\BEAS
& \left[\begin{array}{ccccc}
X[0,0]   & 0        & 0        & \cdots & 0 \\
X[1,0]   & X[1,1]   & 0        & \cdots & 0 \\
X[2,0]   & X[2,1]   & X[2,2]   & \cdots & 0 \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
X[n-1,0] & X[n-1,1] & X[n-1,2] & \cdots & X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = 'L' and diag = 'N'}, \\
& \left[\begin{array}{ccccc}
1   & 0   & 0   & \cdots & 0 \\
X[1,0]   & 1   & 0   & \cdots & 0 \\
X[2,0]   & X[2,1]   & 1   & \cdots & 0 \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
X[n-1,0] & X[n-1,1] & X[n-1,2] & \cdots & 1
\end{array}\right] & \mbox{if uplo = 'L' and diag = 'U'}, \\
& \left[\begin{array}{ccccc}
X[0,0]   & X[0,1]   & X[0,2]   & \cdots & X[0,n-1] \\
0   & X[1,1]   & X[1,2]   & \cdots & X[1,n-1] \\
0   & 0   & X[2,2]   & \cdots & X[2,n-1] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
0 & 0 & 0 & \cdots & X[n-1,n-1]
\end{array}\right] & \mbox{if uplo = 'U' and diag = 'N'}, \\
& \left[\begin{array}{ccccc}
1   & X[0,1]   & X[0,2]   & \cdots & X[0,n-1] \\
0   & 1   & X[1,2]   & \cdots & X[1,n-1] \\
0   & 0   & 1   & \cdots & X[2,n-1] \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots \\
0 & 0 & 0 & \cdots & 1
\end{array}\right] & \mbox{if uplo = 'U' and diag = 'U'}.
\EEAS

\item[General band matrix]
A general real or complex \tm{m} by \tm{n} band matrix  with \tm{\s{k}{l}}
subdiagonals and \tm{\s{k}{u}} superdiagonals is represented by a real or 
complex \mtrx\ \var{X} of size (\tm{\s{k}{l}+\s{k}{u}+1}, \tm{n}), 
and the two integers \tm{m} and \tm{\s{k}{l}}.   
The diagonals of the band matrix are stored in the rows of \var{X}, 
starting at the top diagonal, and shifted horizontally so that the 
entries of the 
\tm{k}th column of the band matrix are stored in column \tm{k} of 
{\var X}.  A \mtrx\ {\var X} of size (\tm{\s{k}{l}+\s{k}{u}+1}, \tm{n}) 
therefore represents the \tm{m} by \tm{n} band matrix
\[
\left[ \begin{array}{ccccccc}
X[k_u,0]     & X[k_u-1,1]     & X[k_u-2,2]     & \cdots & X[0,k_u] & 0               & \cdots \\
X[k_u+1,0]   & X[k_u,1]       & X[k_u-1,2]     & \cdots & X[1,k_u] & X[0,k_u+1]   & \cdots \\
X[k_u+2,0]   & X[k_u+1,1]     & X[k_u,2]       & \cdots & X[2,k_u] & X[1,k_u+1] & \cdots \\ 
 \vdots      & \vdots         &  \vdots        & \ddots & \vdots   & \vdots          & \ddots  \\
X[k_u+k_l,0] & X[k_u+k_l-1,1] & X[k_u+k_l-2,2] & \cdots &  &  & \\
0            & X[k_u+k_l,1]   & X[k_u+k_l-1,2] & \cdots &  &  & \\
\vdots       & \vdots         & \vdots         & \ddots &  &  & 
\end{array}\right].
\]

\item[Symmetric band matrix]
A real or complex symmetric band matrix of order \tm{n} with \tm{k}
subdiagonals, is represented by a real or complex matrix \var{X} of 
size (\tm{k+1}, \tm{n}), and an argument {\it uplo} to indicate 
whether the subdiagonals ({\it uplo} is \code{'L'}) or superdiagonals 
({\it uplo} is \code{'U'}) are stored.
The \tm{k+1} diagonals are stored as rows of \var{X}, starting at the top 
diagonal (\ie, the main diagonal if {\it uplo} is \code{'L'},  or
the \tm{k}th superdiagonal if {\it uplo} is \code{'U'}) and shifted
horizontally so that the entries of the 
\tm{k}th column of the band matrix are stored in column \tm{k} of 
{\var X}.  A \mtrx\ \var{X} of size (\tm{k+1}, \tm{n}) can therefore
represent the band matrices 
\BEAS
& \left[ \begin{array}{ccccccc}
X[0,0] & X[1,0]   & X[2,0]   & \cdots & X[k,0]   & 0        & \cdots \\
X[1,0] & X[0,1]   & X[1,1]   & \cdots & X[k-1,1] & X[k,1]   & \cdots \\
X[2,0] & X[1,1]   & X[0,2]   & \cdots & X[k-2,2] & X[k-1,2] & \cdots \\
\vdots & \vdots   &  \vdots  & \ddots & \vdots   & \vdots   & \ddots \\
X[k,0] & X[k-1,1] & X[k-2,2] & \cdots &  &  & \\
0      & X[k,1]   & X[k-1,2] & \cdots &  &  & \\
\vdots & \vdots   & \vdots   & \ddots &  &  & 
\end{array}\right] & \mbox{if uplo = 'L'}, \\
& 
\left[ \begin{array}{ccccccc}
X[k,0]   & X[k-1,1] & X[k-2,2] & \cdots & X[0,k] & 0        & \cdots \\
X[k-1,1] & X[k,1]   & X[k-1,2] & \cdots & X[1,k] & X[0,k+1] & \cdots \\
X[k-2,2] & X[k-1,2] & X[k,2]   & \cdots & X[2,k] & X[1,k+1] & \cdots \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots & \vdots   & \ddots \\
X[0,k]   & X[1,k]   & X[2,k]   & \cdots &  &  & \\
0        & X[0,k+1] & X[1,k+1] & \cdots &  &  & \\
\vdots   & \vdots   & \vdots   & \ddots &  &  & 
\end{array}\right] & \mbox{if uplo='U'}.
\EEAS

\item[Hermitian  band matrix]
A complex Hermitian band matrix of order \tm{n} with \tm{k} 
subdiagonals is represented by a complex matrix of size 
(\tm{k+1}, \tm{n}) and an argument \var{uplo}.  
A \mtrx\ \var{X} of size (\tm{k+1}, \tm{n}) can represent the band
matrices 
\BEAS
& \left[ \begin{array}{ccccccc}
\Re X[0,0] & \bar X[1,0]   & \bar X[2,0]   & \cdots & \bar X[k,0]   & 0        & \cdots \\
X[1,0] & \Re X[0,1]   & \bar X[1,1]   & \cdots & \bar X[k-1,1] & \bar X[k,1]   & \cdots \\
X[2,0] & X[1,1]   & \Re X[0,2]   & \cdots & \bar X[k-2,2] & \bar X[k-1,2] & \cdots \\
\vdots & \vdots   &  \vdots  & \ddots & \vdots   & \vdots   & \ddots \\
X[k,0] & X[k-1,1] & X[k-2,2] & \cdots &  &  & \\
0      & X[k,1]   & X[k-1,2] & \cdots &  &  & \\
\vdots & \vdots   & \vdots   & \ddots &  &  & 
\end{array}\right] & \mbox{if uplo = 'L'}, \\
& 
\left[ \begin{array}{ccccccc}
\Re X[k,0]   & X[k-1,1] & X[k-2,2] & \cdots & X[0,k] & 0        & \cdots \\
\bar X[k-1,1] & \Re X[k,1]   & X[k-1,2] & \cdots & X[1,k] & X[0,k+1] & \cdots \\
\bar X[k-2,2] & \bar X[k-1,2] & \Re X[k,2]   & \cdots & X[2,k] & X[1,k+1] & \cdots \\
\vdots   & \vdots   & \vdots   & \ddots & \vdots & \vdots   & \ddots \\
\bar X[0,k]   & \bar X[1,k]   & \bar X[2,k]   & \cdots &  &  & \\
0        & \bar X[0,k+1] & \bar X[1,k+1] & \cdots &  &  & \\
\vdots   & \vdots   & \vdots   & \ddots &  &  & 
\end{array}\right] & \mbox{if uplo='U'}.
\EEAS

\item[Triangular band matrix]
A triangular band matrix of order \tm{n} with \tm{k} subdiagonals or
superdiagonals is represented by a real complex matrix of size 
(\tm{k+1}, \tm{n}) and two character arguments \var{uplo} and 
\var{diag}.  
A \mtrx\ \var{X} of size (\tm{k+1}, \tm{n}) can represent the band
matrices 
\BEAS
& \left[ \begin{array}{cccc}
X[0,0] & 0        & 0        & \cdots \\
X[1,0] & X[0,1]   & 0        & \cdots  \\
X[2,0] & X[1,1]   & X[0,2]   & \cdots \\
\vdots & \vdots   & \vdots   & \ddots \\
X[k,0] & X[k-1,1] & X[k-2,2] & \cdots \\
0      & X[k,1]   & X[k-1,1] & \cdots \\
\vdots & \vdots   & \vdots   & \ddots 
\end{array}\right] & \mbox{if uplo = 'L' and diag = 'N'},  \\
& \left[ \begin{array}{cccc}
1      & 0        & 0        & \cdots \\
X[1,0] & 1        & 0        & \cdots  \\
X[2,0] & X[1,1]   & 1        & \cdots \\
\vdots & \vdots   & \vdots   & \ddots \\
X[k,0] & X[k-1,1] & X[k-2,2] & \cdots \\
0      & X[k,1]   & X[k-1,2] & \cdots \\
\vdots & \vdots   & \vdots   & \ddots 
\end{array}\right] & \mbox{if uplo = 'L'  and diag = 'U'}, \\
& \left[ \begin{array}{ccccccc}
X[k,0] & X[k-1,1] & X[k-2,3] & \cdots & X[0,k]  & 0        & \cdots\\
0      & X[k,1]   & X[k-1,2] & \cdots & X[1,k]  & X[0,k+1] & \cdots \\
0      & 0        & X[k,2]   & \cdots & X[2,k]  & X[1,k+1] & \cdots \\
\vdots & \vdots   &  \vdots  & \ddots & \vdots  & \vdots   & \ddots  
\end{array}\right] & \mbox{if uplo = 'U' and diag = 'N'}, \\
& \left[ \begin{array}{ccccccc}
1      & X[k-1,1] & X[k-2,3] & \cdots & X[0,k]  & 0        & \cdots\\
0      & 1        & X[k-1,2] & \cdots & X[1,k]  & X[0,k+1] & \cdots \\
0      & 0        & 1        & \cdots & X[2,k]  & X[1,k+1] & \cdots \\
\vdots & \vdots   &  \vdots  & \ddots & \vdots  & \vdots   & \ddots  
\end{array}\right] & \mbox{if uplo = 'U' and diag = 'U'}.
\EEAS
\end{description}

When discussing BLAS functions in the following sections we will
omit several less important optional arguments that can 
be used to select submatrices for in-place operations. 
The complete specification is  documented in the docstrings of the 
source code and the \program{pydoc} help program.

\section{Level 1 BLAS} \label{s-blas1}
The level 1 functions implement vector operations.  

\begin{funcdesc}{scal}{alpha, x}
Scales a vector by a constant: 
\[ 
x := \alpha x.
\]
If \var{x} is a real \mtrx, the scalar argument \var{alpha} must be a 
Python \intgr\ or \flt.  If \var{x} is complex, \var{alpha} can be an 
\intgr, \flt, or \cmplx.
\end{funcdesc}

\begin{funcdesc}{nrm2}{x}
Euclidean norm of a vector:  returns 
\[
 \|x\|_2.
\]  
\end{funcdesc}

\begin{funcdesc}{asum}{x}
1-Norm of a vector: returns 
\[
\|x\|_1 \quad \mbox{(\tm{x} real)}, \qquad  
\|\Re x\|_1 + \|\Im x\|_1 \quad \mbox{(\tm{x} complex)}.
\]
\end{funcdesc}

\begin{funcdesc}{iamax}{x}
Returns 
\[
 \argmax_{k=0,\ldots,n-1} |x_k| \quad \mbox{(\tm{x} real)}, \qquad
 \argmax_{k=0,\ldots,n-1} |\Re x_k| + |\Im x_k| \quad 
 \mbox{(\tm{x} complex)}. 
\]
If more than one coefficient achieves the maximum, the index of the 
first \tm{k} is returned.  
\end{funcdesc}

\begin{funcdesc}{swap}{x, y}
Interchanges two vectors:
\[
  x \leftrightarrow y.
\]
\var{x} and \var{y} are matrices of the same type (\dtc\ or \ztc).
\end{funcdesc}

\begin{funcdesc}{copy}{x, y}
Copies a vector to another vector:
\[
 y := x.
\]
\var{x} and \var{y} are matrices of the same type (\dtc\ or \ztc).
\end{funcdesc}

\begin{funcdesc}{axpy}{x, y\optional{,alpha=1.0}}
Constant times a vector plus a vector:  
\[ 
y := \alpha x + y.
\]
\var{x} and \var{y} are matrices of the same type (\dtc\ or \ztc).
If \var{x} is real, the scalar argument \var{alpha} must be a Python 
\intgr\ or \flt.  If \var{x} is complex, \var{alpha} can be an \intgr, 
\flt, or \cmplx.  
\end{funcdesc}

\begin{funcdesc}{dot}{x, y}
Returns 
\[ 
x^Hy. 
\]  
\var{x} and \var{y} are matrices of the same type (\dtc\ or \ztc).
\end{funcdesc}

\begin{funcdesc}{dotu}{x, y}
Returns 
\[ 
x^Ty. 
\]  
\var{x} and \var{y} are matrices of the same type (\dtc\ or \ztc).
\end{funcdesc}


\section{Level 2 BLAS} \label{s-blas2}
The level 2 functions implement matrix-vector products and 
rank-1 and rank-2 matrix updates.
Different types of matrix structure can be exploited using the 
conventions of section~\ref{s-conventions}. 

\begin{funcdesc}{gemv}{A, x, y\optional{, trans='N'\optional{, 
alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector product with a general matrix:  
\[ 
y := \alpha Ax + \beta y \quad (\mathrm{trans} = \mathrm{'N'}),
  \qquad 
y := \alpha A^T x + \beta y \quad (\mathrm{trans} = \mathrm{'T'}), 
  \qquad
y := \alpha A^H x + \beta y \quad (\mathrm{trans} = \mathrm{'C'}). 
\]
The arguments \var{A}, \var{x} and {\var y} must have the same type 
(\dtc\ or \ztc).  Complex values of \var{alpha} and \var{beta} are only
allowed if \var{A} is complex. 
\end{funcdesc}

\begin{funcdesc}{symv}{A, x, y\optional{, uplo='L'\optional{, 
alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector  product with a real symmetric matrix:  
\[
   y := \alpha A x + \beta y,
\]
where \tm{A} is a real symmetric matrix.  
The arguments \var{A}, \var{x} and {\var y} must have 
type \dtc\ and \var{alpha} and \var{beta} must be real.
\end{funcdesc}

\begin{funcdesc}{hemv}{A, x, y\optional{, uplo='L'\optional{, 
alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector  product with a real symmetric or complex Hermitian 
matrix: 
\[
   y := \alpha A x + \beta y,
\]
where \tm{A} is real symmetric or complex Hermitian.
The arguments \var{A}, \var{x} and {\var y} must have the same
type (\dtc\ or \ztc).  
Complex values of \var{alpha} and \var{beta} are only
allowed if \var{A} is complex. 
\end{funcdesc}

\begin{funcdesc}{trmv}{A, x\optional{, uplo='L'\optional{, 
trans='N'\optional{, diag='N'}}}}
Matrix-vector  product with a triangular matrix: 
\[ 
x := Ax \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A^T x \quad (\mathrm{trans} = \mathrm{'T'}), \qquad
x := A^H x \quad (\mathrm{trans} = \mathrm{'C'}), 
\]
where \tm{A} is square and triangular.
The arguments \var{A} and \var{x} must have the same type (\dtc\ or \ztc).
\end{funcdesc}

\begin{funcdesc}{trsv}{A, x\optional{, uplo='L'\optional{, 
trans='N'\optional{, diag='N'}}}}
Solution of a nonsingular triangular set of linear equations:
\[ 
x := A^{-1}x \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A^{-T}x \quad (\mathrm{trans} = \mathrm{'T'}), \qquad 
x := A^{-H}x \quad (\mathrm{trans} = \mathrm{'C'}), 
\]
where \tm{A} is square and triangular with nonzero diagonal 
elements.  The arguments \var{A} and \var{x} must have the same type 
(\dtc\ or \ztc).
\end{funcdesc}

\begin{funcdesc}{gbmv}{A, m, kl, x, y\optional{, trans='N'
\optional{, alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector product with a general band matrix:
\[ 
y := \alpha Ax + \beta y \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
y := \alpha A^T x + \beta y \quad (\mathrm{trans} = \mathrm{'T'}), 
\qquad 
y := \alpha A^H x + \beta y \quad (\mathrm{trans} = \mathrm{'C'}),
\]
where  \tm{A} is a rectangular band matrix with \tm{m} rows and 
\tm{\s{k}{l}} subdiagonals.
The arguments \var{A}, \var{x} and {\var y} must have the same
type (\dtc\ or \ztc).
Complex values of \var{alpha} and \var{beta} are only allowed if \var{A} is
 complex.
\end{funcdesc}

\begin{funcdesc}{sbmv}{A, x, y\optional{, uplo='L'\optional{, 
alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector  product with a real symmetric band matrix:
\[
 y := \alpha Ax + \beta y,
\]
where \tm{A} is a real symmetric band matrix.
The arguments \var{A}, \var{x} and {\var y} must have type \dtc\ and 
\var{alpha} and \var{beta} must be real.
\end{funcdesc}

\begin{funcdesc}{hbmv}{A, x, y\optional{, uplo='L'\optional{, 
alpha=1.0\optional{, beta=0.0}}}}
Matrix-vector  product with a real symmetric or complex Hermitian 
band matrix:
\[
 y := \alpha Ax + \beta y,
\]
where \tm{A} is a real symmetric or complex Hermitian band matrix.
The arguments \var{A}, \var{x} and {\var y} must have the same type
(\dtc\ or \ztc).  
Complex values of \var{alpha} and \var{beta} are only allowed if 
\var{A} is complex. 
\end{funcdesc}

\begin{funcdesc}{tbmv}{A, x\optional{, uplo='L'\optional{, 
trans\optional{, diag}}}}
Matrix-vector  product with a triangular band matrix:
\[
x := Ax \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A^T x \quad (\mathrm{trans} = \mathrm{'T'}), \qquad 
x := A^H x \quad (\mathrm{trans} = \mathrm{'C'}). 
\]
The arguments \var{A} and \var{x} must have the same type 
(\dtc\ or \ztc).  
\end{funcdesc}

\begin{funcdesc}{tbsv}{A, x\optional{, uplo='L'\optional{, 
trans\optional{, diag}}}}
Solution of a triangular banded set of linear equations:
\[
x := A^{-1}x \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A^{-T} x \quad (\mathrm{trans} = \mathrm{'T'}), \qquad
x := A^{-H} x \quad (\mathrm{trans} = \mathrm{'T'}), 
\]
where \tm{A} is a triangular band matrix of with nonzero diagonal 
elements.
The arguments \var{A} and \var{x} must have the same type 
(\dtc\ or \ztc).  
\end{funcdesc}

\begin{funcdesc}{ger}{x, y, A\optional{, alpha=1.0}}
General rank-1 update:
\[ 
A := A + \alpha x y^H,
\]
where \tm{A} is a general matrix.
The arguments \var{A}, \var{x} and \var{y} must have the same type 
(\dtc\ or \ztc).  
Complex values of \var{alpha} are only allowed if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{geru}{x, y, A\optional{, alpha=1.0}}
General rank-1 update:
\[ 
A := A + \alpha x y^T, 
\]
where \tm{A} is a general matrix.
The arguments \var{A}, \var{x} and \var{y} must have the same type 
(\dtc\ or \ztc).  
Complex values of \var{alpha} are only allowed if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{syr}{x, A\optional{, uplo='L'\optional{, alpha=1.0}}}
Symmetric rank-1 update:
\[
 A := A + \alpha xx^T,
\]
where \tm{A} is a real symmetric matrix.
The arguments \var{A} and \var{x} must have type \dtc.  
\var{alpha} must be a real number.
\end{funcdesc}

\begin{funcdesc}{her}{x, A\optional{, uplo='L'\optional{, alpha=1.0}}}
Hermitian rank-1 update:
\[
 A := A + \alpha xx^H, 
\]
where \tm{A} is a real symmetric or complex Hermitian matrix.
The arguments \var{A} and \var{x} must have the same type 
(\dtc\ or \ztc).  
\var{alpha} must be a real number.
\end{funcdesc}

\begin{funcdesc}{syr2}{x, y, A\optional{, uplo='L'\optional{, 
alpha=1.0}}}
Symmetric rank-2  update:
\[
 A := A + \alpha (xy^T + yx^T),
\]
where \tm{A} is a real symmetric matrix.
The arguments \var{A}, \var{x} and \var{y} must have type \dtc.  
\var{alpha} must be real.
\end{funcdesc}

\begin{funcdesc}{her2}{x, y, A\optional{, uplo='L'\optional{, 
alpha=1.0}}}
Symmetric rank-2  update:
\[
 A := A + \alpha xy^H + \bar \alpha yx^H,
\]
where \tm{A} is a a real symmetric or complex Hermitian matrix.
The arguments \var{A}, \var{x} and \var{y} must have the same type  
(\dtc\ or \ztc).  
Complex values of \var{alpha} are only allowed if \var{A} is complex.
\end{funcdesc}

As an example, the following code multiplies the tridiagonal matrix
\[
A = \left[\begin{array}{rrrr}
  1 &  6 &  0 & 0 \\ 
  2 & -4 &  3 & 0 \\ 
  0 & -3 & -1 & 1 
  \end{array}\right]
\]
with the vector {\it x} = (1,-1,2,-2).
\begin{verbatim}
>>> from cvxopt.base import matrix
>>> from cvxopt.blas import gbmv
>>> A = matrix([[0., 1., 2.],  [6., -4., -3.],  [3., -1., 0.],  [1., 0., 0.]])
>>> x = matrix([1., -1., 2., -2.])
>>> y = matrix(0., (3,1))
>>> gbmv(A, 3, 1, x, y)
>>> print y
[-5.00e+00]
[ 1.20e+01]
[-1.00e+00]
\end{verbatim}

The following example illustrates the use of \function{tbsv()}.
\begin{verbatim}
>>> from cvxopt.base import matrix
>>> from cvxopt.blas import tbsv
>>> A = matrix([-6., 5., -1., 2.], (1,4))
>>> x = matrix(1.0, (4,1))
>>> tbsv(A, x)  # x := diag(A)^{-1}*x
>>> print x
[-1.67e-01]
[ 2.00e-01]
[-1.00e+00]
[ 5.00e-01]
\end{verbatim}


\section{Level 3 BLAS} \label{s-blas3}
The level 3 BLAS include functions for matrix-matrix multiplication.

\begin{funcdesc}{gemm}{A, B, C\optional{, transA='N'\optional{, 
transB='N'\optional{, alpha=1.0\optional{, beta=0.0}}}}}
Matrix-matrix product of two general matrices:  
\[
  C := \alpha \op(A) \op(B) + \beta C 
\]
where
\[
\op(A) =  \left\{ \begin{array}{ll}
 A & \mathrm{transA} = \mathrm{'N'} \\
 A^T & \mathrm{transA} = \mathrm{'T'} \\
 A^H & \mathrm{transA} = \mathrm{'C'} \end{array} \right.
\qquad
\op(B) =  \left\{ \begin{array}{ll}
 B & \mathrm{transB} = \mathrm{'N'} \\
 B^T & \mathrm{transB} = \mathrm{'T'} \\
 B^H & \mathrm{transB} = \mathrm{'C'}. \end{array} \right.
\]
The arguments \var{A}, \var{B} and \var{C} must have the same type 
(\dtc\ or \ztc).
Complex values of \var{alpha} and \var{beta} are only allowed 
if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{symm}{A, B, C\optional{, side='L'\optional{, 
uplo='L'\optional{, alpha=1.0\optional{,  beta=0.0}}}}}
Product of a real or complex symmetric matrix \tm{A} and a general 
matrix \tm{B}:
\[
 C := \alpha AB + \beta C \quad (\mathrm{side} = \mathrm{'L'}), \qquad 
 C := \alpha BA + \beta C \quad (\mathrm{side} = \mathrm{'R'}). 
\]
The arguments \var{A}, \var{B} and \var{C} must have the same type 
(\dtc\ or \ztc).  Complex values of \var{alpha} and \var{beta} are 
only allowed if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{hemm}{A, B, C\optional{, side='L'\optional{, 
uplo='L'\optional{, alpha=1.0\optional{,  beta=0.0}}}}}
Product of a real symmetric or complex Hermitian matrix {\it A} and a 
general matrix {\it B}:
\[
 C := \alpha AB + \beta C \quad (\mathrm{side} = \mathrm{'L'}), \qquad 
 C := \alpha BA + \beta C \quad (\mathrm{side} = \mathrm{'R'}). 
\]
The arguments \var{A}, \var{B} and \var{C} must have the same type 
(\dtc\ or \ztc).
Complex values of \var{alpha} and \var{beta} are only allowed if 
\var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{trmm}{A, B\optional{, side='L'\optional{, 
uplo='L'\optional{, transA='N'\optional{, diag='N'\optional{, 
alpha=1.0}}}}}}
Product of a triangular matrix {\it A} and a general matrix {\it B}:
\[
 B := \alpha\op(A)B \quad (\mathrm{side} = \mathrm{'L'}), \qquad 
 B := \alpha B\op(A) \quad (\mathrm{side} = \mathrm{'R'}), \qquad 
 \op(A) =  \left\{ \begin{array}{ll}
 A & \mathrm{transA} = \mathrm{'N'} \\
 A^T & \mathrm{transA} = \mathrm{'T'} \\
 A^H & \mathrm{transA} = \mathrm{'C'}. \end{array} \right.
\]
The arguments \var{A} and \var{B} must have the same type (\dtc\ or 
\ztc).   Complex values of \var{alpha} are only allowed if \var{A} is 
complex.
\end{funcdesc}

\begin{funcdesc}{trsm}{A, B\optional{, side='L'\optional{, 
uplo='L'\optional{, transA='N'\optional{, diag='N'\optional{, 
alpha=1.0}}}}}}
Solution of a nonsingular triangular system of equations:
\[
 B := \alpha \op(A)^{-1}B \quad (\mathrm{side} = \mathrm{'L'}), \qquad 
 B := \alpha B\op(A)^{-1} \quad (\mathrm{side} = \mathrm{'R'}), \qquad 
 \op(A) =  \left\{ \begin{array}{ll}
 A & \mathrm{transA} = \mathrm{'N'} \\
 A^T & \mathrm{transA} = \mathrm{'T'} \\
 A^H & \mathrm{transA} = \mathrm{'C'}, \end{array} \right.
\]
where \tm{A} is triangular and \tm{B} is a general matrix.
The arguments \var{A} and \var{B} must have the same type (\dtc\ or 
\ztc).   Complex values of \var{alpha} are only allowed if \var{A} is 
complex.
\end{funcdesc}

\begin{funcdesc}{syrk}{A, C\optional{, uplo='L'\optional{, 
trans='N'\optional{, alpha=1.0\optional{, beta=0.0}}}}}
Rank-{\it k} update of a real or complex symmetric matrix {\it C}:
\[
 C := \alpha AA^T + \beta C \quad (\mathrm{trans} = \mathrm{'N'}), 
 \qquad 
 C := \alpha A^TA + \beta C \quad (\mathrm{trans} = \mathrm{'T'}), 
\]
where \tm{A} is a general matrix.
The arguments \var{A} and \var{C} must have the same type (\dtc\ or 
\ztc).  Complex values of \var{alpha} and \var{beta} are only allowed 
if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{herk}{A, C\optional{, uplo='L'\optional{, 
trans='N'\optional{, alpha=1.0\optional{, beta=0.0}}}}}
Rank-\tm{k} update of a real symmetric or complex Hermitian matrix \tm{C}:
\[
 C := \alpha AA^H + \beta C \quad (\mathrm{trans} = \mathrm{'N'}), 
 \qquad 
 C := \alpha A^HA + \beta C \quad (\mathrm{trans} = \mathrm{'C'}),
\]
where \tm{A} is a general matrix.
The arguments \var{A} and \var{C} must have the same type (\dtc\ or
\ztc).  \var{alpha} and \var{beta} must be real.
\end{funcdesc}

\begin{funcdesc}{syr2k}{A, B, C\optional{, uplo='L'\optional{, 
trans='N'\optional{, alpha=1.0\optional{, beta=0.0}}}}}
Rank-{\it 2k} update of a real or complex symmetric matrix {\it C}:
\[
 C := \alpha (AB^T + BA^T) + \beta C \quad 
  (\mathrm{trans} = \mathrm{'N'}), \qquad 
 C := \alpha (A^TB + B^TA) + \beta C \quad 
  (\mathrm{trans} = \mathrm{'T'}). 
\]
\tm{A} and \tm{B} are general real or complex matrices.
The arguments \var{A}, \var{B} and \var{C} must have the same
type.  Complex values of \var{alpha} and \var{beta} are only 
allowed if \var{A} is complex.
\end{funcdesc}

\begin{funcdesc}{her2k}{A, B, C\optional{, uplo='L'\optional{, 
trans='N'\optional{, alpha=1.0\optional{ beta=0.0}}}}}
Rank-\tm{2k} update of a real symmetric or complex Hermitian matrix \tm{C}:
\[
 C := \alpha AB^H + \bar \alpha BA^H + \beta C \quad 
  (\mathrm{trans} = \mathrm{'N'}), \qquad 
 C := \alpha A^HB + \bar\alpha B^HA + \beta C \quad 
  (\mathrm{trans} = \mathrm{'C'}), 
\]
where \tm{A} and \tm{B} are general matrices.
The arguments \var{A}, \var{B} and \var{C} must have the same type 
(\dtc\ or \ztc).  Complex values of \var{alpha} are only allowed if 
\var{A} is complex.  \var{beta} must be real.
\end{funcdesc}
