14.10 Class LinAlg

mosek.LinAlg

BLAS/LAPACK linear algebra routines.

Static members:

LinAlg.axpy – Computes vector addition and multiplication by a scalar.

LinAlg.dot – Computes the inner product of two vectors.

LinAlg.gemm – Performs a dense matrix multiplication.

LinAlg.gemv – Computes dense matrix times a dense vector product.

LinAlg.potrf – Computes a Cholesky factorization of a dense matrix.

LinAlg.syeig – Computes all eigenvalues of a symmetric dense matrix.

LinAlg.syevd – Computes all the eigenvalues and eigenvectors of a symmetric dense matrix, and thus its eigenvalue decomposition.

LinAlg.syrk – Performs a rank-k update of a symmetric matrix.

LinAlg.axpy
LinAlg.axpy(int n, float alpha, float[] x, float[] y)

Adds αx to y, i.e. performs the update

y:=αx+y.

Note that the result is stored overwriting y. It must not overlap with the other input arrays.

Parameters:
  • n (int) – Length of the vectors.

  • alpha (float) – The scalar that multiplies x.

  • x (float[]) – The x vector.

  • y (float[]) – The y vector.

LinAlg.dot
LinAlg.dot(int n, float[] x, float[] y) -> float

Computes the inner product of two vectors x,y of length n0, i.e

xy=i=1nxiyi.

Note that if n=0, then the result of the operation is 0.

Parameters:
  • n (int) – Length of the vectors.

  • x (float[]) – The x vector.

  • y (float[]) – The y vector.

Return:

(float)

LinAlg.gemm
LinAlg.gemm(mosek.transpose transa, mosek.transpose transb, int m, int n, int k, float alpha, float[] a, float[] b, float beta, float[] c)

Performs a matrix multiplication plus addition of dense matrices. Given A, B and C of compatible dimensions, this function computes

C:=αop(A)op(B)+βC

where α,β are two scalar values. The function op(X) denotes X if transX is NO, or XT if set to YES. The matrix C has m rows and n columns, and the other matrices must have compatible dimensions.

The result of this operation is stored in C. It must not overlap with the other input arrays.

Parameters:
  • transa (transpose) – Indicates if A should be transposed. See the Optimizer API documentation for the definition of these constants.

  • transb (transpose) – Indicates if B should be transposed. See the Optimizer API documentation for the definition of these constants.

  • m (int) – Indicates the number of rows of matrix C.

  • n (int) – Indicates the number of columns of matrix C.

  • k (int) – Specifies the common dimension along which op(A) and op(B) are multiplied. For example, if neither A nor B are transposed, then this is the number of columns in A and also the number of rows in B.

  • alpha (float) – A scalar value multiplying the result of the matrix multiplication.

  • a (float[]) – The pointer to the array storing matrix A in a column-major format.

  • b (float[]) – The pointer to the array storing matrix B in a column-major format.

  • beta (float) – A scalar value that multiplies C.

  • c (float[]) – The pointer to the array storing matrix C in a column-major format.

LinAlg.gemv
LinAlg.gemv(mosek.transpose trans, int m, int n, float alpha, float[] a, float[] x, float beta, float[] y)

Computes the multiplication of a scaled dense matrix times a dense vector, plus a scaled dense vector. Precisely, if trans is NO then the update is

y:=αAx+βy,

and if trans is YES then

y:=αATx+βy,

where α,β are scalar values and A is a matrix with m rows and n columns.

Note that the result is stored overwriting y. It must not overlap with the other input arrays.

Parameters:
  • trans (transpose) – Indicates if A should be transposed. See the Optimizer API documentation for the definition of these constants.

  • m (int) – Specifies the number of rows of the matrix A.

  • n (int) – Specifies the number of columns of the matrix A.

  • alpha (float) – A scalar value multiplying the matrix A.

  • a (float[]) – A pointer to the array storing matrix A in a column-major format.

  • x (float[]) – A pointer to the array storing the vector x.

  • beta (float) – A scalar value multiplying the vector y.

  • y (float[]) – A pointer to the array storing the vector y.

LinAlg.potrf
LinAlg.potrf(mosek.uplo uplo, int n, float[] a)

Computes a Cholesky factorization of a real symmetric positive definite dense matrix.

Parameters:
  • uplo (uplo) – Indicates whether the upper or lower triangular part of the matrix is used. See the Optimizer API documentation for the definition of these constants.

  • n (int) – Specifies the dimension of the symmetric matrix.

  • a (float[]) – A symmetric matrix stored in column-major order. Only the lower or the upper triangular part is used, accordingly with the uplo argument. It will contain the result on exit.

LinAlg.syeig
LinAlg.syeig(mosek.uplo uplo, int n, float[] a, float[] w)

Computes all eigenvalues of a real symmetric matrix A. Given a matrix ARn×n it returns a vector wRn containing the eigenvalues of A.

Parameters:
  • uplo (uplo) – Indicates whether the upper or lower triangular part of the matrix is used. See the Optimizer API documentation for the definition of these constants.

  • n (int) – Specifies the dimension of the symmetric matrix.

  • a (float[]) – A symmetric matrix stored in column-major order. Only the lower or the upper triangular part is used, accordingly with the uplo argument. It will contain the result on exit.

  • w (float[]) – Array of length at least n containing the eigenvalues of A.

LinAlg.syevd
LinAlg.syevd(mosek.uplo uplo, int n, float[] a, float[] w)

Computes all the eigenvalues and eigenvectors a real symmetric matrix. Given the input matrix ARn×n, this function returns a vector wRn containing the eigenvalues of A and it also computes the eigenvectors of A. Therefore, this function computes the eigenvalue decomposition of A as

A=UVUT,

where V=diag(w) and U contains the eigenvectors of A.

Note that the matrix U overwrites the input data A.

Parameters:
  • uplo (uplo) – Indicates whether the upper or lower triangular part of the matrix is used. See the Optimizer API documentation for the definition of these constants.

  • n (int) – Specifies the dimension of the symmetric matrix.

  • a (float[]) – A symmetric matrix stored in column-major order. Only the lower or the upper triangular part is used, accordingly with the uplo argument. It will contain the result on exit.

  • w (float[]) – Array of length at least n containing the eigenvalues of A.

LinAlg.syrk
LinAlg.syrk(mosek.uplo uplo, mosek.transpose trans, int n, int k, float alpha, float[] a, float beta, float[] c)

Performs a symmetric rank-k update for a symmetric matrix.

Given a symmetric matrix CRn×n, two scalars α,β and a matrix A of rank kn, it computes either

C:=αAAT+βC,

when trans is set to NO and ARn×k, or

C:=αATA+βC,

when trans is set to YES and ARk×n.

Only the part of C indicated by uplo is used and only that part is updated with the result. It must not overlap with the other input arrays.

Parameters:
  • uplo (uplo) – Indicates whether the upper or lower triangular part of C is used. See the Optimizer API documentation for the definition of these constants.

  • trans (transpose) – Indicates if A should be transposed. See the Optimizer API documentation for the definition of these constants.

  • n (int) – Specifies the order of C.

  • k (int) – Indicates the number of rows or columns of A, depending on whether or not it is transposed, and its rank.

  • alpha (float) – A scalar value multiplying the result of the matrix multiplication.

  • a (float[]) – The pointer to the array storing matrix A in a column-major format.

  • beta (float) – A scalar value that multiplies C.

  • c (float[]) – The pointer to the array storing matrix C in a column-major format.