The following functions can be imported from cvxopt.
sqrt(x)
The elementwise square root of a dense matrix x. The result is returned as a real matrix if x is an integer or real matrix and as a complex matrix if x is a complex matrix. Raises an exception when x is an integer or real matrix with negative elements.
As an example we take the elementwise square root of the sparse matrix
![]() | (2.2) |
sin(x)
The sine function applied elementwise to a dense matrix x. The result is returned as a real matrix if x is an integer or real matrix and as a complex matrix otherwise.
cos(x)
The cosine function applied elementwise to a dense matrix x. The result is returned as a real matrix if x is an integer or real matrix and as a complex matrix otherwise.
exp(x)
The exponential function applied elementwise to a dense matrix x. The result is returned as a real matrix if x is an integer or real matrix and as a complex matrix otherwise.
log(x)
The natural logarithm applied elementwise to a dense matrix x. The result is returned as a real matrix if x is an integer or real matrix and as a complex matrix otherwise. Raises an exception when x is an integer or real matrix with nonnegative elements, or a complex matrix with zero elements.
mul(x0, [, x1 [, x2 …]])
If the arguments are dense or sparse matrices of the same size, returns the elementwise product of its arguments. The result is a sparse matrix if one or more of its arguments is sparse, and a dense matrix otherwise.
If the arguments include scalars, a scalar product with the scalar is made. (A 1 by 1 dense matrix is treated as a scalar if the dimensions of the other arguments are not all 1 by 1.)
mul() can also be called with an iterable (list, tuple, xrange object, or generator) as its single argument, if the iterable generates a list of dense or sparse matrices or scalars.
div(x, y)
Returns the elementwise division of x by y. x is a dense or sparse matrix, or a scalar (Python number of 1 by 1 dense matrix). y is a dense matrix or a scalar.
max(x0[, x1[, x2 …]])
When called with a single matrix argument, returns the maximum of the elements of the matrix (including the zero entries, if the matrix is sparse).
When called with multiple arguments, the arguments must be matrices of the same size, or scalars, and the elementwise maximum is returned. A 1 by 1 dense matrix is treated as a scalar if the other arguments are not all 1 by 1. If one of the arguments is scalar, and the other arguments are not all 1 by 1, then the scalar argument is interpreted as a dense matrix with all its entries equal to the scalar.
The result is a sparse matrix if all its arguments are sparse matrices. The result is a number if all its arguments are numbers. The result is a dense matrix if at least one of the arguments is a dense matrix.
max() can also be called with an iterable (list, tuple, xrange object, or generator) as its single argument, if the iterable generates a list of dense or sparse matrices or scalars.
It is important to note the difference between this max() and the built-in max(), explained in the previous section.
min(x0[, x1[, x2 …]])
When called with a single matrix argument, returns the minimum of the elements of the matrix (including the zero entries, if the matrix is sparse).
When called with multiple arguments, the arguments must be matrices of the same size, or scalars, and the elementwise maximum is returned. A 1 by 1 dense matrix is treated as a scalar if the other arguments are not all 1 by 1. If one of the arguments is scalar, and the other arguments are not all 1 by 1, then the scalar argument is interpreted as a dense matrix with all its entries equal to the scalar.
min() can also be called with an iterable (list, tuple, xrange object, or generator) as its single argument, if the iterable generates a list of dense or sparse matrices or scalars.