A, x, y[, trans='N'[, alpha=1.0[, beta=0.0]]]) |
matrix(A)
as
argument, however, without explicitly converting A to dense.
A, x, y[, uplo='L'[, alpha=1.0[, beta=0.0]]]) |
matrix(A)
as
argument, however, without explicitly converting A to dense.
A, B, C[, transA='N'[, transB='N'[, alpha=1.0[, beta=0.0[, partial=False]]]]]) |
If A and/or B are sparse and C is dense, the result
is the same as when blas.gemm() is called with
matrix(A)
and matrix(B)
as arguments, without explicitly
converting A and B to dense.
The argument partial is ignored.
If C is a sparse matrix, the matrix-matrix product in the
definition of blas.gemm() is computed, but as a sparse
matrix.
If partial is False
, the result is stored in C,
and the sparsity pattern of C is modified if necessary.
If partial is True
, the operation only updates the nonzero
elements in C, even if the sparsity pattern of C differs
from that of the matrix product.
A, C[, uplo='L'[, trans='N'[, alpha=1.0[, beta=0.0[, partial=False]]]]]) |
If A is sparse and C is dense, the result is the same as
when blas.syrk() is called with matrix(A)
as
argument, without explicitly converting A to dense.
The argument partial is ignored.
If C is sparse, the product in the definition of
blas.syrk() is computed, but as a sparse matrix.
If partial is False
, the result is stored in C,
and the sparsity pattern of C is modified if necessary.
If partial is True
, the operation only updates the nonzero
elements in C, even if the sparsity pattern of C differs
from that of the matrix product.
In the following example, we first compute
>>> from cvxopt.base import spmatrix, gemm >>> A = spmatrix(1, [1,3,0,2,1], [0,0,1,1,2]) >>> B = spmatrix([2,2,-1,3,2], [1,3,0,2,1], [0,0,1,1,2]) >>> C = spmatrix([], [], [], size=(3,3)) >>> gemm(A, B, C, transA='T') >>> print C SIZE: (3,3) (0, 0) 4.0000e+00 (2, 0) 2.0000e+00 (1, 1) 2.0000e+00 (0, 2) 2.0000e+00 (2, 2) 2.0000e+00
partial=True
option.
This saves time in large sparse matrix multiplications when the
sparsity pattern of the result is known beforehand.
>>> D = spmatrix([3,4,1,1,-2], [1,3,0,2,1], [0,0,1,1,2]) >>> gemm(A, D, C, transA='T', partial=True) >>> print C SIZE: (3,3) (0, 0) 7.0000e+00 (2, 0) 3.0000e+00 (1, 1) 2.0000e+00 (0, 2) -2.0000e+00 (2, 2) -2.0000e+00