/// <summary>Computes the Cholesky factorization of a Hermitian positive-definite matrix using the Rectangular Full Packed (RFP) format, i.e. /// A = conj(U') * U or A = L * conj(L'), where L is a lower triangular matrix and U is upper triangular. /// </summary> /// <param name="n">The order of the matrix.</param> /// <param name="a">The matrix A in the RFP format, i.e. an array with at least <paramref name="n"/> * (<paramref name="n"/> + 1) / 2 elements; overwritten by the upper or lower triangular matrix U, L respectively.</param> /// <param name="triangularMatrixType">A value indicating whether the upper or lower triangular part of matrix A is stored and how matrix A is factored.</param> /// <param name="transposeState">A value indicating whether <paramref name="a"/> represents matrix A or its transposed.</param> public void zpftrf(int n, Complex[] a, BLAS.TriangularMatrixType triangularMatrixType = BLAS.TriangularMatrixType.LowerTriangularMatrix, BLAS.MatrixTransposeState transposeState = BLAS.MatrixTransposeState.NoTranspose) { int info; var trans = LAPACK.GetTrans(transposeState); var uplo = LAPACK.GetUplo(triangularMatrixType); _zpftrf(ref trans, ref uplo, ref n, a, out info); CheckForError(info, "zpftrf"); }
/// <summary>Uses QR or LQ factorization to solve a overdetermined or underdetermined linear system with full rank matrix, i.e. minimize ||b - op(A) * x||. /// </summary> /// <param name="m">The number of rows of the matrix A.</param> /// <param name="n">The number of columns of the matrix A.</param> /// <param name="nrhs">The number of right-hand sides; the number of columns in b.</param> /// <param name="a">The <paramref name="m"/>-by-<paramref name="n"/> matrix provided column-by-column.</param> /// <param name="b">The <paramref name="m"/>-by-<paramref name="nrhs"/> matrix B of right hand side vectors, stored columnwise.</param> /// <param name="work">A workspace array.</param> /// <param name="transposeState">A value indicating whether to take into account A or A'.</param> public void driver_zgels(int m, int n, int nrhs, Complex[] a, Complex[] b, Complex[] work, BLAS.MatrixTransposeState transposeState = BLAS.MatrixTransposeState.NoTranspose) { int info; var trans = LAPACK.GetTrans(transposeState); int lda = Math.Max(1, m); int ldb = Math.Max(1, Math.Max(m, n)); int lwork = work.Length; _driver_zgels(ref trans, ref m, ref n, ref nrhs, a, ref lda, b, ref ldb, work, ref lwork, out info); CheckForError(info, "zgels"); }
/// <summary>Gets a optimal workspace array length for the <c>zgels</c> function. /// </summary> /// <param name="m">The number of rows of the matrix A.</param> /// <param name="n">The number of columns of the matrix A.</param> /// <param name="nrhs">The number of right-hand sides; the number of columns in b.</param> /// <param name="transposeState">A value indicating whether to take into account A or A'.</param> /// <returns>The optimal workspace array length.</returns> public int driver_zgelsQuery(int m, int n, int nrhs, BLAS.MatrixTransposeState transposeState = BLAS.MatrixTransposeState.NoTranspose) { int info; var trans = LAPACK.GetTrans(transposeState); int lda = Math.Max(1, m); int ldb = Math.Max(1, Math.Max(m, n)); int lwork = -1; unsafe { Complex *work = stackalloc Complex[1]; _driver_zgels(ref trans, ref m, ref n, ref nrhs, null, ref lda, null, ref ldb, work, ref lwork, out info); CheckForError(info, "zgels"); return(((int)work[0].Real) + 1); } }