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 \(\alpha x\) to \(y\), i.e. performs the update

\[y := \alpha 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 \(n\geq 0\), i.e

\[x\cdot y= \sum_{i=1}^n x_i y_i.\]

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:= \alpha op(A)op(B) + \beta C\]

where \(\alpha,\beta\) are two scalar values. The function \(op(X)\) denotes \(X\) if transX is NO, or \(X^T\) 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 := \alpha A x + \beta y,\]

and if trans is YES then

\[y := \alpha A^T x + \beta y,\]

where \(\alpha,\beta\) 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 \(A\in\real^{n\times n}\) it returns a vector \(w\in\real^n\) 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 \(A\in \real^{n\times n}\), this function returns a vector \(w\in \real^n\) containing the eigenvalues of \(A\) and it also computes the eigenvectors of \(A\). Therefore, this function computes the eigenvalue decomposition of \(A\) as

\[A= U V U^T,\]

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 \(C\in \real^{n\times n}\), two scalars \(\alpha,\beta\) and a matrix \(A\) of rank \(k\leq n\), it computes either

\[C := \alpha A A^T + \beta C,\]

when trans is set to NO and \(A\in \real^{n\times k}\), or

\[C := \alpha A^T A + \beta C,\]

when trans is set to YES and \(A\in \real^{k\times 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.