3.3 Level 2 BLAS

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 3.1.

gemv( A, x, y[, trans='N'[, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a general matrix:

\begin{displaymath}
y := \alpha Ax + \beta y \quad (\mathrm{trans} = \mathrm{'N'...
...\alpha A^H x + \beta y \quad (\mathrm{trans} = \mathrm{'C'}).
\end{displaymath}

The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha and beta are only allowed if A is complex.

symv( A, x, y[, uplo='L'[, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a real symmetric matrix:

\begin{displaymath}
y := \alpha A x + \beta y,
\end{displaymath}

where A is a real symmetric matrix. The arguments A, x and y must have type 'd' and alpha and beta must be real.

hemv( A, x, y[, uplo='L'[, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a real symmetric or complex Hermitian matrix:

\begin{displaymath}
y := \alpha A x + \beta y,
\end{displaymath}

where A is real symmetric or complex Hermitian. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha and beta are only allowed if A is complex.

trmv( A, x[, uplo='L'[, trans='N'[, diag='N']]])
Matrix-vector product with a triangular matrix:

\begin{displaymath}
x := Ax \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A...
...'}), \qquad
x := A^H x \quad (\mathrm{trans} = \mathrm{'C'}),
\end{displaymath}

where A is square and triangular. The arguments A and x must have the same type ('d' or 'z').

trsv( A, x[, uplo='L'[, trans='N'[, diag='N']]])
Solution of a nonsingular triangular set of linear equations:

\begin{displaymath}
x := A^{-1}x \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x...
..., \qquad
x := A^{-H}x \quad (\mathrm{trans} = \mathrm{'C'}),
\end{displaymath}

where A is square and triangular with nonzero diagonal elements. The arguments A and x must have the same type ('d' or 'z').

gbmv( A, m, kl, x, y[, trans='N' [, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a general band matrix:

\begin{displaymath}
y := \alpha Ax + \beta y \quad (\mathrm{trans} = \mathrm{'N'...
... \alpha A^H x + \beta y \quad (\mathrm{trans} = \mathrm{'C'}),
\end{displaymath}

where A is a rectangular band matrix with m rows and kl subdiagonals. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha and beta are only allowed if A is complex.

sbmv( A, x, y[, uplo='L'[, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a real symmetric band matrix:

\begin{displaymath}
y := \alpha A x + \beta y,
\end{displaymath}

where A is a real symmetric band matrix. The arguments A, x and y must have type 'd' and alpha and beta must be real.

hbmv( A, x, y[, uplo='L'[, alpha=1.0[, beta=0.0]]])
Matrix-vector product with a real symmetric or complex Hermitian band matrix:

\begin{displaymath}
y := \alpha A x + \beta y,
\end{displaymath}

where A is a real symmetric or complex Hermitian band matrix. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha and beta are only allowed if A is complex.

tbmv( A, x[, uplo='L'[, trans[, diag]]])
Matrix-vector product with a triangular band matrix:

\begin{displaymath}
x := Ax \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x := A...
...}), \qquad
x := A^H x \quad (\mathrm{trans} = \mathrm{'C'}).
\end{displaymath}

The arguments A and x must have the same type ('d' or 'z').

tbsv( A, x[, uplo='L'[, trans[, diag]]])
Solution of a triangular banded set of linear equations:

\begin{displaymath}
x := A^{-1}x \quad (\mathrm{trans} = \mathrm{'N'}), \qquad
x...
..., \qquad
x := A^{-H} x \quad (\mathrm{trans} = \mathrm{'T'}),
\end{displaymath}

where A is a triangular band matrix of with nonzero diagonal elements. The arguments A and x must have the same type ('d' or 'z').

ger( x, y, A[, alpha=1.0])
General rank-1 update:

\begin{displaymath}
A := A + \alpha x y^H,
\end{displaymath}

where A is a general matrix. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha are only allowed if A is complex.

geru( x, y, A[, alpha=1.0])
General rank-1 update:

\begin{displaymath}
A := A + \alpha x y^T,
\end{displaymath}

where A is a general matrix. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha are only allowed if A is complex.

syr( x, A[, uplo='L'[, alpha=1.0]])
Symmetric rank-1 update:

\begin{displaymath}
A := A + \alpha xx^T,
\end{displaymath}

where A is a real symmetric matrix. The arguments A and x must have type 'd'. alpha must be a real number.

her( x, A[, uplo='L'[, alpha=1.0]])
Hermitian rank-1 update:

\begin{displaymath}
A := A + \alpha xx^H,
\end{displaymath}

where A is a real symmetric or complex Hermitian matrix. The arguments A and x must have the same type ('d' or 'z'). alpha must be a real number.

syr2( x, y, A[, uplo='L'[, alpha=1.0]])
Symmetric rank-2 update:

\begin{displaymath}
A := A + \alpha (xy^T + yx^T),
\end{displaymath}

where A is a real symmetric matrix. The arguments A, x and y must have type 'd'. alpha must be real.

her2( x, y, A[, uplo='L'[, alpha=1.0]])
Symmetric rank-2 update:

\begin{displaymath}
A := A + \alpha xy^H + \bar \alpha yx^H,
\end{displaymath}

where A is a a real symmetric or complex Hermitian matrix. The arguments A, x and y must have the same type ('d' or 'z'). Complex values of alpha are only allowed if A is complex.

As an example, the following code multiplies the tridiagonal matrix

\begin{displaymath}
A = \left[\begin{array}{rrrr}
1 & 6 & 0 & 0 \\
2 & -4 & 3 & 0 \\
0 & -3 & -1 & 1
\end{array}\right]
\end{displaymath}

with the vector x = (1,-1,2,-2).
>>> 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.0000e+00
 1.2000e+01
-1.0000e+00

The following example illustrates the use of tbsv().

>>> 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.6667e-01
 2.0000e-01
-1.0000e+00
 5.0000e-01