A, B[, ipiv=None]) |
'd'
or
'z'
).
The optional argument ipiv is an integer matrix of length at
least n.
If ipiv is provided, then gesv() solves the system,
replaces A with its triangular factors, and returns the
permutation matrix in ipiv.
If ipiv is not specified, then gesv() solves the
system but does not return the LU factorization and does not
modify A.
For example,
>>> gesv(A, B)
>>> gesv(A, B, ipiv)
Raises an ArithmeticError
if the matrix is singular.
A, ipiv) |
ArithmeticError
if the matrix is not full rank.
A, ipiv, B[, trans='N']) |
A, ipiv) |
In the following example we compute
>>> from cvxopt.base import matrix >>> from cvxopt.random import normal >>> from cvxopt.lapack import gesv, getrs >>> n = 10 >>> A = normal(n,n) >>> b = normal(n) >>> ipiv = matrix(0, (n,1)) >>> x = +b >>> gesv(A, x, ipiv) # x = A^{-1}*b >>> x2 = +b >>> getrs(A, ipiv, x2, trans='T') # x2 = A^{-T}*b >>> x += x2
Separate functions are provided for equations with band matrices.
A, kl, B[, ipiv=None]) |
'd'
or
'z'
).
The optional argument ipiv is an integer matrix of length at least n. If ipiv is provided, then A must have 2kl + ku + 1 rows. On entry the diagonals of A are stored in rows kl + 1 to 2kl + ku +1 of the A, using the BLAS format for general band matrices (see section 3.1). On exit, the factorization is returned in A and ipiv.
If ipiv is not provided, then A must have kl + ku + 1 rows. On entry the diagonals of A are stored in the rows of A, following the standard format for general band matrices. In this case, gbsv() does not modify A on exit and does not return the factorization.
On exit, B is replaced by the solution X.
Raises an ArithmeticError
if the matrix is singular.
A, m, kl, ipiv) |
ArithmeticError
if the matrix is not full rank.
A, kl, ipiv, B[, trans='N']) |
As an example, we solve a linear equation with
>>> from cvxopt.base import matrix >>> from cvxopt.lapack import gbsv, gbtrf, gbtrs >>> n, kl, ku = 4, 2, 1 >>> A = matrix([[0., 1., 3., 6.], [2., 4., 7., 10.], [5., 8., 11., 0.], [9., 12., 0., 0.]]) >>> x = matrix(1.0, (4,1)) >>> gbsv(A, kl, x) >>> print x 7.1429e-02 4.6429e-01 -2.1429e-01 -1.0714e-01
>>> Ac = matrix(0.0, (2*kl+ku+1,n)) >>> Ac[kl:,:] = A >>> ipiv = matrix(0, (n,1)) >>> x = matrix(1.0, (4,1)) >>> gbsv(Ac, kl, x, ipiv) # solves A*x = 1 >>> print x 7.1429e-02 4.6429e-01 -2.1429e-01 -1.0714e-01 >>> x = matrix(1.0, (4,1)) >>> gbtrs(Ac, kl, ipiv, x, trans='T') # solve A^T*x = 1 >>> print x 7.1429e-02 2.3810e-02 1.4286e-01 -2.3810e-02
>>> Ac[kl:,:] = A >>> gbtrf(Ac, n, kl, ipiv) >>> x = matrix(1.0, (4,1)) >>> gbtrs(Ac, kl, ipiv, x) # solve A^T*x = 1 >>> print x 7.1429e-02 4.6429e-01 -2.1429e-01 -1.0714e-01 >>> x = matrix(1.0, (4,1)) >>> gbtrs(Ac, kl, ipiv, x, trans='T') # solve A^T*x = 1 >>> print x 7.1429e-02 2.3810e-02 1.4286e-01 -2.3810e-02
The following functions can be used for tridiagonal matrices They use a simpler matrix format, that stores the diagonals in three separate vectors.
dl, d, du, B)) |
'd'
or 'z'
).
On exit dl, d, du are overwritten with the details of
the LU factorization of A, and B is overwritten with the
solution X.
Raises an ArithmeticError
if the matrix is singular.
dl, d, du, du2, ipiv) |
'i'
matrix of length n.
On exit, the five arguments contain the details of the factorization.
Raises an ArithmeticError
if the matrix is singular.
dl, d, du, du2, ipiv, B[, trans='N']) |